diff options
author | Ryan Prichard <rprichard@google.com> | 2018-04-06 11:34:12 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-04-06 11:34:12 -0700 |
commit | 49f78f5dafbe31790a52fb90dfda09a26f551f3c (patch) | |
tree | 15d9cf774ffc73a9011d19c3b69318e61954a452 | |
parent | 19df9bb8a21642ab6bd44cee72528bf468c7cd20 (diff) | |
parent | 2485f18b02e8a6d2173314daa570d81f580607c3 (diff) | |
download | binutils-49f78f5dafbe31790a52fb90dfda09a26f551f3c.tar.gz |
Windows: enable gold threading, copy libwinpthread-1.dll
am: 2485f18b02
Change-Id: Id8b65c16f617b6c4995a94a11002944c052b9dc2
-rwxr-xr-x | build.py | 38 |
1 files changed, 30 insertions, 8 deletions
@@ -60,6 +60,12 @@ def chdir(path): os.chdir(path) +def install_file(src, dst): + """shutil.copy2 with logging.""" + logger().info('copy %s %s', src, dst) + shutil.copy2(src, dst) + + def check_call(cmd, *args, **kwargs): """subprocess.check_call with logging.""" logger().info('check_call %s', subprocess.list2cmdline(cmd)) @@ -84,6 +90,7 @@ def configure(arch, host, install_dir, src_dir): '--host={}'.format(configure_host), '--enable-initfini-array', '--enable-plugins', + '--enable-threads', '--disable-nls', '--with-sysroot={}'.format(sysroot), '--prefix={}'.format(install_dir), @@ -97,12 +104,6 @@ def configure(arch, host, install_dir, src_dir): # https://issuetracker.google.com/70838247 configure_args.append('--enable-gold=default') - if not is_windows: - # Multithreaded linking is implemented with pthreads, which we - # historically couldn't use on Windows. - # TODO: Try enabling this now that we have winpthreads in mingw. - configure_args.append('--enable-threads') - env = {} m32 = False @@ -158,10 +159,31 @@ def build(jobs): check_call(['make', '-j', str(jobs)]) -def install(jobs): +def install_winpthreads(is_windows32, install_dir): + """Installs the winpthreads runtime to the Windows bin directory.""" + lib_name = 'libwinpthread-1.dll' + mingw_dir = ndk.paths.android_path( + 'prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8', + 'x86_64-w64-mingw32') + # Yes, this indeed may be found in bin/ because the executables are the + # 64-bit version by default. + pthread_dir = 'lib32' if is_windows32 else 'bin' + lib_path = os.path.join(mingw_dir, pthread_dir, lib_name) + + lib_install = os.path.join(install_dir, 'bin', lib_name) + install_file(lib_path, lib_install) + + +def install(jobs, arch, host, install_dir): """Installs binutils.""" check_call(['make', 'install-strip', '-j', str(jobs)]) + if host in ('win', 'win64'): + arch_install_dir = os.path.join( + install_dir, ndk.abis.arch_to_triple(arch)) + install_winpthreads(host == 'win', install_dir) + install_winpthreads(host == 'win', arch_install_dir) + def dist(dist_dir, base_dir, package_name): """Packages binutils for distribution.""" @@ -237,7 +259,7 @@ def main(): install_timer = ndk.timer.Timer() with install_timer: - install(args.jobs) + install(args.jobs, args.arch, args.host, install_dir) finally: chdir(orig_dir) |