From e06dc0569a01cff00cd8d726457015182bea8f98 Mon Sep 17 00:00:00 2001 From: bmeurer Date: Mon, 9 Feb 2015 23:26:59 -0800 Subject: [PATCH] [linux] Improve link time with Chromium-bundled binutils. Also enabled concurrent linking with gold on Linux. Mostly copy and paste from Chromium with customization for V8 where necessary. BUG=v8:3880 LOG=n Review URL: https://codereview.chromium.org/896703003 Cr-Commit-Position: refs/heads/master@{#26536} --- DEPS | 11 ++ build/toolchain.gypi | 75 +++++++++++++ .../binutils/Linux_ia32/binutils.tar.bz2.sha1 | 1 + .../binutils/Linux_x64/binutils.tar.bz2.sha1 | 1 + third_party/binutils/download.py | 118 +++++++++++++++++++++ 5 files changed, 206 insertions(+) create mode 100644 third_party/binutils/Linux_ia32/binutils.tar.bz2.sha1 create mode 100644 third_party/binutils/Linux_x64/binutils.tar.bz2.sha1 create mode 100755 third_party/binutils/download.py diff --git a/DEPS b/DEPS index 5c72db1..062e10e 100644 --- a/DEPS +++ b/DEPS @@ -80,6 +80,17 @@ hooks = [ "-s", "v8/buildtools/linux64/clang-format.sha1", ], }, + # Pull binutils for linux, enabled debug fission for faster linking / + # debugging when used with clang on Ubuntu Precise. + # https://code.google.com/p/chromium/issues/detail?id=352046 + { + 'name': 'binutils', + 'pattern': 'v8/third_party/binutils', + 'action': [ + 'python', + 'v8/third_party/binutils/download.py', + ], + }, { # Pull clang if needed or requested via GYP_DEFINES. # Note: On Win, this should run after win_toolchain, as it may use it. diff --git a/build/toolchain.gypi b/build/toolchain.gypi index e0d6d74..dfaffd0 100644 --- a/build/toolchain.gypi +++ b/build/toolchain.gypi @@ -86,6 +86,46 @@ # Allow to suppress the array bounds warning (default is no suppression). 'wno_array_bounds%': '', + # Override where to find binutils + 'binutils_dir%': '', + + 'conditions': [ + ['OS=="linux" and host_arch=="x64"', { + 'binutils_dir%': 'third_party/binutils/Linux_x64/Release/bin', + }], + ['OS=="linux" and host_arch=="ia32"', { + 'binutils_dir%': 'third_party/binutils/Linux_ia32/Release/bin', + }], + + # linux_use_bundled_gold: whether to use the gold linker binary checked + # into third_party/binutils. Force this off via GYP_DEFINES when you + # are using a custom toolchain and need to control -B in ldflags. + # Do not use 32-bit gold on 32-bit hosts as it runs out address space + # for component=static_library builds. + ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', { + 'linux_use_bundled_gold%': 1, + }, { + 'linux_use_bundled_gold%': 0, + }], + # linux_use_bundled_binutils: whether to use the binary binutils + # checked into third_party/binutils. These are not multi-arch so cannot + # be used except on x86 and x86-64 (the only two architectures which + # are currently checke in). Force this off via GYP_DEFINES when you + # are using a custom toolchain and need to control -B in cflags. + ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', { + 'linux_use_bundled_binutils%': 1, + }, { + 'linux_use_bundled_binutils%': 0, + }], + # linux_use_gold_flags: whether to use build flags that rely on gold. + # On by default for x64 Linux. + ['OS=="linux" and target_arch=="x64"', { + 'linux_use_gold_flags%': 1, + }, { + 'linux_use_gold_flags%': 0, + }], + ], + # Link-Time Optimizations 'use_lto%': 0, @@ -797,6 +837,26 @@ '-mx32', ], }], # v8_target_arch=="x32" + ['linux_use_gold_flags==1', { + # Newer gccs and clangs support -fuse-ld, use the flag to force gold + # selection. + # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html + 'ldflags': [ '-fuse-ld=gold', ], + }], + ['linux_use_bundled_binutils==1', { + 'cflags': [ + '-B