• Home
  • Raw
  • Download

Lines Matching +full:gcc +full:- +full:pgo

2 # Use of this source code is governed by a BSD-style license that can be
55 # clang looks for lld next to it, no need for -B.
84 # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
85 # optimization that GCC supports. It used by ChromeOS in their official
101 # We currently only have default profiles for Chromium in-tree, so we disable
122 # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
138 # The cache can lead to non-determinism: https://crbug.com/1486045
142 # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
168 # windbg and Windows Performance Analyzer with finding the PDBs in some local-
175 # Enable -H, which prints the include tree during compilation.
180 # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
184 # If true, linker crashes will be rerun with `--reproduce` which causes
241 # Turn off the --call-graph-profile-sort flag for lld by default. Enable
254 # default_include_dirs ---------------------------------------------------------
267 # the executable they are loaded into, so they are unresolved at link-time.
272 "-Wl,-z,defs",
273 "-Wl,--as-needed",
278 # compiler ---------------------------------------------------------------------
298 # System-specific flags. If your compiler flags apply to one of the
330 # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
332 # of some security-critical code: see https://crbug.com/1139129.
335 # GCC seems to have some bugs compiling constexpr code when this is defined,
336 # so only enable it if using_clang. See: https://gcc.gnu.org/PR97913
337 # TODO(mpdenton): remove is_clang once GCC bug is fixed.
339 cflags += [ "-fno-delete-null-pointer-checks" ]
342 # Don't emit the GCC version ident directives, they just end up in the
346 cflags += [ "-fno-ident" ]
353 # --------------------------------
354 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
362 # x18 by default. On other OSs adding "-ffixed-x18" might be required.
366 "-fsanitize=shadow-call-stack",
367 "-fno-stack-protector",
376 cflags += [ "-fstack-protector-strong" ]
378 cflags += [ "-fstack-protector" ]
381 # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
383 # The x86 toolchain currently has problems with stack-protector.
385 cflags += [ "-fno-stack-protector" ]
388 cflags += [ "-fstack-protector" ]
394 ldflags += [ "-fuse-ld=lld" ]
396 ldflags += [ "-B$lld_path" ]
403 ldflags += [ "-Wl,--fatal-warnings" ]
406 ldflags += [ "-Wl,-fatal_warnings" ]
413 # well-defined C/C++ and Clang can optimize such checks away in
416 "-Wno-undefined-bool-conversion",
417 "-Wno-tautological-undefined-compare",
421 # Non-Apple Posix and Fuchsia compiler flags setup.
422 # -----------------------------------
426 cflags += [ "-g" ]
430 "-fno-inline",
431 "-fno-optimize-sibling-calls",
437 # Explicitly pass --build-id to ld. Compilers used to always pass this
444 ldflags += [ "-Wl,--build-id=sha1" ]
446 ldflags += [ "-Wl,--build-id" ]
453 …# See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
463 "-fno-unwind-tables",
464 "-fno-asynchronous-unwind-tables",
466 rustflags += [ "-Cforce-unwind-tables=no" ]
469 cflags += [ "-funwind-tables" ]
470 rustflags += [ "-Cforce-unwind-tables=yes" ]
476 # ---------------------------------
487 asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
488 cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
494 rustflags += [ "-Csplit-debuginfo=unpacked" ]
498 # ---------------------------------
500 asmflags += [ "-fPIC" ]
501 cflags += [ "-fPIC" ]
502 ldflags += [ "-fPIC" ]
503 rustflags += [ "-Crelocation-model=pic" ]
506 # Use pipes for communicating between sub-processes. Faster.
508 cflags += [ "-pipe" ]
512 "-Wl,-z,noexecstack",
513 "-Wl,-z,relro",
517 ldflags += [ "-Wl,-z,now" ]
521 # Linux-specific compiler flags setup.
522 # ------------------------------------
524 ldflags += [ "-fuse-ld=gold" ]
526 # On Android, this isn't needed. gcc in the NDK knows to look next to
527 # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
530 ldflags += [ "-B$gold_path" ]
536 …# https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
539 "-Wl,--threads",
540 "-Wl,--thread-count=4",
547 # "-Wl,--detect-odr-violations",
553 ldflags += [ "-Wl,--icf=all" ]
557 cflags += [ "-pthread" ]
558 # Do not use the -pthread ldflag here since it becomes a no-op
559 # when using -nodefaultlibs, which would cause an unused argument
560 # error. "-lpthread" is added in //build/config:default_libs.
563 # Clang-specific compiler flags setup.
564 # ------------------------------------
566 cflags += [ "-fcolor-diagnostics" ]
568 # Enable -fmerge-all-constants. This used to be the default in clang
569 # for over a decade. It makes clang non-conforming, but is fairly safe
574 cflags += [ "-fmerge-all-constants" ]
578 # TODO(thakis): Make the driver pass --color-diagnostics to the linker
579 # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
584 ldflags += [ "--color-diagnostics" ]
586 ldflags += [ "-Wl,--color-diagnostics" ]
593 ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
597 cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
600 "-fcrash-diagnostics=all",
601 "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
608 "-mllvm",
609 "-instcombine-lower-dbg-declare=0",
613 ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
615 ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
625 "-mllvm",
626 "-split-threshold-for-reg-with-hint=0",
630 ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
632 ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
639 cflags += [ "/clang:-ffp-contract=off" ]
641 cflags += [ "-ffp-contract=off" ]
646 # ---------------------------
652 # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
654 # non-standard features that _GNU_SOURCE enables, so define it manually.
658 # Undefine __STRICT_ANSI__ to get non-standard features which would
660 cflags += [ "-U__STRICT_ANSI__" ]
663 # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
666 # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
667 # to -std=c*.
671 cflags_c += [ "-std=${standard_prefix}11" ]
676 cflags_cc += [ "-std=${standard_prefix}++14" ]
678 cflags_cc += [ "-fno-trigraphs" ]
682 cflags_cc += [ "-std=${standard_prefix}++17" ]
684 cflags_cc += [ "-std=${standard_prefix}++20" ]
687 # The gcc bots are currently using GCC 9, which is not new enough to
689 cflags_cc += [ "-std=${standard_prefix}++2a" ]
699 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
704 cflags_c += [ "-std=c11" ]
707 cflags_cc += [ "-std=c++17" ]
709 cflags_cc += [ "-std=c++20" ]
716 cflags_cc += [ "-Wno-trigraphs" ]
720 cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
721 ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
724 # Add flags for link-time optimization. These flags enable
725 # optimizations/transformations that require whole-program visibility at link
736 "-flto=thin",
737 "-fsplit-lto-unit",
745 cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
753 ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
755 ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
757 ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
770 "-mllvm:-import-instr-limit=$import_instr_limit",
771 "-mllvm:-disable-auto-upgrade-debug-info",
774 ldflags += [ "-flto=thin" ]
784 ldflags += [ "-Wl,--thinlto-jobs=all" ]
798 ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
801 ldflags += [ "-Wcrl,object_path_lto" ]
808 ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
815 cflags += [ "-fwhole-program-vtables" ]
818 # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
820 # or it rejects the Zsplit-lto-unit flag.
822 "-Zsplit-lto-unit",
823 "-Clinker-plugin-lto=yes",
827 rustflags += [ "-Cembed-bitcode=no" ]
831 ldflags += [ "-fwhole-program-vtables" ]
839 # -march flag passed at compile time (see llvm.org/pr36291).
841 ldflags += [ "-march=$arm_arch" ]
847 cflags += [ "-ftime-trace" ]
849 ldflags += [ "-Wl,--time-trace" ]
854 # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
863 ldflags += [ "-Wl,--no-rosegment" ]
867 # --no-undefined-version.
869 ldflags += [ "-Wl,--undefined-version" ]
873 ldflags += [ "-Wl,--strict-auto-link" ]
876 # LLD does call-graph-sorted binary layout by default when profile data is
882 ldflags += [ "/call-graph-profile-sort:no" ]
884 ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
890 # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output.
893 "/clang:-H",
894 "/clang:-fshow-skipped-includes",
898 "-H",
899 "-fshow-skipped-includes",
909 cflags += [ "-fcomplete-member-pointers" ]
914 cflags_cc += [ "-gsimple-template-names" ]
917 # MLGO specific flags. These flags enable an ML-based inliner trained on
924 # non-Android targets.
931 ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
937 "clang_embed_bitcode is only supported in non-ThinLTO builds")
939 "-Xclang",
940 "-fembed-bitcode=all",
948 "-Wl,--save-temps=import",
949 "-Wl,--thinlto-emit-index-files",
972 "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
973 "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
974 "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
975 "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
976 "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
977 "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
978 "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
979 "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
980 "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
981 "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
982 "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
983 …"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9noth…
984 "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
985 "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
986 …"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9noth…
987 "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
988 …"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothro…
989 "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
990 …"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothro…
995 # ---------------------------
999 # behavior is defined). Because containers are bounds-checked
1006 "-Coverflow-checks=on",
1008 # By default Rust passes `-nodefaultlibs` to the linker, however this
1009 # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
1011 # `-nodefaultlibs` from the linker invocation from Rust, which would be used
1013 "-Cdefault-linker-libraries",
1016 "-Zdep-info-omit-d-target",
1020 "-Zmacro-backtrace",
1024 "-Zremap-cwd-prefix=.",
1029 # be platform-gated since rustc will unconditionally output ANSI escape
1031 rustflags += [ "--color=always" ]
1034 rustflags += [ "--target=$rust_abi_target" ]
1038 rustflags += [ "-Cembed-bitcode=no" ]
1041 rustflags += [ "-Ccodegen-units=1" ]
1049 "-Cpanic=abort",
1050 "-Zpanic_abort_tests",
1057 # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
1084 ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
1091 rustflags = [ "-Clinker-plugin-lto=yes" ]
1094 rustflags = [ "-Cembed-bitcode=no" ]
1102 # configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
1118 ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
1125 rustflags = [ "-Clinker-plugin-lto=yes" ]
1128 rustflags = [ "-Cembed-bitcode=no" ]
1153 "-m64",
1154 "-msse3",
1161 "-mssse3",
1162 "-msse4",
1163 "-msse4.1",
1164 "-msse4.2",
1167 ldflags += [ "-m64" ]
1169 cflags += [ "-m32" ]
1170 ldflags += [ "-m32" ]
1173 "-mfpmath=sse",
1174 "-msse3",
1180 cflags += [ "--target=arm-linux-gnueabihf" ]
1181 ldflags += [ "--target=arm-linux-gnueabihf" ]
1185 "-march=$arm_arch",
1186 "-mfloat-abi=$arm_float_abi",
1190 cflags += [ "-mtune=$arm_tune" ]
1195 cflags += [ "--target=aarch64-linux-gnu" ]
1196 ldflags += [ "--target=aarch64-linux-gnu" ]
1199 ldflags += [ "-Wl,--hash-style=sysv" ]
1203 cflags += [ "--target=mipsel-linux-android" ]
1204 ldflags += [ "--target=mipsel-linux-android" ]
1206 cflags += [ "--target=mipsel-linux-gnu" ]
1207 ldflags += [ "--target=mipsel-linux-gnu" ]
1210 cflags += [ "-EL" ]
1211 ldflags += [ "-EL" ]
1216 cflags += [ "-mno-odd-spreg" ]
1217 ldflags += [ "-mips32r6" ]
1220 "-march=mipsel",
1221 "-mcpu=mips32r6",
1225 "-mips32r6",
1226 "-Wa,-mips32r6",
1229 ldflags += [ "-Wl,-melf32ltsmip" ]
1234 "-mmsa",
1235 "-mfp64",
1239 ldflags += [ "-mips32r2" ]
1242 "-march=mipsel",
1243 "-mcpu=mips32r2",
1247 "-mips32r2",
1248 "-Wa,-mips32r2",
1251 cflags += [ "-m$mips_fpu_mode" ]
1255 ldflags += [ "-mips32" ]
1258 "-march=mipsel",
1259 "-mcpu=mips32",
1263 "-mips32",
1264 "-Wa,-mips32",
1270 "-march=loongson3a",
1271 "-mno-branch-likely",
1272 "-Wa,-march=loongson3a",
1277 cflags += [ "-mdsp" ]
1279 cflags += [ "-mdspr2" ]
1282 cflags += [ "-m${mips_float_abi}-float" ]
1284 ldflags += [ "-Wl,--hash-style=sysv" ]
1287 cflags += [ "--target=mips-linux-gnu" ]
1288 ldflags += [ "--target=mips-linux-gnu" ]
1290 cflags += [ "-EB" ]
1291 ldflags += [ "-EB" ]
1297 "-mips32r6",
1298 "-Wa,-mips32r6",
1302 "-mmsa",
1303 "-mfp64",
1308 "-mips32r2",
1309 "-Wa,-mips32r2",
1312 cflags += [ "-m$mips_fpu_mode" ]
1316 "-mips32",
1317 "-Wa,-mips32",
1322 cflags += [ "-mdsp" ]
1324 cflags += [ "-mdspr2" ]
1327 cflags += [ "-m${mips_float_abi}-float" ]
1329 cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
1330 ldflags += [ "-Wl,--hash-style=sysv" ]
1334 cflags += [ "--target=mips64el-linux-android" ]
1335 ldflags += [ "--target=mips64el-linux-android" ]
1337 cflags += [ "--target=mips64el-linux-gnuabi64" ]
1338 ldflags += [ "--target=mips64el-linux-gnuabi64" ]
1342 "-EL",
1343 "-mabi=64",
1346 "-EL",
1347 "-mabi=64",
1355 "-march=mips64el",
1356 "-mcpu=mips64r6",
1360 "-mips64r6",
1361 "-Wa,-mips64r6",
1363 ldflags += [ "-mips64r6" ]
1367 "-mmsa",
1368 "-mfp64",
1372 ldflags += [ "-mips64r2" ]
1375 "-march=mips64el",
1376 "-mcpu=mips64r2",
1380 "-mips64r2",
1381 "-Wa,-mips64r2",
1387 "-march=loongson3a",
1388 "-mno-branch-likely",
1389 "-Wa,-march=loongson3a",
1393 ldflags += [ "-Wl,--hash-style=sysv" ]
1396 cflags += [ "--target=mips64-linux-gnuabi64" ]
1397 ldflags += [ "--target=mips64-linux-gnuabi64" ]
1400 "-EB",
1401 "-mabi=64",
1404 "-EB",
1405 "-mabi=64",
1412 "-mips64r6",
1413 "-Wa,-mips64r6",
1415 ldflags += [ "-mips64r6" ]
1419 "-mmsa",
1420 "-mfp64",
1425 "-mips64r2",
1426 "-Wa,-mips64r2",
1428 ldflags += [ "-mips64r2" ]
1432 cflags += [ "-maix64" ]
1433 ldflags += [ "-maix64" ]
1435 cflags += [ "-m64" ]
1436 ldflags += [ "-m64" ]
1440 cflags += [ "--target=riscv64-linux-gnu" ]
1441 ldflags += [ "--target=riscv64-linux-gnu" ]
1443 cflags += [ "-mabi=lp64d" ]
1446 cflags += [ "--target=loongarch64-linux-gnu" ]
1447 ldflags += [ "--target=loongarch64-linux-gnu" ]
1450 "-mabi=lp64d",
1451 "-mcmodel=medium",
1454 cflags += [ "-m64" ]
1455 ldflags += [ "-m64" ]
1478 cflags += [ "-mno-outline" ]
1481 # has been resolved, and -mno-outline is obeyed by the linker during
1483 ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
1513 "-Wno-builtin-macro-redefined",
1514 "-D__DATE__=",
1515 "-D__TIME__=",
1516 "-D__TIMESTAMP__=",
1529 # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
1531 "-Xclang",
1532 "-fdebug-compilation-dir",
1533 "-Xclang",
1537 # -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
1538 # and -fcoverage-compilation-dir=.
1539 cflags += [ "-ffile-compilation-dir=." ]
1540 swiftflags += [ "-file-compilation-dir=." ]
1543 # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
1544 asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
1550 # if the pdb contains source-level debug information and if linker
1565 cflags += [ "-no-canonical-prefixes" ]
1568 # with a relative path and pass relative paths to built-in
1574 ldflags += [ "-no-canonical-prefixes" ]
1582 "--print-revision",
1583 "--verify-version=$clang_version",
1586 update_args += [ "--llvm-force-head-revision" ]
1606 "--cfg",
1614 cflags = [ "-mfpu=$arm_fpu" ]
1616 cflags += [ "-marm" ]
1625 cflags = [ "-mthumb" ]
1632 # is used to pass -mthumb, and therefor change the default.
1633 cflags = [ "-marm" ]
1637 # runtime_library -------------------------------------------------------------
1652 # libandroid_support in the -isystem include order. Otherwise, there will be
1663 # compiler-rt library.
1676 ldflags = [ "--unwindlib=none" ]
1680 # System-specific flags. If your compiler flags apply to one of the
1703 # treat_warnings_as_errors ----------------------------------------------------
1707 # is broken out separately so nocompile tests can force-enable this setting
1713 cflags = [ "-Werror" ]
1718 ldflags = [ "-Werror" ]
1722 # errors. The equivalent of -Werror for clang/gcc.
1725 # are suppressed in third-party crates.
1726 rustflags = [ "-Dwarnings" ]
1729 # default_warnings ------------------------------------------------------------
1733 # flags are guaranteed to appear on the compile command line after -Wall.
1753 # gethostbyname. Fires mostly in non-Chromium code. We probably
1759 # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
1765 # When compiling Objective-C, warns if a method is used whose
1767 cflags += [ "-Wunguarded-availability" ]
1771 # When compiling Objective-C, warns if a selector named via @selector has
1773 cflags += [ "-Wundeclared-selector" ]
1779 cflags += [ "-Wno-psabi" ]
1784 # See comment for -Wno-c++11-narrowing.
1785 "-Wno-narrowing",
1788 # -Wno-class-memaccess warns about hash table and vector in blink.
1791 cflags_cc += [ "-Wno-class-memaccess" ]
1794 # -Wunused-local-typedefs is broken in gcc,
1795 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63872
1796 cflags += [ "-Wno-unused-local-typedefs" ]
1799 # in -Wall but gcc does, and it gives false positives.
1800 cflags += [ "-Wno-maybe-uninitialized" ]
1801 cflags += [ "-Wno-deprecated-declarations" ]
1803 # -Wcomment gives too many false positives in the case a
1806 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61638
1807 cflags += [ "-Wno-comments" ]
1809 # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
1811 cflags += [ "-Wno-packed-not-aligned" ]
1815 # Common Clang and GCC warning setup.
1819 "-Wno-missing-field-initializers", # "struct foo f = {0};"
1820 "-Wno-unused-parameter", # Unused function parameters.
1828 "-Wno-psabi",
1835 "-Wloop-analysis",
1837 # TODO(thakis): This used to be implied by -Wno-unused-function,
1840 "-Wno-unneeded-internal-declaration",
1847 cflags += [ "-Wno-nonportable-include-path" ]
1853 "-Wno-missing-field-initializers",
1858 "-Wenum-compare-conditional",
1862 "-Wno-ignored-pragma-optimize",
1868 "-Wno-deprecated-builtins",
1871 "-Wno-bitfield-constant-conversion",
1874 "-Wno-deprecated-this-capture",
1876 # TODO(https://crbug.com/1491833): Fix and re-enable.
1877 "-Wno-invalid-offsetof",
1880 "-Wno-vla-extension",
1882 # TODO(https://crbug.com/1490607): Fix and re-enable.
1883 "-Wno-thread-safety-reference-return",
1893 "-Wno-error=unknown-warning-option",
1894 "-Wno-error=unused-command-line-argument",
1903 # https://github.com/rust-lang/rust/issues/71668
1904 rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
1907 # prevent_unsafe_narrowing ----------------------------------------------------
1910 # likely to cause out-of-bound read/writes or Undefined Behaviour. In
1913 # memory-safety bugs and thus security exploits.
1925 # See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
1933 "-Wshorten-64-to-32",
1934 "-Wimplicit-int-conversion",
1935 "-Wsign-compare",
1936 "-Wsign-conversion",
1940 # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
1941 # fixing types to be sign-correct.
1942 "-Wtautological-unsigned-zero-compare",
1948 # chromium_code ---------------------------------------------------------------
1962 cflags = [ "-Wall" ]
1965 cflags += [ "-Wextra" ]
1979 # Non-chromium code is not guaranteed to compile cleanly with
1984 # ChromeOS's toolchain supports a high-quality _FORTIFY_SOURCE=3
1994 cflags_objc = [ "-Wimplicit-retain-self" ]
1995 cflags_objcc = [ "-Wimplicit-retain-self" ]
1999 cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
2000 cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
2008 "-Wimplicit-fallthrough",
2011 "-Wextra-semi",
2015 "-Wunreachable-code-aggressive",
2023 "-Wthread-safety",
2054 cflags += [ "-Wall" ]
2060 # Lots of third-party libraries have unused variables. Instead of
2062 "-Wno-unused-variable",
2065 # third-party libraries.
2066 "-Wno-c++11-narrowing",
2070 # Disabled for similar reasons as -Wunused-variable.
2071 "-Wno-unused-but-set-variable",
2074 "-Wno-misleading-indentation",
2080 # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
2081 rustflags = [ "--cap-lints=allow" ]
2085 # GCC may emit unsuppressible warnings so only apply this config when
2092 # noshadowing -----------------------------------------------------------------
2094 # Allows turning -Wshadow on.
2100 cflags = [ "-Wshadow" ]
2104 # rtti ------------------------------------------------------------------------
2106 # Allows turning Run-Time Type Identification on or off.
2112 cflags_cc = [ "-frtti" ]
2120 cflags_cc = [ "/GR-" ]
2122 cflags_cc = [ "-fno-rtti" ]
2128 # export_dynamic ---------------------------------------------------------------
2132 # other memory-related symbols) to libraries. Otherwise, they might
2134 # to heap-allocated memory are passed over shared library boundaries.
2138 ldflags = [ "-rdynamic" ]
2142 # thin_archive -----------------------------------------------------------------
2162 arflags = [ "-T" ]
2168 # exceptions -------------------------------------------------------------------
2181 cflags_cc = [ "-fexceptions" ]
2198 cflags_cc = [ "-fno-exceptions" ]
2203 # Warnings ---------------------------------------------------------------------
2207 # See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
2210 cflags = [ "-Wglobal-constructors" ]
2214 # This will generate warnings when using Clang if code generates exit-time
2219 cflags = [ "-Wexit-time-destructors" ]
2225 # gcc 4.9 and earlier had no way of suppressing this warning without
2227 # the gcc 4.9 toolchains.
2231 cflags += [ "-Wno-incompatible-pointer-types" ]
2233 cflags += [ "-w" ]
2235 cflags += [ "-w" ]
2239 # Optimization -----------------------------------------------------------------
2245 # You can override the optimization level on a per-target basis by removing the
2248 # configs -= [ "//build/config/compiler:default_optimization" ]
2256 "/Oy-", # Disable omitting frame pointers, must be after /O2.
2262 # to put bit-identical constants at the same address even if
2271 # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
2279 # TODO(thakis): Add LTO/PGO clang flags eventually, https://crbug.com/598772
2284 common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
2291 # TODO(jdduke) Re-enable on mips after resolving linking
2296 "-Wl,--warn-shared-textrel",
2302 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
2306 "-Wl,-no_data_in_code_info",
2307 "-Wl,-no_function_starts",
2311 # Non-Mac Posix flags.
2316 # can be removed at link time with --gc-sections.
2317 "-fdata-sections",
2318 "-ffunction-sections",
2323 common_optimize_on_cflags += [ "-fno-unique-section-names" ]
2329 # -O2 enables string tail merge optimization in gold and lld.
2330 "-Wl,-O2",
2331 "-Wl,--gc-sections",
2336 # especially since glibc does not set it. Thus, use -fno-math-errno
2338 # Note that this is different from -ffast-math (even though -ffast-math
2339 # implies -fno-math-errno), which also allows a number of unsafe
2341 common_optimize_on_cflags += [ "-fno-math-errno" ]
2347 cflags = [ "-fno-omit-frame-pointer" ]
2353 cflags += [ "-momit-leaf-frame-pointer" ]
2356 cflags = [ "-fomit-frame-pointer" ]
2359 # On Windows, the flag to enable framepointers "/Oy-" must always come after
2362 # applied is well-defined by the GN spec, and there is no way to ensure that
2365 # config into the "optimize" config. We always apply the "/Oy-" config in the
2377 rustflags = [ "-Copt-level=s" ]
2379 # PGO requires all translation units to be compiled with /O2. The actual
2383 # https://doc.rust-lang.org/rustc/profile-guided-optimization.html#usage
2384 # suggests not using an explicit `-Copt-level` at all, and the default is
2391 cflags = [ "-Oz" ] + common_optimize_on_cflags
2395 "-mllvm",
2396 "-enable-ml-inliner=release",
2400 cflags = [ "-Os" ] + common_optimize_on_cflags
2403 # Like with `-Oz` on Clang, `-Copt-level=z` will also turn off loop
2405 rustflags = [ "-Copt-level=z" ]
2408 # uses clang, and -Os in clang is more of a size-conscious -O2 than "size at
2409 # any cost" (AKA -Oz). It'd be nice to:
2410 # - Make `optimize_for_size` apply to all platforms where we're optimizing
2412 # - Investigate -Oz here, maybe just for ARM?
2413 cflags = [ "-Os" ] + common_optimize_on_cflags
2415 # Similar to clang, we optimize with `-Copt-level=s` to keep loop
2417 rustflags = [ "-Copt-level=s" ]
2419 cflags = [ "-O2" ] + common_optimize_on_cflags
2421 # The `-O3` for clang turns on extra optimizations compared to the standard
2422 # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
2424 rustflags = [ "-Copt-level=3" ]
2441 cflags += [ "/Oy-" ]
2447 cflags = [ "-Oz" ] + common_optimize_on_cflags
2449 cflags = [ "-Os" ] + common_optimize_on_cflags
2455 ldflags = [ "-Wl,--gc-sections" ]
2460 cflags = [ "-Og" ]
2462 cflags = [ "-O0" ]
2468 # optimization and link-time code generation which is very expensive and should
2475 # configs -= [ "//build/config/compiler:default_optimization" ]
2488 cflags = [ "-O1" ] + common_optimize_on_cflags
2490 cflags = [ "-O2" ] + common_optimize_on_cflags
2492 rustflags = [ "-Copt-level=3" ]
2496 # This config can be used to override the default settings for per-component
2497 # and whole-program optimization, optimizing the particular target for speed
2499 # except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
2501 # TODO(crbug.com/621335) - rework how all of these configs are related
2508 # configs -= [ "//build/config/compiler:default_optimization" ]
2521 cflags = [ "-O1" ] + common_optimize_on_cflags
2523 cflags = [ "-O3" ] + common_optimize_on_cflags
2525 rustflags = [ "-Copt-level=3" ]
2530 cflags = [ "-O1" ] + common_optimize_on_cflags
2531 rustflags = [ "-Copt-level=1" ]
2549 # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
2575 chromeos_afdo_platform == "arm-exp",
2576 "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
2589 cflags = [ "-fprofile-sample-accurate" ]
2593 # GCC and clang support a form of profile-guided optimization called AFDO.
2595 # config to allow AFDO to be disabled per-target.
2601 cflags += [ "-gline-tables-only" ]
2603 cflags += [ "-fdebug-info-for-profiling" ]
2607 assert(chrome_pgo_phase == 0, "AFDO can't be used in PGO builds")
2610 cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
2612 cflags += [ "-fsample-profile-use-profi" ]
2615 # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
2616 # These seem to be false positives - the complaints are about functions
2621 cflags += [ "-Wno-backend-plugin" ]
2625 cflags = [ "-fauto-profile=${auto_profile_path}" ]
2630 # Symbols ----------------------------------------------------------------------
2635 # You can override the symbol level on a per-target basis by removing the
2638 # configs -= [ "//build/config/compiler:default_symbols" ]
2642 # include as sub-config.
2653 # so there's minimal downside to always using this. However, post-mortem
2671 # prevent some types of non-determinism.
2672 "-gno-codeview-command-line",
2679 cflags += [ "-gcodeview-ghash" ]
2690 # If generating dSYMs, specify -fno-standalone-debug. This was
2695 cflags += [ "-fno-standalone-debug" ]
2698 # On aix -gdwarf causes linker failures due to thread_local variables.
2701 cflags += [ "-gdwarf-5" ]
2702 rustflags += [ "-Zdwarf-version=5" ]
2709 cflags += [ "-gdwarf-4" ]
2714 rustflags += [ "-Zdwarf-version=4" ]
2718 # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
2719 # elsewhere in this file), so they can't have build-dir-independent output.
2720 # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
2722 # build-directory-independent output.
2723 # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
2726 cflags += [ "-g2" ]
2730 # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
2736 cflags += [ "-gdwarf-aranges" ]
2740 swiftflags = [ "-g" ]
2744 cflags += [ "-gsplit-dwarf" ]
2750 # thinlto requires -gsplit-dwarf in ldflags.
2752 ldflags += [ "-gsplit-dwarf" ]
2755 # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
2763 # Disable on non-fission 32-bit Android because it pushes
2769 # This flag enables the GNU-format pubnames and pubtypes sections,
2771 # TODO(pcc): Try to make lld understand non-GNU-format pubnames
2773 cflags += [ "-ggnu-pubnames" ]
2775 ldflags += [ "-Wl,--gdb-index" ]
2781 # Compress debug on 32-bit ARM to stay under 4GB for ChromeOS
2793 "-Xclang",
2794 "-debug-info-kind=limited",
2800 "-Xclang",
2801 "-fuse-ctor-homing",
2805 rustflags += [ "-g" ]
2820 # prevent some types of non-determinism.
2821 "-gno-codeview-command-line",
2825 cflags += [ "-gcodeview-ghash" ]
2836 # -gline-tables-only is the same as -g1, but clang-cl only exposes the
2838 cflags += [ "-gline-tables-only" ]
2846 cflags += [ "-gdwarf-4" ]
2847 rustflags += [ "-Zdwarf-version=4" ]
2849 # On aix -gdwarf causes linker failures due to thread_local variables.
2852 cflags += [ "-gdwarf-4" ]
2853 rustflags += [ "-Zdwarf-version=4" ]
2857 cflags += [ "-gdwarf-5" ]
2858 rustflags += [ "-Zdwarf-version=5" ]
2861 # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
2862 # elsewhere in this file), so they can't have build-dir-independent output.
2863 # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
2865 # build-directory-independent output.
2866 # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
2869 cflags += [ "-g1" ]
2873 # See comment for -gdwarf-aranges in config("symbols").
2874 cflags += [ "-gdwarf-aranges" ]
2879 # Android defaults to symbol_level=1 builds, but clang, unlike gcc,
2880 # doesn't emit DW_AT_linkage_name in -g1 builds.
2881 # -fdebug-info-for-profiling enables that (and a bunch of other things we
2883 # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
2884 # failing that consider doing this on non-Android too.
2885 cflags += [ "-fdebug-info-for-profiling" ]
2890 rustflags += [ "-Cdebuginfo=1" ]
2903 cflags = [ "-g0" ]
2930 ldflags += [ "-Wl,--strip-debug" ]
2937 # -fobjc-arc enables ARC overall.
2939 # ARC does not add exception handlers to pure Objective-C code, but does add
2940 # them to Objective-C++ code with the rationale that C++ pervasively adds them
2942 # C++ and exceptions in Objective-C code are intended to be fatal, so
2943 # -fno-objc-arc-exceptions is specified to disable these unwanted exception
2947 "-fobjc-arc",
2948 "-fno-objc-arc-exceptions",
2966 "-Wl,--symbol-ordering-file",
2967 "-Wl,$_rebased_orderfile",
2968 "-Wl,--no-warn-symbol-ordering",
2980 cflags += [ "-ftrivial-auto-var-init=zero" ]
2982 cflags += [ "-ftrivial-auto-var-init=pattern" ]