Lines Matching +full:linux +full:- +full:loong64
2 # Use of this source code is governed by a BSD-style license that can be
54 # clang looks for lld next to it, no need for -B.
79 # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
96 # We currently only have default profiles for Chromium in-tree, so we disable
117 # http://blog.llvm.org/2018/01/improving-link-time-on-windows-with.html
133 # The cache can lead to non-determinism: https://crbug.com/1486045
137 # uninitialized floating-point types (and 32-bit pointers) with 0xFF and the
165 # windbg and Windows Performance Analyzer with finding the PDBs in some local-
172 # Enable -H, which prints the include tree during compilation.
177 # https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers
181 # If true, linker crashes will be rerun with `--reproduce` which causes
228 # Turn off the --call-graph-profile-sort flag for lld by default. Enable
236 assert(!(llvm_force_head_revision && use_remoteexec && host_os != "linux"),
237 "rbe with locally built clang only works on linux")
239 # default_include_dirs ---------------------------------------------------------
252 # the executable they are loaded into, so they are unresolved at link-time.
257 "-Wl,-z,defs",
258 "-Wl,--as-needed",
263 # compiler ---------------------------------------------------------------------
283 # System-specific flags. If your compiler flags apply to one of the
291 configs += [ "//build/config/linux:compiler" ]
315 # Here we enable -fno-delete-null-pointer-checks, which makes various nullptr
317 # of some security-critical code: see https://crbug.com/1139129.
325 cflags += [ "-fno-delete-null-pointer-checks" ]
332 cflags += [ "-fno-ident" ]
339 # --------------------------------
340 cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
348 # x18 by default. On other OSs adding "-ffixed-x18" might be required.
352 "-fsanitize=shadow-call-stack",
353 "-fno-stack-protector",
362 cflags += [ "-fstack-protector-strong" ]
364 cflags += [ "-fstack-protector" ]
369 cflags += [ "-fstack-protector" ]
375 ldflags += [ "-fuse-ld=lld" ]
377 ldflags += [ "-B$lld_path" ]
384 ldflags += [ "-Wl,--fatal-warnings" ]
387 ldflags += [ "-Wl,-fatal_warnings" ]
394 # well-defined C/C++ and Clang can optimize such checks away in
397 "-Wno-undefined-bool-conversion",
398 "-Wno-tautological-undefined-compare",
402 # Non-Apple Posix and Fuchsia compiler flags setup.
403 # -----------------------------------
407 cflags += [ "-g" ]
411 "-fno-inline",
412 "-fno-optimize-sibling-calls",
418 # Explicitly pass --build-id to ld. Compilers used to always pass this
425 ldflags += [ "-Wl,--build-id=sha1" ]
427 ldflags += [ "-Wl,--build-id" ]
434 …# See https://android-developers.googleblog.com/2017/09/introducing-android-native-development.html
444 "-fno-unwind-tables",
445 "-fno-asynchronous-unwind-tables",
447 rustflags += [ "-Cforce-unwind-tables=no" ]
450 cflags += [ "-funwind-tables" ]
451 rustflags += [ "-Cforce-unwind-tables=yes" ]
457 # ---------------------------------
468 asmflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
469 cflags += [ "-femit-dwarf-unwind=no-compact-unwind" ]
475 rustflags += [ "-Csplit-debuginfo=unpacked" ]
478 # Linux/Android/Fuchsia common flags setup.
479 # ---------------------------------
481 asmflags += [ "-fPIC" ]
482 cflags += [ "-fPIC" ]
483 ldflags += [ "-fPIC" ]
484 rustflags += [ "-Crelocation-model=pic" ]
487 # Use pipes for communicating between sub-processes. Faster.
489 cflags += [ "-pipe" ]
493 "-Wl,-z,noexecstack",
494 "-Wl,-z,relro",
498 ldflags += [ "-Wl,-z,now" ]
502 # Linux-specific compiler flags setup.
503 # ------------------------------------
505 ldflags += [ "-Wl,--icf=all" ]
509 cflags += [ "-pthread" ]
510 # Do not use the -pthread ldflag here since it becomes a no-op
511 # when using -nodefaultlibs, which would cause an unused argument
512 # error. "-lpthread" is added in //build/config:default_libs.
515 # Clang-specific compiler flags setup.
516 # ------------------------------------
518 cflags += [ "-fcolor-diagnostics" ]
520 # Enable -fmerge-all-constants. This used to be the default in clang
521 # for over a decade. It makes clang non-conforming, but is fairly safe
526 cflags += [ "-fmerge-all-constants" ]
530 cflags += [ "/Zc:sizedDealloc-" ]
532 cflags += [ "-fno-sized-deallocation" ]
537 # TODO(thakis): Make the driver pass --color-diagnostics to the linker
538 # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics
543 ldflags += [ "--color-diagnostics" ]
545 ldflags += [ "-Wl,--color-diagnostics" ]
549 # Enable text section splitting only on linux when using lld for now. Other
552 ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
556 cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
559 "-fcrash-diagnostics=all",
560 "-fcrash-diagnostics-dir=" + clang_diagnostic_dir,
567 "-mllvm",
568 "-instcombine-lower-dbg-declare=0",
572 ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ]
574 ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ]
584 "-mllvm",
585 "-split-threshold-for-reg-with-hint=0",
589 ldflags += [ "-mllvm:-split-threshold-for-reg-with-hint=0" ]
591 ldflags += [ "-Wl,-mllvm,-split-threshold-for-reg-with-hint=0" ]
598 cflags += [ "/clang:-ffp-contract=off" ]
600 cflags += [ "-ffp-contract=off" ]
605 # ---------------------------
611 # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be
613 # non-standard features that _GNU_SOURCE enables, so define it manually.
617 # Undefine __STRICT_ANSI__ to get non-standard features which would
619 cflags += [ "-U__STRICT_ANSI__" ]
622 # Gcc does not support ##__VA_ARGS__ when in standards-conforming mode,
625 # standard-compliant __VA_OPT__ added by C++20, and switch the gcc build
626 # to -std=c*.
630 cflags_c += [ "-std=${standard_prefix}11" ]
635 cflags_cc += [ "-std=${standard_prefix}++14" ]
637 cflags_cc += [ "-fno-trigraphs" ]
641 cflags_cc += [ "-std=${standard_prefix}++17" ]
643 cflags_cc += [ "-std=${standard_prefix}++20" ]
648 cflags_cc += [ "-std=${standard_prefix}++2a" ]
659 # on MSVC. clang-cl defines it by default and doesn't need this flag.
660 # See: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus
664 # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either
669 cflags_c += [ "-std=c11" ]
672 cflags_cc += [ "-std=c++17" ]
674 cflags_cc += [ "-std=c++20" ]
681 cflags_cc += [ "-Wno-trigraphs" ]
685 cflags_cc += [ "-fexperimental-relative-c++-abi-vtables" ]
686 ldflags += [ "-fexperimental-relative-c++-abi-vtables" ]
689 # Add flags for link-time optimization. These flags enable
690 # optimizations/transformations that require whole-program visibility at link
698 # High-end Android: While Full LTO provides a small performance improvement
700 # build time. Thin LTO appears to provide the best build time-optimization
702 # - Increases build time by ~1:30 hours, to ~2:40 hours (from ~1:10 hours
704 # - Increases Speedometer 2.1 score by 1.1% [0].
705 # - Increases Speedometer 3.0 score by 1.2% [1].
708 # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/15efb0313e0000
709 # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/157f0b42be0000
714 "-flto=thin",
715 "-fsplit-lto-unit",
723 cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
731 ldflags += [ "-Wl,-cache_path_lto,$cache_dir" ]
733 ldflags += [ "-Wl,--thinlto-cache-dir=$cache_dir" ]
735 ldflags += [ "-Wl,--thinlto-cache-policy=$cache_policy" ]
744 # For high-end Android, 30 seems to be the right trade-off between performance
747 # Speedometer 3.0 score remains roughly the same (-0.1%) [1]. The binary size
750 # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/16984a18be0000
751 # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/11984a18be0000
752 # [2]: https://ci.chromium.org/ui/p/chromium/builders/try/android-binary-size/1848442
758 "-mllvm:-import-instr-limit=$import_instr_limit",
759 "-mllvm:-disable-auto-upgrade-debug-info",
762 ldflags += [ "-flto=thin" ]
772 ldflags += [ "-Wl,--thinlto-jobs=all" ]
788 ldflags += [ "-Wl,-mllvm,-import-instr-limit=$import_instr_limit" ]
791 ldflags += [ "-Wcrl,object_path_lto" ]
796 ldflags += [ "-Wl,-mllvm,-disable-auto-upgrade-debug-info" ]
803 "-mllvm",
804 "-inlinehint-threshold=360",
807 ldflags += [ "-mllvm:-inlinehint-threshold=360" ]
809 ldflags += [ "-Wl,-mllvm,-inlinehint-threshold=360" ]
816 cflags += [ "-fwhole-program-vtables" ]
819 # whole-program-vtables implies -fsplit-lto-unit, and Rust needs to match
821 # or it rejects the Zsplit-lto-unit flag.
823 "-Zsplit-lto-unit",
824 "-Clinker-plugin-lto=yes",
828 rustflags += [ "-Cembed-bitcode=no" ]
832 ldflags += [ "-fwhole-program-vtables" ]
840 # -march flag passed at compile time (see llvm.org/pr36291).
842 ldflags += [ "-march=$arm_arch" ]
848 cflags += [ "-ftime-trace" ]
850 ldflags += [ "-Wl,--time-trace" ]
855 # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/
864 ldflags += [ "-Wl,--no-rosegment" ]
868 # --no-undefined-version.
870 ldflags += [ "-Wl,--undefined-version" ]
874 ldflags += [ "-Wl,--strict-auto-link" ]
877 # LLD does call-graph-sorted binary layout by default when profile data is
883 ldflags += [ "/call-graph-profile-sort:no" ]
885 ldflags += [ "-Wl,--no-call-graph-profile-sort" ]
892 "/clang:-H",
893 "/clang:-fshow-skipped-includes",
897 "-H",
898 "-fshow-skipped-includes",
908 cflags += [ "-fcomplete-member-pointers" ]
913 cflags_cc += [ "-gsimple-template-names" ]
916 # MLGO specific flags. These flags enable an ML-based inliner trained on
923 # non-Android targets.
924 # MLGO is only officially supported on linux.
927 is_android && host_os == "linux",
928 "MLGO is currently only supported for targeting Android on a linux host")
930 ldflags += [ "-Wl,-mllvm,-enable-ml-inliner=release" ]
936 "clang_embed_bitcode is only supported in non-ThinLTO builds")
938 "-Xclang",
939 "-fembed-bitcode=all",
947 "-Wl,--save-temps=import",
948 "-Wl,--thinlto-emit-index-files",
971 "-Wl,--export-dynamic-symbol=_ZdaPv,-u,_ZdaPv",
972 "-Wl,--export-dynamic-symbol=_ZdaPvRKSt9nothrow_t,-u,_ZdaPvRKSt9nothrow_t",
973 "-Wl,--export-dynamic-symbol=_ZdlPv,-u,_ZdlPv",
974 "-Wl,--export-dynamic-symbol=_ZdlPvm,-u,_ZdlPvm",
975 "-Wl,--export-dynamic-symbol=_ZdlPvRKSt9nothrow_t,-u,_ZdlPvRKSt9nothrow_t",
976 "-Wl,--export-dynamic-symbol=_Znam,-u,_Znam",
977 "-Wl,--export-dynamic-symbol=_ZnamRKSt9nothrow_t,-u,_ZnamRKSt9nothrow_t",
978 "-Wl,--export-dynamic-symbol=_Znwm,-u,_Znwm",
979 "-Wl,--export-dynamic-symbol=_ZnwmRKSt9nothrow_t,-u,_ZnwmRKSt9nothrow_t",
980 "-Wl,--export-dynamic-symbol=_ZdaPvmSt11align_val_t,-u,_ZdaPvmSt11align_val_t",
981 "-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_t,-u,_ZdaPvSt11align_val_t",
982 …"-Wl,--export-dynamic-symbol=_ZdaPvSt11align_val_tRKSt9nothrow_t,-u,_ZdaPvSt11align_val_tRKSt9noth…
983 "-Wl,--export-dynamic-symbol=_ZdlPvmSt11align_val_t,-u,_ZdlPvmSt11align_val_t",
984 "-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_t,-u,_ZdlPvSt11align_val_t",
985 …"-Wl,--export-dynamic-symbol=_ZdlPvSt11align_val_tRKSt9nothrow_t,-u,_ZdlPvSt11align_val_tRKSt9noth…
986 "-Wl,--export-dynamic-symbol=_ZnamSt11align_val_t,-u,_ZnamSt11align_val_t",
987 …"-Wl,--export-dynamic-symbol=_ZnamSt11align_val_tRKSt9nothrow_t,-u,_ZnamSt11align_val_tRKSt9nothro…
988 "-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_t,-u,_ZnwmSt11align_val_t",
989 …"-Wl,--export-dynamic-symbol=_ZnwmSt11align_val_tRKSt9nothrow_t,-u,_ZnwmSt11align_val_tRKSt9nothro…
994 # ---------------------------
998 # behavior is defined). Because containers are bounds-checked
1005 "-Coverflow-checks=on",
1007 # By default Rust passes `-nodefaultlibs` to the linker, however this
1008 # conflicts with our `--unwind=none` flag for Android dylibs, as the latter
1010 # `-nodefaultlibs` from the linker invocation from Rust, which would be used
1012 "-Cdefault-linker-libraries",
1015 "-Zdep-info-omit-d-target",
1019 "-Zmacro-backtrace",
1023 "-Zremap-cwd-prefix=.",
1028 # be platform-gated since rustc will unconditionally output ANSI escape
1030 rustflags += [ "--color=always" ]
1033 rustflags += [ "--target=$rust_abi_target" ]
1037 rustflags += [ "-Cembed-bitcode=no" ]
1041 # crbug.com/324126269 and github.com/rust-lang/rust/issues/120842.
1042 rustflags += [ "-Clto=no" ]
1045 rustflags += [ "-Ccodegen-units=1" ]
1053 "-Cpanic=abort",
1054 "-Zpanic_abort_tests",
1061 # consistently apply in both Chromium and non-Chromium code *and* non-NaCl
1084 # 64-bit Android sometimes defines __ARM_NEON but not __ARM_NEON__.
1085 # 32-bit Android builds and macOS, however, define __ARM_NEON__,
1104 ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
1111 rustflags = [ "-Clinker-plugin-lto=yes" ]
1114 rustflags = [ "-Cembed-bitcode=no" ]
1122 # configs -= [ "//build/config/compiler:thinlto_optimize_default" ]
1138 ldflags = [ "-Wl,--lto-O" + lto_opt_level ]
1145 rustflags = [ "-Clinker-plugin-lto=yes" ]
1148 rustflags = [ "-Cembed-bitcode=no" ]
1173 "-m64",
1174 "-msse3",
1181 "-mssse3",
1182 "-msse4",
1183 "-msse4.1",
1184 "-msse4.2",
1187 ldflags += [ "-m64" ]
1189 cflags += [ "-m32" ]
1190 ldflags += [ "-m32" ]
1193 "-mfpmath=sse",
1194 "-msse3",
1200 cflags += [ "--target=arm-linux-gnueabihf" ]
1201 ldflags += [ "--target=arm-linux-gnueabihf" ]
1205 "-march=$arm_arch",
1206 "-mfloat-abi=$arm_float_abi",
1210 cflags += [ "-mtune=$arm_tune" ]
1215 cflags += [ "--target=aarch64-linux-gnu" ]
1216 ldflags += [ "--target=aarch64-linux-gnu" ]
1219 ldflags += [ "-Wl,--hash-style=sysv" ]
1223 cflags += [ "--target=mipsel-linux-android" ]
1224 ldflags += [ "--target=mipsel-linux-android" ]
1226 cflags += [ "--target=mipsel-linux-gnu" ]
1227 ldflags += [ "--target=mipsel-linux-gnu" ]
1230 cflags += [ "-EL" ]
1231 ldflags += [ "-EL" ]
1236 cflags += [ "-mno-odd-spreg" ]
1237 ldflags += [ "-mips32r6" ]
1240 "-march=mipsel",
1241 "-mcpu=mips32r6",
1245 "-mips32r6",
1246 "-Wa,-mips32r6",
1249 ldflags += [ "-Wl,-melf32ltsmip" ]
1254 "-mmsa",
1255 "-mfp64",
1259 ldflags += [ "-mips32r2" ]
1262 "-march=mipsel",
1263 "-mcpu=mips32r2",
1267 "-mips32r2",
1268 "-Wa,-mips32r2",
1271 cflags += [ "-m$mips_fpu_mode" ]
1275 ldflags += [ "-mips32" ]
1278 "-march=mipsel",
1279 "-mcpu=mips32",
1283 "-mips32",
1284 "-Wa,-mips32",
1290 "-march=loongson3a",
1291 "-mno-branch-likely",
1292 "-Wa,-march=loongson3a",
1297 cflags += [ "-mdsp" ]
1299 cflags += [ "-mdspr2" ]
1302 cflags += [ "-m${mips_float_abi}-float" ]
1304 ldflags += [ "-Wl,--hash-style=sysv" ]
1307 cflags += [ "--target=mips-linux-gnu" ]
1308 ldflags += [ "--target=mips-linux-gnu" ]
1310 cflags += [ "-EB" ]
1311 ldflags += [ "-EB" ]
1317 "-mips32r6",
1318 "-Wa,-mips32r6",
1322 "-mmsa",
1323 "-mfp64",
1328 "-mips32r2",
1329 "-Wa,-mips32r2",
1332 cflags += [ "-m$mips_fpu_mode" ]
1336 "-mips32",
1337 "-Wa,-mips32",
1342 cflags += [ "-mdsp" ]
1344 cflags += [ "-mdspr2" ]
1347 cflags += [ "-m${mips_float_abi}-float" ]
1349 cflags += [ "-D__SANE_USERSPACE_TYPES__" ]
1350 ldflags += [ "-Wl,--hash-style=sysv" ]
1354 cflags += [ "--target=mips64el-linux-android" ]
1355 ldflags += [ "--target=mips64el-linux-android" ]
1357 cflags += [ "--target=mips64el-linux-gnuabi64" ]
1358 ldflags += [ "--target=mips64el-linux-gnuabi64" ]
1362 "-EL",
1363 "-mabi=64",
1366 "-EL",
1367 "-mabi=64",
1375 "-march=mips64el",
1376 "-mcpu=mips64r6",
1380 "-mips64r6",
1381 "-Wa,-mips64r6",
1383 ldflags += [ "-mips64r6" ]
1387 "-mmsa",
1388 "-mfp64",
1392 ldflags += [ "-mips64r2" ]
1395 "-march=mips64el",
1396 "-mcpu=mips64r2",
1400 "-mips64r2",
1401 "-Wa,-mips64r2",
1407 "-march=loongson3a",
1408 "-mno-branch-likely",
1409 "-Wa,-march=loongson3a",
1413 ldflags += [ "-Wl,--hash-style=sysv" ]
1416 cflags += [ "--target=mips64-linux-gnuabi64" ]
1417 ldflags += [ "--target=mips64-linux-gnuabi64" ]
1420 "-EB",
1421 "-mabi=64",
1424 "-EB",
1425 "-mabi=64",
1432 "-mips64r6",
1433 "-Wa,-mips64r6",
1435 ldflags += [ "-mips64r6" ]
1439 "-mmsa",
1440 "-mfp64",
1445 "-mips64r2",
1446 "-Wa,-mips64r2",
1448 ldflags += [ "-mips64r2" ]
1452 cflags += [ "-maix64" ]
1453 ldflags += [ "-maix64" ]
1455 cflags += [ "-m64" ]
1456 ldflags += [ "-m64" ]
1460 cflags += [ "--target=riscv64-linux-gnu" ]
1461 ldflags += [ "--target=riscv64-linux-gnu" ]
1463 cflags += [ "-mabi=lp64d" ]
1464 } else if (current_cpu == "loong64") {
1466 cflags += [ "--target=loongarch64-linux-gnu" ]
1467 ldflags += [ "--target=loongarch64-linux-gnu" ]
1470 "-mabi=lp64d",
1471 "-mcmodel=medium",
1474 cflags += [ "-m64" ]
1475 ldflags += [ "-m64" ]
1498 cflags += [ "-mno-outline" ]
1501 # has been resolved, and -mno-outline is obeyed by the linker during
1503 ldflags += [ "-Wl,-mllvm,-enable-machine-outliner=never" ]
1533 "-Wno-builtin-macro-redefined",
1534 "-D__DATE__=",
1535 "-D__TIME__=",
1536 "-D__TIMESTAMP__=",
1549 # TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
1551 "-Xclang",
1552 "-fdebug-compilation-dir",
1553 "-Xclang",
1557 # -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
1558 # and -fcoverage-compilation-dir=.
1559 cflags += [ "-ffile-compilation-dir=." ]
1560 swiftflags += [ "-file-compilation-dir=." ]
1563 # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167)
1564 asmflags = [ "-Wa,-fdebug-compilation-dir,." ]
1570 # if the pdb contains source-level debug information and if linker
1585 cflags += [ "-no-canonical-prefixes" ]
1588 # with a relative path and pass relative paths to built-in
1594 ldflags += [ "-no-canonical-prefixes" ]
1602 "--print-revision",
1603 "--verify-version=$clang_version",
1606 update_args += [ "--llvm-force-head-revision" ]
1626 "--cfg",
1634 cflags = [ "-mfpu=$arm_fpu" ]
1636 cflags += [ "-marm" ]
1645 cflags = [ "-mthumb" ]
1652 # is used to pass -mthumb, and therefor change the default.
1653 cflags = [ "-marm" ]
1657 # runtime_library -------------------------------------------------------------
1672 # libandroid_support in the -isystem include order. Otherwise, there will be
1683 # compiler-rt library.
1696 ldflags = [ "--unwindlib=none" ]
1700 # System-specific flags. If your compiler flags apply to one of the
1706 configs += [ "//build/config/linux:runtime_library" ]
1723 # treat_warnings_as_errors ----------------------------------------------------
1727 # is broken out separately so nocompile tests can force-enable this setting
1733 cflags = [ "-Werror" ]
1738 ldflags = [ "-Werror" ]
1742 # errors. The equivalent of -Werror for clang/gcc.
1745 # are suppressed in third-party crates.
1746 rustflags = [ "-Dwarnings" ]
1749 rustflags += [ "-Aunused-imports" ]
1752 # default_warnings ------------------------------------------------------------
1756 # flags are guaranteed to appear on the compile command line after -Wall.
1776 # gethostbyname. Fires mostly in non-Chromium code. We probably
1782 # https://swiftshader-review.googlesource.com/c/SwiftShader/+/57968 has
1790 cflags += [ "-Wunguarded-availability" ]
1794 # When compiling Objective-C, warns if a selector named via @selector has
1796 cflags += [ "-Wundeclared-selector" ]
1798 # Blink builds use a higher deployment target than non-Blink builds, so
1801 cflags += [ "-Wno-deprecated-declarations" ]
1808 cflags += [ "-Wno-psabi" ]
1813 # See comment for -Wno-c++11-narrowing.
1814 "-Wno-narrowing",
1817 # -Wno-class-memaccess warns about hash table and vector in blink.
1820 cflags_cc += [ "-Wno-class-memaccess" ]
1823 # -Wunused-local-typedefs is broken in gcc,
1825 cflags += [ "-Wno-unused-local-typedefs" ]
1828 # in -Wall but gcc does, and it gives false positives.
1829 cflags += [ "-Wno-maybe-uninitialized" ]
1830 cflags += [ "-Wno-deprecated-declarations" ]
1832 # -Wcomment gives too many false positives in the case a
1836 cflags += [ "-Wno-comments" ]
1838 # -Wpacked-not-aligned complains all generated mojom-shared-internal.h
1840 cflags += [ "-Wno-packed-not-aligned" ]
1848 "-Wno-missing-field-initializers", # "struct foo f = {0};"
1849 "-Wno-unused-parameter", # Unused function parameters.
1857 "-Wno-psabi",
1864 "-Wloop-analysis",
1866 # TODO(thakis): This used to be implied by -Wno-unused-function,
1869 "-Wno-unneeded-internal-declaration",
1876 cflags += [ "-Wno-nonportable-include-path" ]
1882 "-Wno-missing-field-initializers",
1885 "-Wno-extra-qualification",
1890 # TODO(crbug.com/330524456): -Wcast-function-type is under -Wextra now.
1891 "-Wno-cast-function-type",
1895 "-Wno-ignored-pragma-optimize",
1898 "-Wno-deprecated-builtins",
1901 "-Wno-bitfield-constant-conversion",
1904 "-Wno-deprecated-this-capture",
1906 # TODO(crbug.com/40285259): Fix and re-enable.
1907 "-Wno-invalid-offsetof",
1910 "-Wno-vla-extension",
1912 # TODO(crbug.com/40284799): Fix and re-enable.
1913 "-Wno-thread-safety-reference-return",
1917 # TODO(crbug.com/328490295): Fix and re-enable for C flags.
1918 "-Wenum-compare-conditional",
1923 # TODO(crbug.com/41486292): Fix and re-enable.
1924 "-Wno-c++11-narrowing-const-reference",
1928 # TODO(crbug.com/344680447): Fix and re-enable.
1929 cflags_cc += [ "-Wno-missing-template-arg-list-after-template-kw" ]
1939 "-Wno-error=unknown-warning-option",
1940 "-Wno-error=unused-command-line-argument",
1941 "-Wno-error=unknown-pragmas",
1950 # https://github.com/rust-lang/rust/issues/71668
1951 rustflags = [ "-Dunsafe_op_in_unsafe_fn" ]
1954 # prevent_unsafe_narrowing ----------------------------------------------------
1957 # likely to cause out-of-bound read/writes or Undefined Behaviour. In
1960 # memory-safety bugs and thus security exploits.
1972 # See also: https://docs.google.com/document/d/1CTbQ-5cQjnjU8aCOtLiA7G6P0i5C6HpSDNlSNq6nl5E
1980 "-Wshorten-64-to-32",
1981 "-Wimplicit-int-conversion",
1982 "-Wsign-compare",
1983 "-Wsign-conversion",
1987 # Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
1988 # fixing types to be sign-correct.
1989 "-Wtautological-unsigned-zero-compare",
1995 # chromium_code ---------------------------------------------------------------
2009 cflags = [ "-Wall" ]
2012 cflags += [ "-Wextra" ]
2016 # C99 macros on Mac and Linux.
2025 current_cpu != "riscv64" && current_cpu != "loong64") {
2026 # Non-chromium code is not guaranteed to compile cleanly with
2031 # ChromeOS's toolchain supports a high-quality _FORTIFY_SOURCE=3
2041 cflags_objc = [ "-Wimplicit-retain-self" ]
2042 cflags_objcc = [ "-Wimplicit-retain-self" ]
2046 cflags_objc += [ "-Wobjc-missing-property-synthesis" ]
2047 cflags_objcc += [ "-Wobjc-missing-property-synthesis" ]
2055 "-Wimplicit-fallthrough",
2058 "-Wextra-semi",
2062 "-Wunreachable-code-aggressive",
2070 "-Wthread-safety",
2101 cflags += [ "-Wall" ]
2107 # Lots of third-party libraries have unused variables. Instead of
2109 "-Wno-unused-variable",
2112 # third-party libraries.
2113 "-Wno-c++11-narrowing",
2117 # Disabled for similar reasons as -Wunused-variable.
2118 "-Wno-unused-but-set-variable",
2121 "-Wno-misleading-indentation",
2127 # https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
2128 rustflags = [ "--cap-lints=allow" ]
2139 # noshadowing -----------------------------------------------------------------
2141 # Allows turning -Wshadow on.
2147 cflags = [ "-Wshadow" ]
2151 # rtti ------------------------------------------------------------------------
2153 # Allows turning Run-Time Type Identification on or off.
2159 cflags_cc = [ "-frtti" ]
2167 cflags_cc = [ "/GR-" ]
2169 cflags_cc = [ "-fno-rtti" ]
2175 # export_dynamic ---------------------------------------------------------------
2179 # other memory-related symbols) to libraries. Otherwise, they might
2181 # to heap-allocated memory are passed over shared library boundaries.
2185 ldflags = [ "-rdynamic" ]
2189 # thin_archive -----------------------------------------------------------------
2207 arflags = [ "-T" ]
2213 # exceptions -------------------------------------------------------------------
2226 cflags_cc = [ "-fexceptions" ]
2243 cflags_cc = [ "-fno-exceptions" ]
2248 # Warnings ---------------------------------------------------------------------
2252 # See: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/B9Q5KTD7iCo/discussion
2255 cflags = [ "-Wglobal-constructors" ]
2259 # This will generate warnings when using Clang if code generates exit-time
2264 cflags = [ "-Wexit-time-destructors" ]
2276 cflags += [ "-Wno-incompatible-pointer-types" ]
2278 cflags += [ "-w" ]
2280 cflags += [ "-w" ]
2284 # Optimization -----------------------------------------------------------------
2290 # You can override the optimization level on a per-target basis by removing the
2293 # configs -= [ "//build/config/compiler:default_optimization" ]
2300 "/Oy-", # Disable omitting frame pointers, must be after /O2.
2306 # to put bit-identical constants at the same address even if
2315 # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
2328 common_optimize_on_cflags += [ "/clang:-fno-math-errno" ]
2335 # TODO(jdduke) Re-enable on mips after resolving linking
2340 "-Wl,--warn-shared-textrel",
2346 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
2350 "-Wl,-no_data_in_code_info",
2351 "-Wl,-no_function_starts",
2355 # Non-Mac Posix flags.
2360 # can be removed at link time with --gc-sections.
2361 "-fdata-sections",
2362 "-ffunction-sections",
2367 common_optimize_on_cflags += [ "-fno-unique-section-names" ]
2374 # -O2 enables string tail merge optimization in lld.
2375 "-Wl,-O2",
2379 common_optimize_on_ldflags += [ "-Wl,--gc-sections" ]
2383 # especially since glibc does not set it. Thus, use -fno-math-errno
2385 # Note that this is different from -ffast-math (even though -ffast-math
2386 # implies -fno-math-errno), which also allows a number of unsafe
2388 common_optimize_on_cflags += [ "-fno-math-errno" ]
2394 cflags = [ "-fno-omit-frame-pointer" ]
2400 cflags += [ "-momit-leaf-frame-pointer" ]
2403 cflags = [ "-fomit-frame-pointer" ]
2406 # On Windows, the flag to enable framepointers "/Oy-" must always come after
2409 # applied is well-defined by the GN spec, and there is no way to ensure that
2412 # config into the "optimize" config. We always apply the "/Oy-" config in the
2419 # High-end Android: As of April 2024, `-O2` appears to be a good default,
2420 # particularly since a selection of "hot" targets are already using `-O3`.
2421 # Enabling `-O3` for all targets does not change performance much (according
2422 # to Speedometer), but regresses binary size. Using `-O3` as the default:
2423 # - Decreases Speedometer 2.1 score by 0.2% [0].
2424 # - Increases Speedometer 3.0 score by 0.1% [1].
2425 # - Increases binary size by 1.47MB [2] (or 0.8%: the arm64 native code size
2427 # ... over `-O2`.
2429 # [0]: https://pinpoint-dot-chromeperf.appspot.com/job/147634a8be0000
2430 # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000
2436 # The `-O3` for clang turns on extra optimizations compared to the standard
2437 # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
2439 rustflags = [ "-Copt-level=3" ]
2442 # -Os in clang is more of a size-conscious -O2 than "size at any cost"
2443 # (AKA -Oz).
2446 cflags = [ "-Oz" ] + common_optimize_on_cflags
2448 cflags = [ "-Os" ] + common_optimize_on_cflags
2453 "-mllvm",
2454 "-enable-ml-inliner=release",
2458 # Similar to clang, we optimize with `-Copt-level=s` to keep loop
2460 rustflags = [ "-Copt-level=s" ]
2462 cflags = [ "-O2" ] + common_optimize_on_cflags
2464 # The `-O3` for clang turns on extra optimizations compared to the standard
2465 # `-O2`. But for rust, `-Copt-level=3` is the default and is thus reliable
2467 rustflags = [ "-Copt-level=3" ]
2484 cflags += [ "/Oy-" ]
2490 cflags = [ "-Oz" ] + common_optimize_on_cflags
2492 cflags = [ "-Os" ] + common_optimize_on_cflags
2498 ldflags = [ "-Wl,--gc-sections" ]
2503 cflags = [ "-Og" ]
2505 cflags = [ "-O0" ]
2510 # Turns up the optimization level. Used to explicitly enable -O2 instead of
2511 # -Os for select targets on platforms that use optimize_for_size. No-op
2518 # configs -= [ "//build/config/compiler:default_optimization" ]
2531 cflags = [ "-O1" ] + common_optimize_on_cflags
2533 cflags = [ "-O2" ] + common_optimize_on_cflags
2535 rustflags = [ "-Copt-level=3" ]
2539 # This config can be used to override the default settings for per-component
2540 # and whole-program optimization, optimizing the particular target for speed
2542 # except that we use -O3 instead of -O2 on non-IRT platforms.
2544 # TODO(crbug.com/41259697) - rework how all of these configs are related
2551 # configs -= [ "//build/config/compiler:default_optimization" ]
2564 cflags += [ "/clang:-O3" ]
2567 cflags = [ "-O1" ] + common_optimize_on_cflags
2569 cflags = [ "-O3" ] + common_optimize_on_cflags
2571 rustflags = [ "-Copt-level=3" ]
2576 cflags = [ "-O1" ] + common_optimize_on_cflags
2577 rustflags = [ "-Copt-level=1" ]
2595 # slower as it uses "-O1" instead of "-O3". Prevent that from happening.
2621 chromeos_afdo_platform == "arm-exp",
2622 "Only 'atom', 'bigcore', 'arm' and 'arm-exp' are valid ChromeOS profiles.")
2635 cflags = [ "-fprofile-sample-accurate" ]
2639 # GCC and clang support a form of profile-guided optimization called AFDO.
2641 # config to allow AFDO to be disabled per-target.
2647 cflags += [ "-gline-tables-only" ]
2649 cflags += [ "-fdebug-info-for-profiling" ]
2656 cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
2658 cflags += [ "-fsample-profile-use-profi" ]
2661 # crbug.com/1459429: ARM builds see failures due to -Wbackend-plugin.
2662 # These seem to be false positives - the complaints are about functions
2667 cflags += [ "-Wno-backend-plugin" ]
2671 cflags = [ "-fauto-profile=${auto_profile_path}" ]
2676 # Symbols ----------------------------------------------------------------------
2681 # You can override the symbol level on a per-target basis by removing the
2684 # configs -= [ "//build/config/compiler:default_symbols" ]
2688 # include as sub-config.
2699 # so there's minimal downside to always using this. However, post-mortem
2717 # prevent some types of non-determinism.
2718 "-gno-codeview-command-line",
2725 cflags += [ "-gcodeview-ghash" ]
2736 # If generating dSYMs, specify -fno-standalone-debug. This was
2741 cflags += [ "-fno-standalone-debug" ]
2744 # On aix -gdwarf causes linker failures due to thread_local variables.
2747 cflags += [ "-gdwarf-5" ]
2748 rustflags += [ "-Zdwarf-version=5" ]
2750 # Recent clang versions default to DWARF5 on Linux, and Android is about
2755 cflags += [ "-gdwarf-4" ]
2760 rustflags += [ "-Zdwarf-version=4" ]
2764 # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
2765 # elsewhere in this file), so they can't have build-dir-independent output.
2766 # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
2768 # build-directory-independent output.
2769 # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are
2772 cflags += [ "-g2" ]
2776 # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has
2782 cflags += [ "-gdwarf-aranges" ]
2786 swiftflags = [ "-g" ]
2790 cflags += [ "-gsplit-dwarf" ]
2796 # thinlto requires -gsplit-dwarf in ldflags.
2798 ldflags += [ "-gsplit-dwarf" ]
2801 # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
2809 # Disable on non-fission 32-bit Android because it pushes
2815 # This flag enables the GNU-format pubnames and pubtypes sections,
2817 # TODO(pcc): Try to make lld understand non-GNU-format pubnames
2819 cflags += [ "-ggnu-pubnames" ]
2821 ldflags += [ "-Wl,--gdb-index" ]
2827 # Compress debug on 32-bit ARM to stay under 4GB file size limit.
2840 "-Xclang",
2841 "-debug-info-kind=limited",
2847 "-Xclang",
2848 "-fuse-ctor-homing",
2852 rustflags += [ "-g" ]
2867 # prevent some types of non-determinism.
2868 "-gno-codeview-command-line",
2872 cflags += [ "-gcodeview-ghash" ]
2883 # -gline-tables-only is the same as -g1, but clang-cl only exposes the
2885 cflags += [ "-gline-tables-only" ]
2893 cflags += [ "-gdwarf-4" ]
2894 rustflags += [ "-Zdwarf-version=4" ]
2896 # On aix -gdwarf causes linker failures due to thread_local variables.
2897 # Recent clang versions default to DWARF5 on Linux, and Android is about
2899 cflags += [ "-gdwarf-4" ]
2900 rustflags += [ "-Zdwarf-version=4" ]
2904 cflags += [ "-gdwarf-5" ]
2905 rustflags += [ "-Zdwarf-version=5" ]
2908 # The gcc-based nacl compilers don't support -fdebug-compilation-dir (see
2909 # elsewhere in this file), so they can't have build-dir-independent output.
2910 # Moreover pnacl does not support newer flags such as -fdebug-prefix-map
2912 # build-directory-independent output.
2913 # Keeping -g1 for saigo as it's the only toolchain whose artifacts that are
2916 cflags += [ "-g1" ]
2920 # See comment for -gdwarf-aranges in config("symbols").
2921 cflags += [ "-gdwarf-aranges" ]
2927 # doesn't emit DW_AT_linkage_name in -g1 builds.
2928 # -fdebug-info-for-profiling enables that (and a bunch of other things we
2930 # TODO(thakis): Consider making clang emit DW_AT_linkage_name in -g1 mode;
2931 # failing that consider doing this on non-Android too.
2932 cflags += [ "-fdebug-info-for-profiling" ]
2937 rustflags += [ "-Cdebuginfo=1" ]
2950 cflags = [ "-g0" ]
2977 ldflags += [ "-Wl,--strip-debug" ]
2984 # -fobjc-arc enables ARC overall.
2986 # ARC does not add exception handlers to pure Objective-C code, but does add
2987 # them to Objective-C++ code with the rationale that C++ pervasively adds them
2989 # C++ and exceptions in Objective-C code are intended to be fatal, so
2990 # -fno-objc-arc-exceptions is specified to disable these unwanted exception
2994 "-fobjc-arc",
2995 "-fno-objc-arc-exceptions",
3013 "-Wl,--symbol-ordering-file",
3014 "-Wl,$_rebased_orderfile",
3015 "-Wl,--no-warn-symbol-ordering",
3027 cflags += [ "-ftrivial-auto-var-init=zero" ]
3029 cflags += [ "-ftrivial-auto-var-init=pattern" ]