Chromium Code Reviews| Index: tools/clang/scripts/update.py |
| diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py |
| index 421fee4472e4a144221a69884c08a28ed88b2dd2..f419b21a68bb2a83a3f1215fa0d7d9cfeb6a8490 100755 |
| --- a/tools/clang/scripts/update.py |
| +++ b/tools/clang/scripts/update.py |
| @@ -437,7 +437,8 @@ def UpdateClang(args): |
| Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) |
| Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) |
| - if sys.platform == 'win32' or use_head_revision: |
| + if (sys.platform == 'win32' or sys.platform.startswith('linux') |
| + or use_head_revision): |
| Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR) |
|
hans
2016/07/22 15:33:05
I wonder if we should just always build it, to sim
krasin1
2016/07/22 20:19:57
This is a good idea. Done.
|
| Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) |
| if sys.platform == 'darwin': |
| @@ -529,22 +530,16 @@ def UpdateClang(args): |
| # Build LLVM gold plugin with LTO. That speeds up the linker by ~10%. |
| # We only use LTO for Linux now. |
| - if args.bootstrap and args.lto_gold_plugin: |
| + if args.bootstrap and args.lto: |
| print 'Building LTO LLVM Gold plugin' |
| if os.path.exists(LLVM_LTO_GOLD_PLUGIN_DIR): |
| RmTree(LLVM_LTO_GOLD_PLUGIN_DIR) |
| EnsureDirExists(LLVM_LTO_GOLD_PLUGIN_DIR) |
| os.chdir(LLVM_LTO_GOLD_PLUGIN_DIR) |
| - # Create a symlink to LLVMgold.so build in the previous step so that ar |
| - # and ranlib could find it while linking LLVMgold.so with LTO. |
| - EnsureDirExists(BFD_PLUGINS_DIR) |
| - RunCommand(['ln', '-sf', |
| - os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'lib', 'LLVMgold.so'), |
| - os.path.join(BFD_PLUGINS_DIR, 'LLVMgold.so')]) |
| - |
| lto_cflags = ['-flto'] |
| - lto_ldflags = ['-fuse-ld=gold'] |
| + lto_cxxflags = ['-flto'] |
| + lto_ldflags = ['-fuse-ld=lld'] |
| if args.gcc_toolchain: |
| # Tell the bootstrap compiler to use a specific gcc prefix to search |
| # for standard library headers and shared object files. |
| @@ -554,15 +549,14 @@ def UpdateClang(args): |
| '-DCMAKE_C_COMPILER=' + cc, |
| '-DCMAKE_CXX_COMPILER=' + cxx, |
| '-DCMAKE_C_FLAGS=' + ' '.join(lto_cflags), |
| - '-DCMAKE_CXX_FLAGS=' + ' '.join(lto_cflags), |
| + '-DCMAKE_CXX_FLAGS=' + ' '.join(lto_cxxflags), |
| '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(lto_ldflags), |
| '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(lto_ldflags), |
| '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(lto_ldflags)] |
| - # We need to use the proper binutils which support LLVM Gold plugin. |
| + # We need to use the proper binutils which support LTO. |
| lto_env = os.environ.copy() |
| lto_env['PATH'] = BINUTILS_BIN_DIR + os.pathsep + lto_env.get('PATH', '') |
| - |
| RmCmakeCache('.') |
| RunCommand(['cmake'] + lto_cmake_args + [LLVM_DIR], env=lto_env) |
| RunCommand(['ninja', 'LLVMgold'], env=lto_env) |
| @@ -597,10 +591,27 @@ def UpdateClang(args): |
| CreateChromeToolsShim() |
| - deployment_env = None |
| + llvm_build_cflags = cflags |
| + llvm_build_cxxflags = cxxflags |
| + llvm_build_ldflags = ldflags |
| + llvm_build_env = None |
| + if sys.platform != 'win32': |
| + # On Windows, the line below might add some Unicode entries |
| + # and that will fail if passed into popen. See |
| + # http://stackoverflow.com/questions/12253014/why-does-popen-fail-on-windows-if-the-env-parameter-contains-a-unicode-object |
| + # Since we don't need to add anything into environment on Windows, |
| + # just workaround this, until we moved into Python 3, where it's |
| + # supposedly fixed. |
| + llvm_build_env = os.environ.copy() |
|
hans
2016/07/22 15:33:05
Pretty scary. But now we'll have an empty llvm_bui
krasin1
2016/07/22 20:19:58
This is a non-functional change for windows, as pa
|
| if deployment_target: |
| - deployment_env = os.environ.copy() |
| - deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target |
| + llvm_build_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target |
| + if args.lto: |
| + # Put proper binutils for building with LTO |
| + llvm_build_env['PATH'] = (BINUTILS_BIN_DIR + os.pathsep + |
| + llvm_build_env.get('PATH', '')) |
| + llvm_build_cflags += ['-flto'] |
| + llvm_build_cxxflags += ['-flto'] |
| + llvm_build_ldflags += ['-fuse-ld=lld'] |
| cmake_args = [] |
| # TODO(thakis): Unconditionally append this to base_cmake_args instead once |
| @@ -610,11 +621,11 @@ def UpdateClang(args): |
| if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx) |
| cmake_args += base_cmake_args + [ |
| '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, |
| - '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
| - '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags), |
| - '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags), |
| - '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags), |
| - '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags), |
| + '-DCMAKE_C_FLAGS=' + ' '.join(llvm_build_cflags), |
| + '-DCMAKE_CXX_FLAGS=' + ' '.join(llvm_build_cxxflags), |
| + '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(llvm_build_ldflags), |
| + '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(llvm_build_ldflags), |
| + '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(llvm_build_ldflags), |
| '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR, |
| # TODO(thakis): Remove this once official builds pass -Wl,--build-id |
| # explicitly, https://crbug.com/622775 |
| @@ -626,7 +637,7 @@ def UpdateClang(args): |
| os.chdir(LLVM_BUILD_DIR) |
| RmCmakeCache('.') |
| RunCommand(['cmake'] + cmake_args + [LLVM_DIR], |
| - msvc_arch='x64', env=deployment_env) |
| + msvc_arch='x64', env=llvm_build_env) |
| if args.gcc_toolchain: |
| # Copy in the right stdlibc++.so.6 so clang can start. |
| @@ -666,8 +677,8 @@ def UpdateClang(args): |
| #cflags += ['-m32'] |
| #cxxflags += ['-m32'] |
| compiler_rt_args = base_cmake_args + [ |
| - '-DCMAKE_C_FLAGS=' + ' '.join(cflags), |
| - '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)] |
| + '-DCMAKE_C_FLAGS=' + ' '.join(llvm_build_cflags), |
| + '-DCMAKE_CXX_FLAGS=' + ' '.join(llvm_build_cxxflags)] |
| if sys.platform != 'win32': |
| compiler_rt_args += ['-DLLVM_CONFIG_PATH=' + |
| os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-config'), |
| @@ -677,7 +688,7 @@ def UpdateClang(args): |
| RmCmakeCache('.') |
| RunCommand(['cmake'] + compiler_rt_args + |
| [LLVM_DIR if sys.platform == 'win32' else COMPILER_RT_DIR], |
| - msvc_arch='x86', env=deployment_env) |
| + msvc_arch='x86', env=llvm_build_env) |
| RunCommand(['ninja', 'compiler-rt'], msvc_arch='x86') |
| # Copy select output to the main tree. |
| @@ -808,8 +819,8 @@ def main(): |
| parser.add_argument('--gcc-toolchain', help='set the version for which gcc ' |
| 'version be used for building; --gcc-toolchain=/opt/foo ' |
| 'picks /opt/foo/bin/gcc') |
| - parser.add_argument('--lto-gold-plugin', action='store_true', |
| - help='build LLVM Gold plugin with LTO') |
| + parser.add_argument('--lto', action='store_true', |
| + help='build Clang toolchain with LTO') |
|
hans
2016/07/22 15:33:05
The flag also controls whether to build the Gold p
krasin1
2016/07/22 20:19:57
Yes, but I hope we can remove Gold plugin altogeth
|
| parser.add_argument('--llvm-force-head-revision', action='store_true', |
| help=('use the revision in the repo when printing ' |
| 'the revision')) |
| @@ -828,12 +839,12 @@ def main(): |
| default=sys.platform.startswith('linux')) |
| args = parser.parse_args() |
| - if args.lto_gold_plugin and not args.bootstrap: |
| - print '--lto-gold-plugin requires --bootstrap' |
| + if args.lto and not args.bootstrap: |
| + print '--lto requires --bootstrap' |
| return 1 |
| - if args.lto_gold_plugin and not sys.platform.startswith('linux'): |
| - print '--lto-gold-plugin is only effective on Linux. Ignoring the option.' |
| - args.lto_gold_plugin = False |
| + if args.lto and not sys.platform.startswith('linux'): |
| + print '--lto is only effective on Linux. Ignoring the option.' |
| + args.lto = False |
| if args.if_needed: |
| is_clang_required = False |