Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: toolchain_build/toolchain_build_pnacl.py

Issue 867403003: Adding le32-nacl build of pnacl tools. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: more Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 def TripleIsX8664(t): 135 def TripleIsX8664(t):
136 return fnmatch.fnmatch(t, 'x86_64*') 136 return fnmatch.fnmatch(t, 'x86_64*')
137 137
138 138
139 # Return a tuple (C compiler, C++ compiler) of the compilers to compile the host 139 # Return a tuple (C compiler, C++ compiler) of the compilers to compile the host
140 # toolchains 140 # toolchains
141 def CompilersForHost(host): 141 def CompilersForHost(host):
142 compiler = { 142 compiler = {
143 # For now we only do native builds for linux and mac 143 # For now we only do native builds for linux and mac
144 # treat 32-bit linux like a native build 144 # treat 32-bit linux like a native build
145 'i686-linux': (CHROME_CLANG, CHROME_CLANGXX), 145 'i686-linux': (CHROME_CLANG, CHROME_CLANGXX, 'ar', 'ranlib'),
146 'x86_64-linux': (CHROME_CLANG, CHROME_CLANGXX), 146 'x86_64-linux': (CHROME_CLANG, CHROME_CLANGXX, 'ar', 'ranlib'),
147 'x86_64-apple-darwin': (CHROME_CLANG, CHROME_CLANGXX), 147 'x86_64-apple-darwin': (CHROME_CLANG, CHROME_CLANGXX, 'ar', 'ranlib'),
148 # Windows build should work for native and cross 148 # Windows build should work for native and cross
149 'i686-w64-mingw32': ('i686-w64-mingw32-gcc', 'i686-w64-mingw32-g++'), 149 'i686-w64-mingw32': (
150 'i686-w64-mingw32-gcc', 'i686-w64-mingw32-g++', 'ar', 'ranlib'),
150 # TODO: add arm-hosted support 151 # TODO: add arm-hosted support
151 'i686-pc-cygwin': ('gcc', 'g++'), 152 'i686-pc-cygwin': ('gcc', 'g++', 'ar', 'ranlib'),
152 } 153 }
154 if host == 'le32-nacl':
155 nacl_sdk = os.environ.get('NACL_SDK_ROOT')
156 assert nacl_sdk, 'NACL_SDK_ROOT not set'
157 pnacl_bin_dir = os.path.join(nacl_sdk, 'toolchain/linux_pnacl/bin')
158 glibc_bin_dir = os.path.join(nacl_sdk, 'toolchain/linux_x86_glibc/bin')
159 compiler.update({
160 'le32-nacl': (os.path.join(pnacl_bin_dir, 'pnacl-clang'),
161 os.path.join(pnacl_bin_dir, 'pnacl-clang++'),
162 os.path.join(pnacl_bin_dir, 'pnacl-ar'),
163 os.path.join(pnacl_bin_dir, 'pnacl-ranlib')),
164 })
153 return compiler[host] 165 return compiler[host]
154 166
155 167
156 def GSDJoin(*args): 168 def GSDJoin(*args):
157 return '_'.join([pynacl.gsd_storage.LegalizeName(arg) for arg in args]) 169 return '_'.join([pynacl.gsd_storage.LegalizeName(arg) for arg in args])
158 170
159 171
160 def ConfigureHostArchFlags(host, extra_cflags, options): 172 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None):
161 """ Return flags passed to LLVM and binutils configure for compilers and 173 """ Return flags passed to LLVM and binutils configure for compilers and
162 compile flags. """ 174 compile flags. """
163 configure_args = [] 175 configure_args = []
164 extra_cc_args = [] 176 extra_cc_args = []
165 177
178 configure_args += options.extra_configure_args
179 if extra_configure is not None:
180 configure_args += extra_configure
181 if options.extra_cc_args is not None:
182 extra_cc_args += [options.extra_cc_args]
183
166 native = pynacl.platform.PlatformTriple() 184 native = pynacl.platform.PlatformTriple()
167 is_cross = host != native 185 is_cross = host != native
168 if is_cross: 186 if is_cross:
169 if (pynacl.platform.IsLinux64() and 187 if (pynacl.platform.IsLinux64() and
170 fnmatch.fnmatch(host, '*-linux*')): 188 fnmatch.fnmatch(host, '*-linux*')):
171 # 64 bit linux can build 32 bit linux binaries while still being a native 189 # 64 bit linux can build 32 bit linux binaries while still being a native
172 # build for our purposes. But it's not what config.guess will yield, so 190 # build for our purposes. But it's not what config.guess will yield, so
173 # use --build to force it and make sure things build correctly. 191 # use --build to force it and make sure things build correctly.
174 configure_args.append('--build=' + host) 192 configure_args.append('--build=' + host)
175 else: 193 else:
176 configure_args.append('--host=' + host) 194 configure_args.append('--host=' + host)
177 if TripleIsLinux(host) and not TripleIsX8664(host): 195 if TripleIsLinux(host) and not TripleIsX8664(host):
178 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux. 196 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux.
179 extra_cc_args = ['-m32'] 197 extra_cc_args += ['-m32']
180 198
181 extra_cxx_args = list(extra_cc_args) 199 extra_cxx_args = list(extra_cc_args)
182 200
183 if not options.gcc: 201 if not options.gcc:
184 cc, cxx = CompilersForHost(host) 202 cc, cxx, ar, ranlib = CompilersForHost(host)
185 203
186 configure_args.append('CC=' + ' '.join([cc] + extra_cc_args)) 204 configure_args.append('CC=' + ' '.join([cc] + extra_cc_args))
187 configure_args.append('CXX=' + ' '.join([cxx] + extra_cxx_args)) 205 configure_args.append('CXX=' + ' '.join([cxx] + extra_cxx_args))
206 configure_args.append('AR=' + ar)
207 configure_args.append('RANLIB=' + ranlib)
188 208
189 if TripleIsWindows(host): 209 if TripleIsWindows(host):
190 # The i18n support brings in runtime dependencies on MinGW DLLs 210 # The i18n support brings in runtime dependencies on MinGW DLLs
191 # that we don't want to have to distribute alongside our binaries. 211 # that we don't want to have to distribute alongside our binaries.
192 # So just disable it, and compiler messages will always be in US English. 212 # So just disable it, and compiler messages will always be in US English.
193 configure_args.append('--disable-nls') 213 configure_args.append('--disable-nls')
194 configure_args.extend(['LDFLAGS=-L%(abs_libdl)s -ldl', 214 configure_args.extend(['LDFLAGS=-L%(abs_libdl)s -ldl',
195 'CFLAGS=-isystem %(abs_libdl)s', 215 'CFLAGS=-isystem %(abs_libdl)s',
196 'CXXFLAGS=-isystem %(abs_libdl)s']) 216 'CXXFLAGS=-isystem %(abs_libdl)s'])
197 if is_cross: 217 if is_cross:
198 # LLVM's linux->mingw cross build needs this 218 # LLVM's linux->mingw cross build needs this
199 configure_args.append('CC_FOR_BUILD=gcc') 219 configure_args.append('CC_FOR_BUILD=gcc')
200 else: 220 else:
201 if TripleIsMac(host): 221 if TripleIsMac(host):
202 # This is required for building with recent libc++ against OSX 10.6 222 # This is required for building with recent libc++ against OSX 10.6
203 extra_cflags.append('-U__STRICT_ANSI__') 223 extra_cflags.append('-U__STRICT_ANSI__')
204 if options.gcc: 224 if options.gcc or host == 'le32-nacl':
205 configure_args.extend(['CFLAGS=' + ' '.join(extra_cflags), 225 configure_args.extend(['CFLAGS=' + ' '.join(extra_cflags),
206 'CXXFLAGS=' + ' '.join(extra_cflags)]) 226 'CXXFLAGS=' + ' '.join(extra_cflags)])
207 else: 227 else:
208 configure_args.extend( 228 configure_args.extend(
209 ['CFLAGS=' + ' '.join(extra_cflags), 229 ['CFLAGS=' + ' '.join(extra_cflags),
210 'LDFLAGS=-L%(' + GSDJoin('abs_libcxx', host) + ')s/lib', 230 'LDFLAGS=-L%(' + GSDJoin('abs_libcxx', host) + ')s/lib',
211 'CXXFLAGS=-stdlib=libc++ -I%(' + GSDJoin('abs_libcxx', host) + 231 'CXXFLAGS=-stdlib=libc++ -I%(' + GSDJoin('abs_libcxx', host) +
212 ')s/include/c++/v1 ' + ' '.join(extra_cflags)]) 232 ')s/include/c++/v1 ' + ' '.join(extra_cflags)])
213 233
214 return configure_args 234 return configure_args
215 235
216 236
217 def LibCxxHostArchFlags(host): 237 def LibCxxHostArchFlags(host):
218 cc, cxx = CompilersForHost(host) 238 cc, cxx, _, _ = CompilersForHost(host)
219 cmake_flags = [] 239 cmake_flags = []
220 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) 240 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx])
221 if TripleIsLinux(host) and not TripleIsX8664(host): 241 if TripleIsLinux(host) and not TripleIsX8664(host):
222 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux 242 # Chrome clang defaults to 64-bit builds, even when run on 32-bit Linux
223 cmake_flags.extend(['-DCMAKE_C_FLAGS=-m32', 243 cmake_flags.extend(['-DCMAKE_C_FLAGS=-m32',
224 '-DCMAKE_CXX_FLAGS=-m32']) 244 '-DCMAKE_CXX_FLAGS=-m32'])
225 return cmake_flags 245 return cmake_flags
226 246
227 def CmakeHostArchFlags(host, options): 247 def CmakeHostArchFlags(host, options):
228 """ Set flags passed to LLVM cmake for compilers and compile flags. """ 248 """ Set flags passed to LLVM cmake for compilers and compile flags. """
229 cmake_flags = [] 249 cmake_flags = []
230 cc, cxx = CompilersForHost(host) 250 cc, cxx, _, _ = CompilersForHost(host)
231 251
232 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) 252 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx])
233 253
234 # There seems to be a bug in chrome clang where it exposes the msan interface 254 # There seems to be a bug in chrome clang where it exposes the msan interface
235 # (even when compiling without msan) but then does not link with an 255 # (even when compiling without msan) but then does not link with an
236 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory 256 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory
237 # undefined. 257 # undefined.
238 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE') 258 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE')
239 259
240 if options.sanitize: 260 if options.sanitize:
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 if TripleIsLinux(host): 404 if TripleIsLinux(host):
385 libname = 'libc++.so.1' 405 libname = 'libc++.so.1'
386 elif TripleIsMac(host): 406 elif TripleIsMac(host):
387 libname = 'libc++.1.dylib' 407 libname = 'libc++.1.dylib'
388 else: 408 else:
389 return [] 409 return []
390 return [command.Mkdir(dest, parents=True), 410 return [command.Mkdir(dest, parents=True),
391 command.Copy('%(' + GSDJoin('abs_libcxx', host) +')s/lib/' + libname, 411 command.Copy('%(' + GSDJoin('abs_libcxx', host) +')s/lib/' + libname,
392 os.path.join(dest, libname))] 412 os.path.join(dest, libname))]
393 413
394 def CreateSymLinksToDirectToNaClTools(): 414 def CreateSymLinksToDirectToNaClTools(host):
415 if host == 'le32-nacl':
416 return []
395 return ( 417 return (
396 [command.Command(['ln', '-f', 418 [command.Command(['ln', '-f',
397 command.path.join('%(output)s', 'bin','clang'), 419 command.path.join('%(output)s', 'bin','clang'),
398 command.path.join('%(output)s', 'bin', 420 command.path.join('%(output)s', 'bin',
399 arch + '-nacl-clang')]) 421 arch + '-nacl-clang')])
400 for arch in DIRECT_TO_NACL_ARCHES] + 422 for arch in DIRECT_TO_NACL_ARCHES] +
401 [command.Command(['ln', '-f', 423 [command.Command(['ln', '-f',
402 command.path.join('%(output)s', 'bin','clang'), 424 command.path.join('%(output)s', 'bin','clang'),
403 command.path.join('%(output)s', 'bin', 425 command.path.join('%(output)s', 'bin',
404 arch + '-nacl-clang++')]) 426 arch + '-nacl-clang++')])
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 def HostTools(host, options): 485 def HostTools(host, options):
464 def H(component_name): 486 def H(component_name):
465 # Return a package name for a component name with a host triple. 487 # Return a package name for a component name with a host triple.
466 return GSDJoin(component_name, host) 488 return GSDJoin(component_name, host)
467 # Return the file name with the appropriate suffix for an executable file. 489 # Return the file name with the appropriate suffix for an executable file.
468 def Exe(file): 490 def Exe(file):
469 if TripleIsWindows(host): 491 if TripleIsWindows(host):
470 return file + '.exe' 492 return file + '.exe'
471 else: 493 else:
472 return file 494 return file
495
496 werror = []
497 extra_gold_deps = []
498 if host == 'le32-nacl':
499 # TODO(bradnelson): Fix warnings so this can go away.
500 werror = ['--enable-werror=no']
501 extra_gold_deps = [H('llvm')]
502
473 # Binutils still has some warnings when building with clang 503 # Binutils still has some warnings when building with clang
474 if not options.gcc: 504 if not options.gcc:
475 warning_flags = ['-Wno-extended-offsetof', '-Wno-absolute-value', 505 warning_flags = ['-Wno-extended-offsetof', '-Wno-absolute-value',
476 '-Wno-unused-function', '-Wno-unused-const-variable', 506 '-Wno-unused-function', '-Wno-unused-const-variable',
477 '-Wno-unneeded-internal-declaration', 507 '-Wno-unneeded-internal-declaration',
478 '-Wno-unused-private-field', '-Wno-format-security'] 508 '-Wno-unused-private-field', '-Wno-format-security']
479 else: 509 else:
480 warning_flags = ['-Wno-unused-function', '-Wno-unused-value'] 510 warning_flags = ['-Wno-unused-function', '-Wno-unused-value']
511
481 tools = { 512 tools = {
482 # The binutils_pnacl package is used both for bitcode linking (gold) and 513 # The binutils_pnacl package is used both for bitcode linking (gold) and
483 # for its conventional use with arm-nacl-clang. 514 # for its conventional use with arm-nacl-clang.
484 H('binutils_pnacl'): { 515 H('binutils_pnacl'): {
485 'dependencies': ['binutils_pnacl_src'], 516 'dependencies': ['binutils_pnacl_src'] + extra_gold_deps,
486 'type': 'build', 517 'type': 'build',
487 'inputs' : { 'macros': os.path.join(NACL_DIR, 518 'inputs' : { 'macros': os.path.join(NACL_DIR,
488 'pnacl', 'support', 'clang_direct', 'nacl-arm-macros.s')}, 519 'pnacl', 'support', 'clang_direct', 'nacl-arm-macros.s')},
489 'commands': [ 520 'commands': [
490 command.SkipForIncrementalCommand([ 521 command.SkipForIncrementalCommand([
491 'sh', 522 'sh',
492 '%(binutils_pnacl_src)s/configure'] + 523 '%(binutils_pnacl_src)s/configure'] +
493 ConfigureBinutilsCommon() + 524 ConfigureBinutilsCommon() +
494 ConfigureHostArchFlags(host, warning_flags, options) + 525 ConfigureHostArchFlags(
526 host, warning_flags, options,
527 options.binutils_pnacl_extra_configure) +
495 ['--target=arm-nacl', 528 ['--target=arm-nacl',
496 '--program-prefix=le32-nacl-', 529 '--program-prefix=le32-nacl-',
497 '--enable-targets=arm-nacl,i686-nacl,x86_64-nacl,' + 530 '--enable-targets=arm-nacl,i686-nacl,x86_64-nacl,' +
498 'mipsel-nacl', 531 'mipsel-nacl',
499 '--enable-shared=no', 532 '--enable-shared=no',
500 '--enable-gold=default', 533 '--enable-gold=default',
501 '--enable-plugins', 534 '--enable-plugins',
502 '--without-gas', 535 '--without-gas',
503 '--with-sysroot=/le32-nacl']), 536 '--with-sysroot=/le32-nacl'] + werror),
504 command.Command(MakeCommand(host)), 537 command.Command(MakeCommand(host)),
505 command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] + 538 command.Command(MAKE_DESTDIR_CMD + ['install-strip'])] +
506 [command.RemoveDirectory(os.path.join('%(output)s', dir)) 539 [command.RemoveDirectory(os.path.join('%(output)s', dir))
507 for dir in ('lib', 'lib32')] + 540 for dir in ('lib', 'lib32')] +
508 # Since it has dual use, just create links for both sets of names 541 # Since it has dual use, just create links for both sets of names
509 # (i.e. le32-nacl-foo and arm-nacl-foo) 542 # (i.e. le32-nacl-foo and arm-nacl-foo)
510 # TODO(dschuff): Use the redirector scripts here like binutils_x86 543 # TODO(dschuff): Use the redirector scripts here like binutils_x86
511 [command.Command([ 544 [command.Command([
512 'ln', '-f', 545 'ln', '-f',
513 command.path.join('%(output)s', 'bin', 'le32-nacl-' + tool), 546 command.path.join('%(output)s', 'bin', 'le32-nacl-' + tool),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 '-DLLVM_ENABLE_ASSERTIONS=ON', 591 '-DLLVM_ENABLE_ASSERTIONS=ON',
559 '-DLLVM_ENABLE_ZLIB=OFF', 592 '-DLLVM_ENABLE_ZLIB=OFF',
560 '-DLLVM_BUILD_TESTS=ON', 593 '-DLLVM_BUILD_TESTS=ON',
561 '-DLLVM_APPEND_VC_REV=ON', 594 '-DLLVM_APPEND_VC_REV=ON',
562 '-DLLVM_BINUTILS_INCDIR=%(abs_binutils_pnacl_src)s/include', 595 '-DLLVM_BINUTILS_INCDIR=%(abs_binutils_pnacl_src)s/include',
563 '-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=%(clang_src)s', 596 '-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=%(clang_src)s',
564 '%(llvm_src)s']), 597 '%(llvm_src)s']),
565 command.Command(['ninja', '-v']), 598 command.Command(['ninja', '-v']),
566 command.Command(['ninja', 'install']), 599 command.Command(['ninja', 'install']),
567 ] + 600 ] +
568 CreateSymLinksToDirectToNaClTools() 601 CreateSymLinksToDirectToNaClTools(host)
569 }, 602 },
570 } 603 }
604 cleanup_static_libs = []
605 shared = []
606 if host != 'le32-nacl':
607 shared = ['--enable-shared']
608 cleanup_static_libs = [
609 command.Remove(*[os.path.join('%(output)s', 'lib', f) for f
610 in '*.a', '*Hello.*', 'BugpointPasses.*']),
611 ]
571 llvm_autoconf = { 612 llvm_autoconf = {
572 H('llvm'): { 613 H('llvm'): {
573 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src', 614 'dependencies': ['clang_src', 'llvm_src', 'binutils_pnacl_src',
574 'subzero_src'], 615 'subzero_src'],
575 'type': 'build', 616 'type': 'build',
576 'commands': [ 617 'commands': [
577 command.SkipForIncrementalCommand([ 618 command.SkipForIncrementalCommand([
578 'sh', 619 'sh',
579 '%(llvm_src)s/configure'] + 620 '%(llvm_src)s/configure'] +
580 ConfigureHostArchFlags(host, [], options) + 621 ConfigureHostArchFlags(host, [], options) +
581 LLVMConfigureAssertionsFlags(options) + 622 LLVMConfigureAssertionsFlags(options) +
582 ['--prefix=/', 623 ['--prefix=/',
583 '--enable-shared',
584 '--disable-zlib', 624 '--disable-zlib',
585 '--disable-terminfo', 625 '--disable-terminfo',
586 '--disable-jit', 626 '--disable-jit',
587 '--disable-bindings', # ocaml is currently the only binding. 627 '--disable-bindings', # ocaml is currently the only binding.
588 '--with-binutils-include=%(abs_binutils_pnacl_src)s/include', 628 '--with-binutils-include=%(abs_binutils_pnacl_src)s/include',
589 '--enable-targets=x86,arm,mips', 629 '--enable-targets=x86,arm,mips',
590 '--program-prefix=', 630 '--program-prefix=',
591 '--enable-optimized', 631 '--enable-optimized',
592 '--with-clang-srcdir=%(abs_clang_src)s'])] + 632 '--with-clang-srcdir=%(abs_clang_src)s'] + shared)] +
593 CopyHostLibcxxForLLVMBuild( 633 CopyHostLibcxxForLLVMBuild(
594 host, 634 host,
595 os.path.join('Release+Asserts', 'lib'), 635 os.path.join('Release+Asserts', 'lib'),
596 options) + 636 options) +
597 [command.Command(MakeCommand(host) + [ 637 [command.Command(MakeCommand(host) + [
598 'VERBOSE=1', 638 'VERBOSE=1',
599 'NACL_SANDBOX=0', 639 'NACL_SANDBOX=0',
640 'PNACL_BROWSER_TRANSLATOR=0',
600 'SUBZERO_SRC_ROOT=%(abs_subzero_src)s', 641 'SUBZERO_SRC_ROOT=%(abs_subzero_src)s',
601 'all']), 642 'all']),
602 command.Command(MAKE_DESTDIR_CMD + ['install']), 643 command.Command(MAKE_DESTDIR_CMD + ['install'])] +
603 command.Remove(*[os.path.join('%(output)s', 'lib', f) for f in 644 cleanup_static_libs + [
604 '*.a', '*Hello.*', 'BugpointPasses.*']),
605 command.Remove(*[os.path.join('%(output)s', 'bin', f) for f in 645 command.Remove(*[os.path.join('%(output)s', 'bin', f) for f in
606 Exe('clang-format'), Exe('clang-check'), 646 Exe('clang-format'), Exe('clang-check'),
607 Exe('c-index-test'), Exe('clang-tblgen'), 647 Exe('c-index-test'), Exe('clang-tblgen'),
608 Exe('llvm-tblgen')])] + 648 Exe('llvm-tblgen')])] +
609 CreateSymLinksToDirectToNaClTools() + 649 CreateSymLinksToDirectToNaClTools(host) +
610 CopyWindowsHostLibs(host), 650 CopyWindowsHostLibs(host),
611 }, 651 },
612 } 652 }
613 if options.cmake: 653 if options.cmake:
614 tools.update(llvm_cmake) 654 tools.update(llvm_cmake)
615 else: 655 else:
616 tools.update(llvm_autoconf) 656 tools.update(llvm_autoconf)
617 if TripleIsWindows(host): 657 if TripleIsWindows(host):
618 tools[H('binutils_pnacl')]['dependencies'].append('libdl') 658 tools[H('binutils_pnacl')]['dependencies'].append('libdl')
619 tools[H('llvm')]['dependencies'].append('libdl') 659 tools[H('llvm')]['dependencies'].append('libdl')
620 elif not options.gcc: 660 elif not options.gcc and host != 'le32-nacl':
621 tools[H('binutils_pnacl')]['dependencies'].append(H('libcxx')) 661 tools[H('binutils_pnacl')]['dependencies'].append(H('libcxx'))
622 tools[H('llvm')]['dependencies'].append(H('libcxx')) 662 tools[H('llvm')]['dependencies'].append(H('libcxx'))
623 return tools 663 return tools
624 664
625 665
626 def TargetLibCompiler(host, options): 666 def TargetLibCompiler(host, options):
627 def H(component_name): 667 def H(component_name):
628 return GSDJoin(component_name, host) 668 return GSDJoin(component_name, host)
629 compiler = { 669 compiler = {
630 # Because target_lib_compiler is not a memoized target, its name doesn't 670 # Because target_lib_compiler is not a memoized target, its name doesn't
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 724
685 tools = {} 725 tools = {}
686 726
687 if TripleIsWindows(host): 727 if TripleIsWindows(host):
688 redirector_table = '' 728 redirector_table = ''
689 for tool, args in TOOL_X64_I686_REDIRECTS: 729 for tool, args in TOOL_X64_I686_REDIRECTS:
690 redirector_table += ' {L"/bin/i686-nacl-%s.exe",' % tool + \ 730 redirector_table += ' {L"/bin/i686-nacl-%s.exe",' % tool + \
691 ' L"/bin/x86_64-nacl-%s.exe",' % tool + \ 731 ' L"/bin/x86_64-nacl-%s.exe",' % tool + \
692 ' L"%s"},\n' % args 732 ' L"%s"},\n' % args
693 733
694 cc, cxx = CompilersForHost(host) 734 cc, cxx, _, _ = CompilersForHost(host)
695 tools.update({ 735 tools.update({
696 'redirector': { 736 'redirector': {
697 'type': 'build', 737 'type': 'build',
698 'inputs': { 'source_directory': REDIRECTOR_WIN32_SRC }, 738 'inputs': { 'source_directory': REDIRECTOR_WIN32_SRC },
699 'commands': [ 739 'commands': [
700 command.WriteData(redirector_table, 740 command.WriteData(redirector_table,
701 'redirector_table_pnacl.txt'), 741 'redirector_table_pnacl.txt'),
702 command.Command([cc, '-O3', '-std=c99', '-I.', '-o', 742 command.Command([cc, '-O3', '-std=c99', '-I.', '-o',
703 os.path.join('%(output)s', 'redirector.exe'), 743 os.path.join('%(output)s', 'redirector.exe'),
704 '-I', os.path.dirname(NACL_DIR), 744 '-I', os.path.dirname(NACL_DIR),
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 parser.add_argument('--gcc', action='store_true', default=False, 981 parser.add_argument('--gcc', action='store_true', default=False,
942 help="Use the default compiler 'cc' instead of clang") 982 help="Use the default compiler 'cc' instead of clang")
943 parser.add_argument('--sanitize', choices=['address', 'thread', 'memory', 983 parser.add_argument('--sanitize', choices=['address', 'thread', 'memory',
944 'undefined'], 984 'undefined'],
945 help="Use a sanitizer with LLVM's clang cmake build") 985 help="Use a sanitizer with LLVM's clang cmake build")
946 parser.add_argument('--testsuite-sync', action='store_true', default=False, 986 parser.add_argument('--testsuite-sync', action='store_true', default=False,
947 help=('Sync the sources for the LLVM testsuite. ' 987 help=('Sync the sources for the LLVM testsuite. '
948 'Only useful if --sync/ is also enabled')) 988 'Only useful if --sync/ is also enabled'))
949 parser.add_argument('--build-sbtc', action='store_true', default=False, 989 parser.add_argument('--build-sbtc', action='store_true', default=False,
950 help='Build the sandboxed translators') 990 help='Build the sandboxed translators')
991 parser.add_argument('--pnacl-in-pnacl', action='store_true', default=False,
992 help='Build with a PNaCl toolchain')
993 parser.add_argument('--extra-cc-args', default=None,
994 help='Extra arguments to pass to cc/cxx')
995 parser.add_argument('--extra-configure-arg', dest='extra_configure_args',
996 default=[], action='append',
997 help='Extra arguments to pass pass to host configure')
998 parser.add_argument('--binutils-pnacl-extra-configure',
999 default=[], action='append',
1000 help='Extra binutils-pnacl arguments '
1001 'to pass pass to host configure')
951 args, leftover_args = parser.parse_known_args() 1002 args, leftover_args = parser.parse_known_args()
952 if '-h' in leftover_args or '--help' in leftover_args: 1003 if '-h' in leftover_args or '--help' in leftover_args:
953 print 'The following arguments are specific to toolchain_build_pnacl.py:' 1004 print 'The following arguments are specific to toolchain_build_pnacl.py:'
954 parser.print_help() 1005 parser.print_help()
955 print 'The rest of the arguments are generic, in toolchain_main.py' 1006 print 'The rest of the arguments are generic, in toolchain_main.py'
956 1007
957 if args.sanitize and not args.cmake: 1008 if args.sanitize and not args.cmake:
958 print 'Use of sanitizers requires a cmake build' 1009 print 'Use of sanitizers requires a cmake build'
959 sys.exit(1) 1010 sys.exit(1)
960 1011
(...skipping 13 matching lines...) Expand all
974 leftover_args.append('--sync-only') 1025 leftover_args.append('--sync-only')
975 else: 1026 else:
976 upload_packages = GetUploadPackageTargets() 1027 upload_packages = GetUploadPackageTargets()
977 if pynacl.platform.IsWindows(): 1028 if pynacl.platform.IsWindows():
978 InstallMinGWHostCompiler() 1029 InstallMinGWHostCompiler()
979 1030
980 packages.update(HostToolsSources(GetGitSyncCmdsCallback(rev))) 1031 packages.update(HostToolsSources(GetGitSyncCmdsCallback(rev)))
981 if args.testsuite_sync: 1032 if args.testsuite_sync:
982 packages.update(TestsuiteSources(GetGitSyncCmdsCallback(rev))) 1033 packages.update(TestsuiteSources(GetGitSyncCmdsCallback(rev)))
983 1034
984 hosts = [pynacl.platform.PlatformTriple()] 1035 if args.pnacl_in_pnacl:
1036 hosts = ['le32-nacl']
1037 else:
1038 hosts = [pynacl.platform.PlatformTriple()]
985 if pynacl.platform.IsLinux() and BUILD_CROSS_MINGW: 1039 if pynacl.platform.IsLinux() and BUILD_CROSS_MINGW:
986 hosts.append(pynacl.platform.PlatformTriple('win', 'x86-32')) 1040 hosts.append(pynacl.platform.PlatformTriple('win', 'x86-32'))
987 for host in hosts: 1041 for host in hosts:
988 packages.update(HostLibs(host, args))
989 packages.update(HostTools(host, args)) 1042 packages.update(HostTools(host, args))
990 packages.update(HostToolsDirectToNacl(host)) 1043 if not args.pnacl_in_pnacl:
991 packages.update(TargetLibCompiler(pynacl.platform.PlatformTriple(), args)) 1044 packages.update(HostLibs(host, args))
1045 packages.update(HostToolsDirectToNacl(host))
1046 if not args.pnacl_in_pnacl:
1047 packages.update(TargetLibCompiler(pynacl.platform.PlatformTriple(), args))
992 # Don't build the target libs on Windows because of pathname issues. 1048 # Don't build the target libs on Windows because of pathname issues.
993 # Only the linux64 bot is canonical (i.e. it will upload its packages). 1049 # Only the linux64 bot is canonical (i.e. it will upload its packages).
994 # The other bots will use a 'work' target instead of a 'build' target for 1050 # The other bots will use a 'work' target instead of a 'build' target for
995 # the target libs, so they will not be memoized, but can be used for tests. 1051 # the target libs, so they will not be memoized, but can be used for tests.
996 # TODO(dschuff): Even better would be if we could memoize non-canonical 1052 # TODO(dschuff): Even better would be if we could memoize non-canonical
997 # build targets without doing things like mangling their names (and for e.g. 1053 # build targets without doing things like mangling their names (and for e.g.
998 # scons tests, skip running them if their dependencies haven't changed, like 1054 # scons tests, skip running them if their dependencies haven't changed, like
999 # build targets) 1055 # build targets)
1000 is_canonical = pynacl.platform.IsLinux64() 1056 is_canonical = pynacl.platform.IsLinux64()
1001 if pynacl.platform.IsLinux() or pynacl.platform.IsMac(): 1057 if ((pynacl.platform.IsLinux() or pynacl.platform.IsMac())
1058 and not args.pnacl_in_pnacl):
1002 packages.update(pnacl_targetlibs.TargetLibsSrc( 1059 packages.update(pnacl_targetlibs.TargetLibsSrc(
1003 GetGitSyncCmdsCallback(rev))) 1060 GetGitSyncCmdsCallback(rev)))
1004 for bias in BITCODE_BIASES: 1061 for bias in BITCODE_BIASES:
1005 packages.update(pnacl_targetlibs.TargetLibs(bias, is_canonical)) 1062 packages.update(pnacl_targetlibs.TargetLibs(bias, is_canonical))
1006 for arch in DIRECT_TO_NACL_ARCHES: 1063 for arch in DIRECT_TO_NACL_ARCHES:
1007 packages.update(pnacl_targetlibs.TargetLibs(arch, is_canonical)) 1064 packages.update(pnacl_targetlibs.TargetLibs(arch, is_canonical))
1008 packages.update(pnacl_targetlibs.SDKLibs(arch, is_canonical)) 1065 packages.update(pnacl_targetlibs.SDKLibs(arch, is_canonical))
1009 for arch in TRANSLATOR_ARCHES: 1066 for arch in TRANSLATOR_ARCHES:
1010 packages.update(pnacl_targetlibs.TranslatorLibs(arch, is_canonical)) 1067 packages.update(pnacl_targetlibs.TranslatorLibs(arch, is_canonical))
1011 packages.update(Metadata(rev, is_canonical)) 1068 packages.update(Metadata(rev, is_canonical))
1012 packages.update(pnacl_targetlibs.SDKCompiler( 1069 packages.update(pnacl_targetlibs.SDKCompiler(
1013 ['le32'] + DIRECT_TO_NACL_ARCHES)) 1070 ['le32'] + DIRECT_TO_NACL_ARCHES))
1014 packages.update(pnacl_targetlibs.SDKLibs('le32', is_canonical)) 1071 packages.update(pnacl_targetlibs.SDKLibs('le32', is_canonical))
1015 if pynacl.platform.IsLinux() or pynacl.platform.IsMac():
1016 unsandboxed_irt_canonical = is_canonical or pynacl.platform.IsMac() 1072 unsandboxed_irt_canonical = is_canonical or pynacl.platform.IsMac()
1017 packages.update(pnacl_targetlibs.UnsandboxedIRT( 1073 packages.update(pnacl_targetlibs.UnsandboxedIRT(
1018 'x86-32-%s' % pynacl.platform.GetOS(), unsandboxed_irt_canonical)) 1074 'x86-32-%s' % pynacl.platform.GetOS(), unsandboxed_irt_canonical))
1019 1075
1020 if args.build_sbtc: 1076 if args.build_sbtc and not args.pnacl_in_pnacl:
1021 packages.update(pnacl_sandboxed_translator.SandboxedTranslators( 1077 packages.update(pnacl_sandboxed_translator.SandboxedTranslators(
1022 SANDBOXED_TRANSLATOR_ARCHES)) 1078 SANDBOXED_TRANSLATOR_ARCHES))
1023 1079
1024 tb = toolchain_main.PackageBuilder(packages, 1080 tb = toolchain_main.PackageBuilder(packages,
1025 upload_packages, 1081 upload_packages,
1026 leftover_args) 1082 leftover_args)
1027 tb.Main() 1083 tb.Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698