OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
6 if (cpu_arch == "arm") { | 6 if (cpu_arch == "arm") { |
7 import("//build/config/arm.gni") | 7 import("//build/config/arm.gni") |
8 } | 8 } |
9 if (cpu_arch == "mipsel" || cpu_arch == "mips64el") { | 9 if (cpu_arch == "mipsel" || cpu_arch == "mips64el") { |
10 import("//build/config/mips.gni") | 10 import("//build/config/mips.gni") |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 "-fPIC", | 343 "-fPIC", |
344 "-pipe", # Use pipes for communicating between sub-processes. Faster. | 344 "-pipe", # Use pipes for communicating between sub-processes. Faster. |
345 ] | 345 ] |
346 | 346 |
347 ldflags += [ | 347 ldflags += [ |
348 "-fPIC", | 348 "-fPIC", |
349 "-Wl,-z,noexecstack", | 349 "-Wl,-z,noexecstack", |
350 "-Wl,-z,now", | 350 "-Wl,-z,now", |
351 "-Wl,-z,relro", | 351 "-Wl,-z,relro", |
352 ] | 352 ] |
353 | 353 if (!using_sanitizer) { |
354 # TODO(zork): The mipsel build is broken in ffmpeg, guard this flag for now | |
355 # to hide the breakage. https://crbug.com/450771 | |
356 if (!using_sanitizer && cpu_arch != "mipsel") { | |
357 ldflags += [ "-Wl,-z,defs" ] | 354 ldflags += [ "-Wl,-z,defs" ] |
358 } | 355 } |
359 } | 356 } |
360 | 357 |
361 # Linux-specific compiler flags setup. | 358 # Linux-specific compiler flags setup. |
362 # ------------------------------------ | 359 # ------------------------------------ |
363 if (is_linux) { | 360 if (is_linux) { |
364 cflags += [ "-pthread" ] | 361 cflags += [ "-pthread" ] |
365 ldflags += [ "-pthread" ] | 362 ldflags += [ "-pthread" ] |
366 } | 363 } |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 # configs += [ "//build/config/compiler/optimize_max" ] | 893 # configs += [ "//build/config/compiler/optimize_max" ] |
897 | 894 |
898 # Shared settings for both "optimize" and "optimize_max" configs. | 895 # Shared settings for both "optimize" and "optimize_max" configs. |
899 if (is_win) { | 896 if (is_win) { |
900 common_optimize_on_cflags = [ | 897 common_optimize_on_cflags = [ |
901 "/O2", | 898 "/O2", |
902 "/Ob2", # both explicit and auto inlining. | 899 "/Ob2", # both explicit and auto inlining. |
903 "/Oy-", # disable omitting frame pointers, must be after /o2. | 900 "/Oy-", # disable omitting frame pointers, must be after /o2. |
904 "/Os", # favor size over speed. | 901 "/Os", # favor size over speed. |
905 ] | 902 ] |
906 common_optimize_on_ldflags = [] | 903 if (!is_asan) { |
| 904 common_optimize_on_cflags += [ |
| 905 # Put data in separate COMDATs. This allows the linker |
| 906 # to put bit-identical constants at the same address even if |
| 907 # they're unrelated constants, which saves binary size. |
| 908 # This optimization can't be used when ASan is enabled because |
| 909 # it is not compatible with the ASan ODR checker. |
| 910 "/Gw", |
| 911 ] |
| 912 } |
| 913 common_optimize_on_ldflags = [ "/OPT:REF" ] |
907 } else { | 914 } else { |
908 common_optimize_on_cflags = [ | 915 common_optimize_on_cflags = [ |
909 # Don't emit the GCC version ident directives, they just end up in the | 916 # Don't emit the GCC version ident directives, they just end up in the |
910 # .comment section taking up binary size. | 917 # .comment section taking up binary size. |
911 "-fno-ident", | 918 "-fno-ident", |
912 | 919 |
913 # Put data and code in their own sections, so that unused symbols | 920 # Put data and code in their own sections, so that unused symbols |
914 # can be removed at link time with --gc-sections. | 921 # can be removed at link time with --gc-sections. |
915 "-fdata-sections", | 922 "-fdata-sections", |
916 "-ffunction-sections", | 923 "-ffunction-sections", |
(...skipping 14 matching lines...) Expand all Loading... |
931 if (symbol_level == 2) { | 938 if (symbol_level == 2) { |
932 # Mac dead code stripping requires symbols. | 939 # Mac dead code stripping requires symbols. |
933 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] | 940 common_optimize_on_ldflags += [ "-Wl,-dead_strip" ] |
934 } | 941 } |
935 } else { | 942 } else { |
936 # Non-Mac Posix linker flags. | 943 # Non-Mac Posix linker flags. |
937 common_optimize_on_ldflags += [ | 944 common_optimize_on_ldflags += [ |
938 # Specifically tell the linker to perform optimizations. | 945 # Specifically tell the linker to perform optimizations. |
939 # See http://lwn.net/Articles/192624/ . | 946 # See http://lwn.net/Articles/192624/ . |
940 "-Wl,-O1", | 947 "-Wl,-O1", |
941 "-Wl,--as-needed", | |
942 "-Wl,--gc-sections", | 948 "-Wl,--gc-sections", |
943 ] | 949 ] |
| 950 |
| 951 if (!using_sanitizer) { |
| 952 # Functions interposed by the sanitizers can make ld think |
| 953 # that some libraries aren't needed when they actually are, |
| 954 # http://crbug.com/234010. As workaround, disable --as-needed. |
| 955 common_optimize_on_ldflags += [ "-Wl,--as-needed" ] |
| 956 } |
944 } | 957 } |
945 } | 958 } |
946 | 959 |
947 # Default "optimization on" config. On Windows, this favors size over speed. | 960 # Default "optimization on" config. On Windows, this favors size over speed. |
948 config("optimize") { | 961 config("optimize") { |
949 cflags = common_optimize_on_cflags | 962 cflags = common_optimize_on_cflags |
950 ldflags = common_optimize_on_ldflags | 963 ldflags = common_optimize_on_ldflags |
951 if (is_win) { | 964 if (is_win) { |
952 cflags += [ "/Os" ] # favor size over speed. | 965 cflags += [ "/Os" ] # favor size over speed. |
953 } else if (is_android || is_ios) { | 966 } else if (is_android || is_ios) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 cflags += [ "-gsplit-dwarf" ] | 1053 cflags += [ "-gsplit-dwarf" ] |
1041 } | 1054 } |
1042 } | 1055 } |
1043 } | 1056 } |
1044 | 1057 |
1045 config("no_symbols") { | 1058 config("no_symbols") { |
1046 if (!is_win) { | 1059 if (!is_win) { |
1047 cflags = [ "-g0" ] | 1060 cflags = [ "-g0" ] |
1048 } | 1061 } |
1049 } | 1062 } |
OLD | NEW |