From 0dfe6cd0b2725c1e131f6665e19ed4a97a162443 Mon Sep 17 00:00:00 2001 From: Alexander Frick Date: Fri, 28 Apr 2023 03:32:08 -0500 Subject: [PATCH] update main BUILD.gns --- arm/build/config/compiler/BUILD.gn | 55 ++++++++++++-------- arm/raspi/build/config/compiler/BUILD.gn | 62 +++++++++++++++-------- other/AVX2/build/config/compiler/BUILD.gn | 56 ++++++++++++-------- other/SSE2/build/config/compiler/BUILD.gn | 56 ++++++++++++-------- other/SSE3/build/config/compiler/BUILD.gn | 56 ++++++++++++-------- src/build/config/compiler/BUILD.gn | 56 ++++++++++++-------- 6 files changed, 209 insertions(+), 132 deletions(-) diff --git a/arm/build/config/compiler/BUILD.gn b/arm/build/config/compiler/BUILD.gn index 21529131..2cfbe324 100644 --- a/arm/build/config/compiler/BUILD.gn +++ b/arm/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -617,8 +622,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -643,9 +647,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -841,9 +843,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -891,6 +892,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -1333,9 +1341,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1459,16 +1468,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1686,6 +1692,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2072,7 +2081,6 @@ if (is_win) { common_optimize_on_ldflags += [ ] - if (use_polly == true) { common_optimize_on_ldflags += [ "-mllvm:-polly", @@ -2194,12 +2202,12 @@ config("optimize") { if (chrome_pgo_phase != 2) { # Favor size over speed, /O1 must be before the common flags. # /O1 implies /Os and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] rustflags = [ "-Copt-level=3" ] } else { # PGO requires all translation units to be compiled with /O2. The actual # optimization level will be decided based on the profiling data. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2427,6 +2435,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) { diff --git a/arm/raspi/build/config/compiler/BUILD.gn b/arm/raspi/build/config/compiler/BUILD.gn index 4f93cc35..e777fbf9 100644 --- a/arm/raspi/build/config/compiler/BUILD.gn +++ b/arm/raspi/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -352,6 +357,11 @@ config("compiler") { } } + # ADDED BY ALEX313031 FOR THORIUM + if (is_clang && is_android && !is_ubsan && !is_ubsan_security) { + cflags += [ "-fwrapv" ] + } + # Linker warnings. if (fatal_linker_warnings && !is_apple && current_os != "aix" && current_os != "zos") { @@ -612,8 +622,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -638,9 +647,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -827,9 +834,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -877,6 +883,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -1301,9 +1314,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1427,16 +1441,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1654,6 +1665,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2074,11 +2088,12 @@ if (is_win) { # can be removed at link time with --gc-sections. "-fdata-sections", "-ffunction-sections", + "-funique-section-names", ] if ((!is_nacl || is_nacl_saigo) && is_clang) { # We don't care about unique section names, this makes object files a bit # smaller. - common_optimize_on_cflags += [ "-fno-unique-section-names" ] + # common_optimize_on_cflags += [ "-fno-unique-section-names" ] } common_optimize_on_ldflags += [ @@ -2133,7 +2148,7 @@ config("optimize") { # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is # to optimize for performance like `/O2` for clang. - rustflags = [] + rustflags = [ "-Copt-level=3" ] } } else if (optimize_for_size) { # Favor size over speed. @@ -2278,7 +2293,7 @@ config("optimize_speed") { config("optimize_fuzzing") { cflags = [ "-O3" ] + common_optimize_on_cflags - rustflags = [ "-Copt-level=3" ] + rustflags = [ "-Copt-level=3", ] ldflags = common_optimize_on_ldflags visibility = [ ":default_optimization" ] } @@ -2356,6 +2371,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) { diff --git a/other/AVX2/build/config/compiler/BUILD.gn b/other/AVX2/build/config/compiler/BUILD.gn index 973c95bf..317106b9 100644 --- a/other/AVX2/build/config/compiler/BUILD.gn +++ b/other/AVX2/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -617,8 +622,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -643,9 +647,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -832,9 +834,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -882,6 +883,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -896,7 +904,7 @@ config("compiler") { # For deterministic builds, keep the local machine's current working # directory from appearing in build outputs. "-Zremap-cwd-prefix=.", - + # Full RUSTC optimizations. "-Copt-level=3", "-Ctarget-feature=+aes,+avx,+avx2,-pclmul", ] @@ -1325,9 +1333,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1451,16 +1460,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1678,6 +1684,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2261,12 +2270,12 @@ config("optimize") { if (chrome_pgo_phase != 2) { # Favor size over speed, /O1 must be before the common flags. # /O1 implies /Os and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] rustflags = [ "-Copt-level=3" ] } else { # PGO requires all translation units to be compiled with /O2. The actual # optimization level will be decided based on the profiling data. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2494,6 +2503,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) { diff --git a/other/SSE2/build/config/compiler/BUILD.gn b/other/SSE2/build/config/compiler/BUILD.gn index 21e92381..e6bac206 100644 --- a/other/SSE2/build/config/compiler/BUILD.gn +++ b/other/SSE2/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -617,8 +622,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -643,9 +647,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -832,9 +834,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -882,6 +883,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -896,7 +904,7 @@ config("compiler") { # For deterministic builds, keep the local machine's current working # directory from appearing in build outputs. "-Zremap-cwd-prefix=.", - + # Full RUSTC optimizations. "-Copt-level=3", "-Ctarget-feature=+sse2", ] @@ -1322,9 +1330,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1448,16 +1457,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1675,6 +1681,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2255,12 +2264,12 @@ config("optimize") { if (chrome_pgo_phase != 2) { # Favor size over speed, /O1 must be before the common flags. # /O1 implies /Os and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] rustflags = [ "-Copt-level=3" ] } else { # PGO requires all translation units to be compiled with /O2. The actual # optimization level will be decided based on the profiling data. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2488,6 +2497,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) { diff --git a/other/SSE3/build/config/compiler/BUILD.gn b/other/SSE3/build/config/compiler/BUILD.gn index ebe0d142..a11f6265 100644 --- a/other/SSE3/build/config/compiler/BUILD.gn +++ b/other/SSE3/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -617,8 +622,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -643,9 +647,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -832,9 +834,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -882,6 +883,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -896,7 +904,7 @@ config("compiler") { # For deterministic builds, keep the local machine's current working # directory from appearing in build outputs. "-Zremap-cwd-prefix=.", - + # Full RUSTC optimizations. "-Copt-level=3", "-Ctarget-feature=+sse3", ] @@ -1322,9 +1330,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1448,16 +1457,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1675,6 +1681,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2255,12 +2264,12 @@ config("optimize") { if (chrome_pgo_phase != 2) { # Favor size over speed, /O1 must be before the common flags. # /O1 implies /Os and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] rustflags = [ "-Copt-level=3" ] } else { # PGO requires all translation units to be compiled with /O2. The actual # optimization level will be decided based on the profiling data. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2488,6 +2497,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) { diff --git a/src/build/config/compiler/BUILD.gn b/src/build/config/compiler/BUILD.gn index bfdd197c..24235ac1 100644 --- a/src/build/config/compiler/BUILD.gn +++ b/src/build/config/compiler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 The Chromium Authors and Alex313031. All rights reserved. +# Copyright 2023 The Chromium Authors and Alex313031. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -172,6 +172,11 @@ declare_args() { # For use by tools/clang/scripts/analyze_includes.py show_includes = false + # Enable Profi algorithm. Profi can infer block and edge counts. + # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers + # TODO(crbug.com/1375958i:) Possibly enable this for Android too. + use_profi = is_chromeos + # If true, linker crashes will be rerun with `--reproduce` which causes # a reproducer file to be saved. save_reproducers_on_lld_crash = false @@ -610,8 +615,7 @@ config("compiler") { cflags_cc += [ "-fno-trigraphs" ] } } else if (is_clang) { - if (is_chromeos_device || use_cxx17) { - # TODO(crbug.com/1392471): Support C++20 in CrOS toolchain. + if (use_cxx17) { cflags_cc += [ "-std=${standard_prefix}++17" ] } else { cflags_cc += [ "-std=${standard_prefix}++20" ] @@ -636,9 +640,7 @@ config("compiler") { # clause, above. cflags_c += [ "-std=c11" ] - if (is_fuchsia || use_cxx17) { - # TODO(crbug.com/fuchsia/108751): The FIDL compiler generates code that - # will not compile in C++20 mode. Switch to C++20 when this is resolved. + if (use_cxx17) { cflags_cc += [ "-std=c++17" ] } else { cflags_cc += [ "-std=c++20" ] @@ -825,9 +827,8 @@ config("compiler") { # * Windows is not supported as it doesn't use DWARF. # * Apple platforms (e.g. MacOS, iPhone, iPad) aren't supported because xcode # lldb doesn't have the needed changes yet. - # * Fuchsia isn't supported as zxdb doesn't support simple template names yet. # TODO(crbug.com/1379070): Remove if the upstream default ever changes. - if (is_clang && !is_nacl && !is_win && !is_apple && !is_fuchsia) { + if (is_clang && !is_nacl && !is_win && !is_apple) { cflags_cc += [ "-gsimple-template-names" ] } @@ -875,6 +876,13 @@ config("compiler") { # we discover a reason to turn them off. "-Coverflow-checks=on", + # By default Rust passes `-nodefaultlibs` to the linker, however this + # conflicts with our `--unwind=none` flag for Android dylibs, as the latter + # is then unused and produces a warning/error. So this removes the + # `-nodefaultlibs` from the linker invocation from Rust, which would be used + # to compile dylibs on Android, such as for constructing unit test APKs. + "-Cdefault-linker-libraries", + # Turn warnings into the "deny" lint level, which produce compiler errors. # The equivalent of -Werror for clang/gcc. "-Dwarnings", @@ -889,7 +897,7 @@ config("compiler") { # For deterministic builds, keep the local machine's current working # directory from appearing in build outputs. "-Zremap-cwd-prefix=.", - + # Full RUSTC optimizations. "-Copt-level=3", "-Ctarget-feature=+aes,+avx,-pclmul", ] @@ -1317,9 +1325,10 @@ config("compiler_codegen") { configs += [ "//build/config/nacl:compiler_codegen" ] } - if (current_cpu == "arm64" && is_android) { - # On arm64 disable outlining for Android. See crbug.com/931297 for more - # information. + if (current_cpu == "arm64" && !is_win) { + # Disable outlining everywhere on arm64 except Win. For more information see + # crbug.com/931297 for Android and crbug.com/1410297 for iOS. + # TODO(crbug.com/1411363): Enable this on Windows if possible. cflags += [ "-mno-outline" ] # This can be removed once https://bugs.llvm.org/show_bug.cgi?id=40348 @@ -1443,16 +1452,13 @@ config("clang_revision") { } config("rustc_revision") { - if (enable_rust && defined(rustc_version)) { - # Similar to the above config, this is here so that all files get - # recompiled after a rustc roll. Nothing should ever read this cfg. - # $rustc_version is a gn arg set within //build/config/rust.gni - # so that users using a custom Rust toolchain can override it. - # Its accuracy is checked in //build/rust/std:find_stdlib, which - # most of our Rust targets depend upon. + if (rustc_revision != "") { + # Similar to the above config, this is here so that all files get recompiled + # after a rustc roll. Nothing should ever read this cfg. This will not be + # set if a custom toolchain is used. rustflags = [ "--cfg", - "rustc_version=\"$rustc_version\"", + "cr_rustc_revision=\"$rustc_revision\"", ] } } @@ -1670,6 +1676,9 @@ config("default_warnings") { # TODO(crbug.com/1352183) Evaluate and possibly enable. "-Wno-bitfield-constant-conversion", + + # TODO(crbug.com/1412713) Evaluate and possibly enable. + "-Wno-deprecated-this-capture", ] } } @@ -2252,12 +2261,12 @@ config("optimize") { if (chrome_pgo_phase != 2) { # Favor size over speed, /O1 must be before the common flags. # /O1 implies /Os and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] rustflags = [ "-Copt-level=3" ] } else { # PGO requires all translation units to be compiled with /O2. The actual # optimization level will be decided based on the profiling data. - cflags = [ "/O2" ] + common_optimize_on_cflags + [ "/Oi" ] + cflags = [ "/O2", "-Xclang", "-O3", ] + common_optimize_on_cflags + [ "/Oi" ] # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage # suggests not using an explicit `-Copt-level` at all, and the default is @@ -2485,6 +2494,9 @@ config("afdo") { rebased_clang_sample_profile = rebase_path(_clang_sample_profile, root_build_dir) cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ] + if (use_profi) { + cflags += [ "-fsample-profile-use-profi" ] + } inputs = [ _clang_sample_profile ] } } else if (auto_profile_path != "" && is_a_target_toolchain) {