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 opts.gcc or host == 'le32-nacl': | 275 if not opts.gcc and host != 'le32-nacl': |
276 result['CFLAGS'] += extra_cc_flags | 276 # On mac and linux, use libc++ instead of libstdc++ (which is too old on |
277 result['CXXFLAGS'] += extra_cc_flags | 277 # Ubuntu Precise and any OSX to build LLVM) |
278 else: | 278 result['CXXFLAGS'] += ['-stdlib=libc++'] |
279 result['CFLAGS'] += extra_cc_flags | 279 if TripleIsLinux(host): |
280 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', | 280 # Use our own libc++ on Linux |
Roland McGrath
2016/01/08 23:09:27
TODO here about using chromium-built libc++-static
Derek Schuff
2016/01/08 23:30:37
Done.
| |
281 result['CXXFLAGS'] += ['-I%(' + FlavoredName('abs_libcxx', host, opts) + | |
282 ')s/include/c++/v1'] | |
283 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', | |
281 host, opts) + ')s/lib'] | 284 host, opts) + ')s/lib'] |
282 result['CXXFLAGS'] += ([ | 285 deps.append(FlavoredName('libcxx', host, opts)) |
283 '-stdlib=libc++', | 286 |
284 '-I%(' + FlavoredName('abs_libcxx', host, opts) + ')s/include/c++/v1'] + | 287 result['CFLAGS'] += extra_cc_flags |
285 extra_cc_flags) | 288 result['CXXFLAGS'] += extra_cc_flags |
286 deps.append(FlavoredName('libcxx', host, opts)) | 289 |
287 return result, deps | 290 return result, deps |
288 | 291 |
289 | 292 |
290 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, | 293 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, |
291 use_afl_fuzz=False): | 294 use_afl_fuzz=False): |
292 """Return flags passed to LLVM and binutils configure for compilers and | 295 """Return flags passed to LLVM and binutils configure for compilers and |
293 compile flags. | 296 compile flags. |
294 | 297 |
295 Returns the tuple (flags, inputs, deps) where 'flags' is a list of | 298 Returns the tuple (flags, inputs, deps) where 'flags' is a list of |
296 arguments to configure, 'inputs' is a dict of extra inputs to be hashed, | 299 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... | |
565 'type': 'source', | 568 'type': 'source', |
566 'output_dirname': 'llvm-test-suite', | 569 'output_dirname': 'llvm-test-suite', |
567 'commands': GetGitSyncCmds('llvm-test-suite'), | 570 'commands': GetGitSyncCmds('llvm-test-suite'), |
568 }, | 571 }, |
569 } | 572 } |
570 return sources | 573 return sources |
571 | 574 |
572 | 575 |
573 def CopyHostLibcxxForLLVMBuild(host, dest, options): | 576 def CopyHostLibcxxForLLVMBuild(host, dest, options): |
574 """Copy libc++ to the working directory for build tools.""" | 577 """Copy libc++ to the working directory for build tools.""" |
575 if options.gcc: | 578 if options.gcc or not TripleIsLinux(host): |
576 return [] | 579 return [] |
577 if TripleIsLinux(host): | 580 libname = 'libc++.so.1' |
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), | 581 return [command.Mkdir(dest, parents=True), |
584 command.Copy('%(' + | 582 command.Copy('%(' + |
585 FlavoredName('abs_libcxx', host, options) +')s/lib/' + | 583 FlavoredName('abs_libcxx', host, options) +')s/lib/' + |
586 libname, os.path.join(dest, libname))] | 584 libname, os.path.join(dest, libname))] |
587 | 585 |
588 def CreateSymLinksToDirectToNaClTools(host): | 586 def CreateSymLinksToDirectToNaClTools(host): |
589 if host == 'le32-nacl': | 587 if host == 'le32-nacl': |
590 return [] | 588 return [] |
591 return ( | 589 return ( |
592 [command.Command(['ln', '-f', | 590 [command.Command(['ln', '-f', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 '-Wall', '-O3', '-fomit-frame-pointer']), | 622 '-Wall', '-O3', '-fomit-frame-pointer']), |
625 command.Command([ar, 'cru', | 623 command.Command([ar, 'cru', |
626 'libdl.a', 'dlfcn.o']), | 624 'libdl.a', 'dlfcn.o']), |
627 command.Copy('libdl.a', | 625 command.Copy('libdl.a', |
628 os.path.join('%(output)s', 'libdl.a')), | 626 os.path.join('%(output)s', 'libdl.a')), |
629 command.Copy(os.path.join('src', 'dlfcn.h'), | 627 command.Copy(os.path.join('src', 'dlfcn.h'), |
630 os.path.join('%(output)s', 'dlfcn.h')), | 628 os.path.join('%(output)s', 'dlfcn.h')), |
631 ], | 629 ], |
632 }, | 630 }, |
633 }) | 631 }) |
634 elif not options.gcc: | 632 elif TripleIsLinux(host) and not options.gcc: |
635 # Libc++ is only tested with the clang build | 633 # Our Libc++ is only needed for Precise and only tested with clang. |
636 libcxx_host_arch_flags, libcxx_inputs = LibCxxHostArchFlags(host) | 634 libcxx_host_arch_flags, libcxx_inputs = LibCxxHostArchFlags(host) |
637 libs.update({ | 635 libs.update({ |
638 H('libcxx'): { | 636 H('libcxx'): { |
639 'dependencies': ['libcxx_src', 'libcxxabi_src'], | 637 'dependencies': ['libcxx_src', 'libcxxabi_src'], |
640 'type': 'build', | 638 'type': 'build', |
641 'inputs': libcxx_inputs, | 639 'inputs': libcxx_inputs, |
642 'commands': [ | 640 'commands': [ |
643 command.SkipForIncrementalCommand([ | 641 command.SkipForIncrementalCommand([ |
644 'cmake', '-G', 'Unix Makefiles'] + | 642 'cmake', '-G', 'Unix Makefiles'] + |
645 libcxx_host_arch_flags + | 643 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')]] + [ | 941 for t in [H('llvm'), H('binutils_pnacl'), H('binutils_x86')]] + [ |
944 command.Runnable( | 942 command.Runnable( |
945 None, pnacl_commands.InstallDriverScripts, | 943 None, pnacl_commands.InstallDriverScripts, |
946 '%(driver)s', os.path.join('%(output)s', 'bin'), | 944 '%(driver)s', os.path.join('%(output)s', 'bin'), |
947 host_windows=TripleIsWindows(host) or TripleIsCygWin(host), | 945 host_windows=TripleIsWindows(host) or TripleIsCygWin(host), |
948 host_64bit=TripleIsX8664(host)) | 946 host_64bit=TripleIsX8664(host)) |
949 ] | 947 ] |
950 }, | 948 }, |
951 } | 949 } |
952 | 950 |
953 if TripleIsWindows(host) or not options.gcc: | 951 if TripleIsWindows(host) or TripleIsLinux(host) and not options.gcc: |
954 host_lib = 'libdl' if TripleIsWindows(host) else H('libcxx') | 952 host_lib = 'libdl' if TripleIsWindows(host) else H('libcxx') |
955 compiler['target_lib_compiler']['dependencies'].append(host_lib) | 953 compiler['target_lib_compiler']['dependencies'].append(host_lib) |
956 compiler['target_lib_compiler']['commands'].append( | 954 compiler['target_lib_compiler']['commands'].append( |
957 command.CopyRecursive('%(' + host_lib + ')s', '%(output)s')) | 955 command.CopyRecursive('%(' + host_lib + ')s', '%(output)s')) |
958 return compiler | 956 return compiler |
959 | 957 |
960 | 958 |
961 def Metadata(revisions, is_canonical): | 959 def Metadata(revisions, is_canonical): |
962 data = { | 960 data = { |
963 'metadata': { | 961 '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 | 1189 # package_version, we still need to output the 32-bit version of the host |
1192 # packages on that bot. | 1190 # packages on that bot. |
1193 ('linux', pynacl.platform.GetArch3264())): | 1191 ('linux', pynacl.platform.GetArch3264())): |
1194 triple = pynacl.platform.PlatformTriple(os_name, arch) | 1192 triple = pynacl.platform.PlatformTriple(os_name, arch) |
1195 legal_triple = pynacl.gsd_storage.LegalizeName(triple) | 1193 legal_triple = pynacl.gsd_storage.LegalizeName(triple) |
1196 host_packages.setdefault(os_name, []).extend( | 1194 host_packages.setdefault(os_name, []).extend( |
1197 ['binutils_pnacl_%s' % legal_triple, | 1195 ['binutils_pnacl_%s' % legal_triple, |
1198 'binutils_x86_%s' % legal_triple, | 1196 'binutils_x86_%s' % legal_triple, |
1199 'llvm_%s' % legal_triple, | 1197 'llvm_%s' % legal_triple, |
1200 'driver_%s' % legal_triple]) | 1198 'driver_%s' % legal_triple]) |
1201 if os_name != 'win': | 1199 if os_name == 'linux': |
1202 host_packages[os_name].append('libcxx_%s' % legal_triple) | 1200 host_packages[os_name].append('libcxx_%s' % legal_triple) |
1203 | 1201 |
1204 # Unsandboxed target IRT libraries | 1202 # Unsandboxed target IRT libraries |
1205 for os_name in ['linux', 'mac']: | 1203 for os_name in ['linux', 'mac']: |
1206 legal_triple = pynacl.gsd_storage.LegalizeName('x86-32-' + os_name) | 1204 legal_triple = pynacl.gsd_storage.LegalizeName('x86-32-' + os_name) |
1207 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) | 1205 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) |
1208 for os_name in ['linux']: | 1206 for os_name in ['linux']: |
1209 legal_triple = pynacl.gsd_storage.LegalizeName('arm-' + os_name) | 1207 legal_triple = pynacl.gsd_storage.LegalizeName('arm-' + os_name) |
1210 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) | 1208 host_packages[os_name].append('unsandboxed_runtime_%s' % legal_triple) |
1211 for os_name in ['linux']: | 1209 for os_name in ['linux']: |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1354 SANDBOXED_TRANSLATOR_ARCHES)) | 1352 SANDBOXED_TRANSLATOR_ARCHES)) |
1355 | 1353 |
1356 tb = toolchain_main.PackageBuilder(packages, | 1354 tb = toolchain_main.PackageBuilder(packages, |
1357 upload_packages, | 1355 upload_packages, |
1358 leftover_args) | 1356 leftover_args) |
1359 return tb.Main() | 1357 return tb.Main() |
1360 | 1358 |
1361 | 1359 |
1362 if __name__ == '__main__': | 1360 if __name__ == '__main__': |
1363 sys.exit(main()) | 1361 sys.exit(main()) |
OLD | NEW |