| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Recipes for PNaCl toolchain packages. | 6 """Recipes for PNaCl toolchain packages. |
| 7 | 7 |
| 8 Recipes consist of specially-structured dictionaries, with keys for package | 8 Recipes consist of specially-structured dictionaries, with keys for package |
| 9 name, type, commands to execute, etc. The structure is documented in the | 9 name, type, commands to execute, etc. The structure is documented in the |
| 10 PackageBuilder docstring in toolchain_main.py. | 10 PackageBuilder docstring in toolchain_main.py. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 deps = [] | 265 deps = [] |
| 266 if TripleIsWindows(host): | 266 if TripleIsWindows(host): |
| 267 result['LDFLAGS'] += ['-L%(abs_libdl)s', '-ldl'] | 267 result['LDFLAGS'] += ['-L%(abs_libdl)s', '-ldl'] |
| 268 result['CFLAGS'] += ['-isystem','%(abs_libdl)s'] | 268 result['CFLAGS'] += ['-isystem','%(abs_libdl)s'] |
| 269 result['CXXFLAGS'] += ['-isystem', '%(abs_libdl)s'] | 269 result['CXXFLAGS'] += ['-isystem', '%(abs_libdl)s'] |
| 270 deps.append('libdl') | 270 deps.append('libdl') |
| 271 else: | 271 else: |
| 272 if TripleIsLinux(host) and not TripleIsX8664(host): | 272 if TripleIsLinux(host) and not TripleIsX8664(host): |
| 273 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux. | 273 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux. |
| 274 extra_cc_flags += ['-m32'] | 274 extra_cc_flags += ['-m32'] |
| 275 if not opts.gcc and host != 'le32-nacl': | 275 if opts.gcc or host == 'le32-nacl': |
| 276 # On mac and linux, use libc++ instead of libstdc++ (which is too old on | 276 result['CFLAGS'] += extra_cc_flags |
| 277 # Ubuntu Precise and any OSX to build LLVM) | 277 result['CXXFLAGS'] += extra_cc_flags |
| 278 result['CXXFLAGS'] += ['-stdlib=libc++'] | 278 else: |
| 279 if TripleIsLinux(host): | 279 result['CFLAGS'] += extra_cc_flags |
| 280 # Use our own libc++ on Linux. | 280 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', |
| 281 # TODO(dschuff): Get the Chrome clang maintainers to build libc++ for | |
| 282 # Linux too and use that. | |
| 283 result['CXXFLAGS'] += ['-I%(' + FlavoredName('abs_libcxx', host, opts) + | |
| 284 ')s/include/c++/v1'] | |
| 285 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', | |
| 286 host, opts) + ')s/lib'] | 281 host, opts) + ')s/lib'] |
| 287 deps.append(FlavoredName('libcxx', host, opts)) | 282 result['CXXFLAGS'] += ([ |
| 288 | 283 '-stdlib=libc++', |
| 289 result['CFLAGS'] += extra_cc_flags | 284 '-I%(' + FlavoredName('abs_libcxx', host, opts) + ')s/include/c++/v1'] + |
| 290 result['CXXFLAGS'] += extra_cc_flags | 285 extra_cc_flags) |
| 291 | 286 deps.append(FlavoredName('libcxx', host, opts)) |
| 292 return result, deps | 287 return result, deps |
| 293 | 288 |
| 294 | 289 |
| 295 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, | 290 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, |
| 296 use_afl_fuzz=False): | 291 use_afl_fuzz=False): |
| 297 """Return flags passed to LLVM and binutils configure for compilers and | 292 """Return flags passed to LLVM and binutils configure for compilers and |
| 298 compile flags. | 293 compile flags. |
| 299 | 294 |
| 300 Returns the tuple (flags, inputs, deps) where 'flags' is a list of | 295 Returns the tuple (flags, inputs, deps) where 'flags' is a list of |
| 301 arguments to configure, 'inputs' is a dict of extra inputs to be hashed, | 296 arguments to configure, 'inputs' is a dict of extra inputs to be hashed, |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 'type': 'source', | 565 'type': 'source', |
| 571 'output_dirname': 'llvm-test-suite', | 566 'output_dirname': 'llvm-test-suite', |
| 572 'commands': GetGitSyncCmds('llvm-test-suite'), | 567 'commands': GetGitSyncCmds('llvm-test-suite'), |
| 573 }, | 568 }, |
| 574 } | 569 } |
| 575 return sources | 570 return sources |
| 576 | 571 |
| 577 | 572 |
| 578 def CopyHostLibcxxForLLVMBuild(host, dest, options): | 573 def CopyHostLibcxxForLLVMBuild(host, dest, options): |
| 579 """Copy libc++ to the working directory for build tools.""" | 574 """Copy libc++ to the working directory for build tools.""" |
| 580 if options.gcc or not TripleIsLinux(host): | 575 if options.gcc: |
| 581 return [] | 576 return [] |
| 582 libname = 'libc++.so.1' | 577 if TripleIsLinux(host): |
| 578 libname = 'libc++.so.1' |
| 579 elif TripleIsMac(host): |
| 580 libname = 'libc++.1.dylib' |
| 581 else: |
| 582 return [] |
| 583 return [command.Mkdir(dest, parents=True), | 583 return [command.Mkdir(dest, parents=True), |
| 584 command.Copy('%(' + | 584 command.Copy('%(' + |
| 585 FlavoredName('abs_libcxx', host, options) +')s/lib/' + | 585 FlavoredName('abs_libcxx', host, options) +')s/lib/' + |
| 586 libname, os.path.join(dest, libname))] | 586 libname, os.path.join(dest, libname))] |
| 587 | 587 |
| 588 def CreateSymLinksToDirectToNaClTools(host): | 588 def CreateSymLinksToDirectToNaClTools(host): |
| 589 if host == 'le32-nacl': | 589 if host == 'le32-nacl': |
| 590 return [] | 590 return [] |
| 591 return ( | 591 return ( |
| 592 [command.Command(['ln', '-f', | 592 [command.Command(['ln', '-f', |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 '-Wall', '-O3', '-fomit-frame-pointer']), | 624 '-Wall', '-O3', '-fomit-frame-pointer']), |
| 625 command.Command([ar, 'cru', | 625 command.Command([ar, 'cru', |
| 626 'libdl.a', 'dlfcn.o']), | 626 'libdl.a', 'dlfcn.o']), |
| 627 command.Copy('libdl.a', | 627 command.Copy('libdl.a', |
| 628 os.path.join('%(output)s', 'libdl.a')), | 628 os.path.join('%(output)s', 'libdl.a')), |
| 629 command.Copy(os.path.join('src', 'dlfcn.h'), | 629 command.Copy(os.path.join('src', 'dlfcn.h'), |
| 630 os.path.join('%(output)s', 'dlfcn.h')), | 630 os.path.join('%(output)s', 'dlfcn.h')), |
| 631 ], | 631 ], |
| 632 }, | 632 }, |
| 633 }) | 633 }) |
| 634 elif TripleIsLinux(host) and not options.gcc: | 634 elif not options.gcc: |
| 635 # Our Libc++ is only needed for Precise and only tested with clang. | 635 # Libc++ is only tested with the clang build |
| 636 libcxx_host_arch_flags, libcxx_inputs = LibCxxHostArchFlags(host) | 636 libcxx_host_arch_flags, libcxx_inputs = LibCxxHostArchFlags(host) |
| 637 libs.update({ | 637 libs.update({ |
| 638 H('libcxx'): { | 638 H('libcxx'): { |
| 639 'dependencies': ['libcxx_src', 'libcxxabi_src'], | 639 'dependencies': ['libcxx_src', 'libcxxabi_src'], |
| 640 'type': 'build', | 640 'type': 'build', |
| 641 'inputs': libcxx_inputs, | 641 'inputs': libcxx_inputs, |
| 642 'commands': [ | 642 'commands': [ |
| 643 command.SkipForIncrementalCommand([ | 643 command.SkipForIncrementalCommand([ |
| 644 'cmake', '-G', 'Unix Makefiles'] + | 644 'cmake', '-G', 'Unix Makefiles'] + |
| 645 libcxx_host_arch_flags + | 645 libcxx_host_arch_flags + |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 for t in [H('llvm'), H('binutils_pnacl'), H('binutils_x86')]] + [ | 943 for t in [H('llvm'), H('binutils_pnacl'), H('binutils_x86')]] + [ |
| 944 command.Runnable( | 944 command.Runnable( |
| 945 None, pnacl_commands.InstallDriverScripts, | 945 None, pnacl_commands.InstallDriverScripts, |
| 946 '%(driver)s', os.path.join('%(output)s', 'bin'), | 946 '%(driver)s', os.path.join('%(output)s', 'bin'), |
| 947 host_windows=TripleIsWindows(host) or TripleIsCygWin(host), | 947 host_windows=TripleIsWindows(host) or TripleIsCygWin(host), |
| 948 host_64bit=TripleIsX8664(host)) | 948 host_64bit=TripleIsX8664(host)) |
| 949 ] | 949 ] |
| 950 }, | 950 }, |
| 951 } | 951 } |
| 952 | 952 |
| 953 if TripleIsWindows(host) or TripleIsLinux(host) and not options.gcc: | 953 if TripleIsWindows(host) or not options.gcc: |
| 954 host_lib = 'libdl' if TripleIsWindows(host) else H('libcxx') | 954 host_lib = 'libdl' if TripleIsWindows(host) else H('libcxx') |
| 955 compiler['target_lib_compiler']['dependencies'].append(host_lib) | 955 compiler['target_lib_compiler']['dependencies'].append(host_lib) |
| 956 compiler['target_lib_compiler']['commands'].append( | 956 compiler['target_lib_compiler']['commands'].append( |
| 957 command.CopyRecursive('%(' + host_lib + ')s', '%(output)s')) | 957 command.CopyRecursive('%(' + host_lib + ')s', '%(output)s')) |
| 958 return compiler | 958 return compiler |
| 959 | 959 |
| 960 | 960 |
| 961 def Metadata(revisions, is_canonical): | 961 def Metadata(revisions, is_canonical): |
| 962 data = { | 962 data = { |
| 963 'metadata': { | 963 'metadata': { |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 # package_version, we still need to output the 32-bit version of the host | 1191 # package_version, we still need to output the 32-bit version of the host |
| 1192 # packages on that bot. | 1192 # packages on that bot. |
| 1193 ('linux', pynacl.platform.GetArch3264())): | 1193 ('linux', pynacl.platform.GetArch3264())): |
| 1194 triple = pynacl.platform.PlatformTriple(os_name, arch) | 1194 triple = pynacl.platform.PlatformTriple(os_name, arch) |
| 1195 legal_triple = pynacl.gsd_storage.LegalizeName(triple) | 1195 legal_triple = pynacl.gsd_storage.LegalizeName(triple) |
| 1196 host_packages.setdefault(os_name, []).extend( | 1196 host_packages.setdefault(os_name, []).extend( |
| 1197 ['binutils_pnacl_%s' % legal_triple, | 1197 ['binutils_pnacl_%s' % legal_triple, |
| 1198 'binutils_x86_%s' % legal_triple, | 1198 'binutils_x86_%s' % legal_triple, |
| 1199 'llvm_%s' % legal_triple, | 1199 'llvm_%s' % legal_triple, |
| 1200 'driver_%s' % legal_triple]) | 1200 'driver_%s' % legal_triple]) |
| 1201 if os_name == 'linux': | 1201 if os_name != 'win': |
| 1202 host_packages[os_name].append('libcxx_%s' % legal_triple) | 1202 host_packages[os_name].append('libcxx_%s' % legal_triple) |
| 1203 | 1203 |
| 1204 # Unsandboxed target IRT libraries | 1204 # Unsandboxed target IRT libraries |
| 1205 for os_name in ['linux', 'mac']: | 1205 for os_name in ['linux', 'mac']: |
| 1206 legal_triple = pynacl.gsd_storage.LegalizeName('x86-32-' + os_name) | 1206 legal_triple = pynacl.gsd_storage.LegalizeName('x86-32-' + os_name) |
| 1207 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) | 1207 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) |
| 1208 for os_name in ['linux']: | 1208 for os_name in ['linux']: |
| 1209 legal_triple = pynacl.gsd_storage.LegalizeName('arm-' + os_name) | 1209 legal_triple = pynacl.gsd_storage.LegalizeName('arm-' + os_name) |
| 1210 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) | 1210 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) |
| 1211 for os_name in ['linux']: | 1211 for os_name in ['linux']: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 SANDBOXED_TRANSLATOR_ARCHES)) | 1354 SANDBOXED_TRANSLATOR_ARCHES)) |
| 1355 | 1355 |
| 1356 tb = toolchain_main.PackageBuilder(packages, | 1356 tb = toolchain_main.PackageBuilder(packages, |
| 1357 upload_packages, | 1357 upload_packages, |
| 1358 leftover_args) | 1358 leftover_args) |
| 1359 return tb.Main() | 1359 return tb.Main() |
| 1360 | 1360 |
| 1361 | 1361 |
| 1362 if __name__ == '__main__': | 1362 if __name__ == '__main__': |
| 1363 sys.exit(main()) | 1363 sys.exit(main()) |
| OLD | NEW |