diff options
author | krasin <krasin@google.com> | 2016-02-25 14:56:23 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-25 22:58:39 +0000 |
commit | 2de2f30ff962315aef7d81159918548db9a00566 (patch) | |
tree | 7115cdd0bc63da14e77ae7160a04515f4f6b0783 | |
parent | 991e59ed76f5cd44e90422ea7b9e58e7f8bda562 (diff) | |
download | chromium_src-2de2f30ff962315aef7d81159918548db9a00566.zip chromium_src-2de2f30ff962315aef7d81159918548db9a00566.tar.gz chromium_src-2de2f30ff962315aef7d81159918548db9a00566.tar.bz2 |
Add gn option 'is_lto' to enable Link Time Optimization builds.
We'll launch LTO builds on Linux first, and then add CFI
(control flow integrity) on top of that.
BUG=589915
Review URL: https://codereview.chromium.org/1734043003
Cr-Commit-Position: refs/heads/master@{#377695}
-rw-r--r-- | build/config/sanitizers/BUILD.gn | 42 | ||||
-rw-r--r-- | build/config/sanitizers/sanitizers.gni | 4 | ||||
-rw-r--r-- | build/toolchain/gcc_toolchain.gni | 4 | ||||
-rw-r--r-- | build/toolchain/win/BUILD.gn | 2 |
4 files changed, 31 insertions, 21 deletions
diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn index 19af2ba..0b596ba 100644 --- a/build/config/sanitizers/BUILD.gn +++ b/build/config/sanitizers/BUILD.gn @@ -92,13 +92,8 @@ config("default_sanitizer_ldflags") { if (is_ubsan_vptr) { ldflags += [ "-fsanitize=vptr" ] } - if (is_cfi && !is_nacl) { - ldflags += [ - "-flto", - "-fsanitize=cfi-vcall", - "-fsanitize=cfi-derived-cast", - "-fsanitize=cfi-unrelated-cast", - ] + if (is_lto && !is_nacl) { + ldflags += [ "-flto" ] # Apply a lower LTO optimization level as the default is too slow. if (is_linux) { @@ -119,6 +114,14 @@ config("default_sanitizer_ldflags") { ldflags += [ "-Wl,-plugin-opt,-function-sections" ] } + if (is_cfi) { + ldflags += [ + "-fsanitize=cfi-vcall", + "-fsanitize=cfi-derived-cast", + "-fsanitize=cfi-unrelated-cast", + ] + } + if (use_cfi_diag) { ldflags += [ "-fno-sanitize-trap=cfi", @@ -147,7 +150,7 @@ config("default_sanitizer_flags") { if (is_posix) { # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer, # MemorySanitizer and non-official CFI builds. - if (using_sanitizer || (is_cfi && !is_official_build)) { + if (using_sanitizer || (is_lto && !is_official_build)) { cflags += [ "-fno-omit-frame-pointer", "-gline-tables-only", @@ -243,16 +246,19 @@ config("default_sanitizer_flags") { "-fsanitize-blacklist=$ubsan_vptr_blacklist_path", ] } - if (is_cfi && !is_nacl) { - cfi_blacklist_path = - rebase_path("//tools/cfi/blacklist.txt", root_build_dir) - cflags += [ - "-flto", - "-fsanitize=cfi-vcall", - "-fsanitize=cfi-derived-cast", - "-fsanitize=cfi-unrelated-cast", - "-fsanitize-blacklist=$cfi_blacklist_path", - ] + if (is_lto && !is_nacl) { + cflags += [ "-flto" ] + + if (is_cfi) { + cfi_blacklist_path = + rebase_path("//tools/cfi/blacklist.txt", root_build_dir) + cflags += [ + "-fsanitize=cfi-vcall", + "-fsanitize=cfi-derived-cast", + "-fsanitize=cfi-unrelated-cast", + "-fsanitize-blacklist=$cfi_blacklist_path", + ] + } if (use_cfi_diag) { cflags += [ diff --git a/build/config/sanitizers/sanitizers.gni b/build/config/sanitizers/sanitizers.gni index bd89cdb..0323807 100644 --- a/build/config/sanitizers/sanitizers.gni +++ b/build/config/sanitizers/sanitizers.gni @@ -68,6 +68,10 @@ declare_args() { use_custom_libcxx = (is_asan && is_linux) || is_tsan || is_msan || is_ubsan || use_libfuzzer + # Enable Link Time Optimization (output programs runs faster, + # but linking is up to 5-20x slower. + is_lto = is_cfi + use_sanitizer_coverage = use_libfuzzer } diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 0c314bb..a6b3add 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -9,7 +9,7 @@ import("//build/toolchain/goma.gni") import("//build/toolchain/toolchain.gni") # This value will be inherited in the toolchain below. -if (is_cfi) { +if (is_lto) { concurrent_links = exec_script("get_concurrent_links.py", [ "--lto" ], "value") } else { @@ -217,7 +217,7 @@ template("gcc_toolchain") { tool("alink") { rspfile = "{{output}}.rsp" arflags = "" - if (is_cfi && invoker.toolchain_os != "nacl") { + if (is_lto && invoker.toolchain_os != "nacl") { gold_plugin_path = rebase_path( "//third_party/llvm-build/Release+Asserts/lib/LLVMgold.so", root_build_dir) diff --git a/build/toolchain/win/BUILD.gn b/build/toolchain/win/BUILD.gn index 1934e9b..7c359b8 100644 --- a/build/toolchain/win/BUILD.gn +++ b/build/toolchain/win/BUILD.gn @@ -25,7 +25,7 @@ if (use_goma) { } # This value will be inherited in the toolchain below. -if (is_cfi) { +if (is_lto) { concurrent_links = exec_script("../get_concurrent_links.py", [ "--lto" ], "value") } else { |