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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 BUILD_CROSS_MINGW = False | 86 BUILD_CROSS_MINGW = False |
87 # Path to the mingw cross-compiler libs on Ubuntu | 87 # Path to the mingw cross-compiler libs on Ubuntu |
88 CROSS_MINGW_LIBPATH = '/usr/lib/gcc/i686-w64-mingw32/4.6' | 88 CROSS_MINGW_LIBPATH = '/usr/lib/gcc/i686-w64-mingw32/4.6' |
89 # Path and version of the native mingw compiler to be installed on Windows hosts | 89 # Path and version of the native mingw compiler to be installed on Windows hosts |
90 MINGW_PATH = os.path.join(NACL_DIR, 'mingw32') | 90 MINGW_PATH = os.path.join(NACL_DIR, 'mingw32') |
91 MINGW_VERSION = 'i686-w64-mingw32-4.8.1' | 91 MINGW_VERSION = 'i686-w64-mingw32-4.8.1' |
92 | 92 |
93 CHROME_CLANG = os.path.join(os.path.dirname(NACL_DIR), 'third_party', | 93 CHROME_CLANG = os.path.join(os.path.dirname(NACL_DIR), 'third_party', |
94 'llvm-build', 'Release+Asserts', 'bin', 'clang') | 94 'llvm-build', 'Release+Asserts', 'bin', 'clang') |
95 CHROME_CLANGXX = CHROME_CLANG + '++' | 95 CHROME_CLANGXX = CHROME_CLANG + '++' |
96 CHROME_LIBCXX_STATIC = os.path.join(os.path.dirname(NACL_DIR), 'third_party', | |
97 'libc++-static') | |
98 | 96 |
99 # Required SDK version and target version for Mac builds. | 97 # Required SDK version and target version for Mac builds. |
100 # See MAC_SDK_FLAGS, below. | 98 # See MAC_SDK_FLAGS, below. |
101 MAC_SDK_MIN = '10.10' | 99 MAC_SDK_MIN = '10.10' |
102 MAC_DEPLOYMENT_TARGET = '10.6' | 100 MAC_DEPLOYMENT_TARGET = '10.6' |
103 | 101 |
104 # Redirectors are small shims acting like sym links with optional arguments. | 102 # Redirectors are small shims acting like sym links with optional arguments. |
105 # For mac/linux we simply use a shell script which create small redirector | 103 # For mac/linux we simply use a shell script which create small redirector |
106 # shell scripts. For windows we compile an executable which redirects to | 104 # shell scripts. For windows we compile an executable which redirects to |
107 # the target using a compiled in table. | 105 # the target using a compiled in table. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 result['CXXFLAGS'] += ['-stdlib=libc++'] | 278 result['CXXFLAGS'] += ['-stdlib=libc++'] |
281 if TripleIsLinux(host): | 279 if TripleIsLinux(host): |
282 # Use our own libc++ on Linux. | 280 # Use our own libc++ on Linux. |
283 # TODO(dschuff): Get the Chrome clang maintainers to build libc++ for | 281 # TODO(dschuff): Get the Chrome clang maintainers to build libc++ for |
284 # Linux too and use that. | 282 # Linux too and use that. |
285 result['CXXFLAGS'] += ['-I%(' + FlavoredName('abs_libcxx', host, opts) + | 283 result['CXXFLAGS'] += ['-I%(' + FlavoredName('abs_libcxx', host, opts) + |
286 ')s/include/c++/v1'] | 284 ')s/include/c++/v1'] |
287 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', | 285 result['LDFLAGS'] += ['-L%(' + FlavoredName('abs_libcxx', |
288 host, opts) + ')s/lib'] | 286 host, opts) + ')s/lib'] |
289 deps.append(FlavoredName('libcxx', host, opts)) | 287 deps.append(FlavoredName('libcxx', host, opts)) |
290 elif TripleIsMac(host): | |
291 result['LDFLAGS'] += ['-L' + CHROME_LIBCXX_STATIC] | |
292 | 288 |
293 result['CFLAGS'] += extra_cc_flags | 289 result['CFLAGS'] += extra_cc_flags |
294 result['CXXFLAGS'] += extra_cc_flags | 290 result['CXXFLAGS'] += extra_cc_flags |
295 | 291 |
296 return result, deps | 292 return result, deps |
297 | 293 |
298 | 294 |
299 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, | 295 def ConfigureHostArchFlags(host, extra_cflags, options, extra_configure=None, |
300 use_afl_fuzz=False): | 296 use_afl_fuzz=False): |
301 """Return flags passed to LLVM and binutils configure for compilers and | 297 """Return flags passed to LLVM and binutils configure for compilers and |
(...skipping 25 matching lines...) Expand all Loading... |
327 configure_args.append('--build=' + host) | 323 configure_args.append('--build=' + host) |
328 elif is_cross: | 324 elif is_cross: |
329 configure_args.append('--host=' + host) | 325 configure_args.append('--host=' + host) |
330 | 326 |
331 extra_cxx_args = list(extra_cc_args) | 327 extra_cxx_args = list(extra_cc_args) |
332 | 328 |
333 hashables = [] | 329 hashables = [] |
334 | 330 |
335 if not options.gcc: | 331 if not options.gcc: |
336 cc, cxx, ar, ranlib = CompilersForHost(host) | 332 cc, cxx, ar, ranlib = CompilersForHost(host) |
337 hashables += [cc, cxx, ar, ranlib, CHROME_LIBCXX_STATIC] | 333 hashables += [cc, cxx, ar, ranlib] |
338 | 334 |
339 # Introduce afl-fuzz compiler wrappers if needed. | 335 # Introduce afl-fuzz compiler wrappers if needed. |
340 if use_afl_fuzz: | 336 if use_afl_fuzz: |
341 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) | 337 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) |
342 | 338 |
343 if ProgramPath('ccache'): | 339 if ProgramPath('ccache'): |
344 # Set CCACHE_CPP2 envvar, to avoid an error due to a strange | 340 # Set CCACHE_CPP2 envvar, to avoid an error due to a strange |
345 # ccache/clang++ interaction. Specifically, errors about | 341 # ccache/clang++ interaction. Specifically, errors about |
346 # "argument unused during compilation". | 342 # "argument unused during compilation". |
347 os.environ['CCACHE_CPP2'] = 'yes' | 343 os.environ['CCACHE_CPP2'] = 'yes' |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 396 |
401 Returns the tuple (flags, inputs, deps) where 'flags' is a list of | 397 Returns the tuple (flags, inputs, deps) where 'flags' is a list of |
402 arguments to cmake, 'inputs' is a dict of extra inputs to be hashed, | 398 arguments to cmake, 'inputs' is a dict of extra inputs to be hashed, |
403 and 'deps' is a list of extra dependencies for a component using these flags. | 399 and 'deps' is a list of extra dependencies for a component using these flags. |
404 """ | 400 """ |
405 cmake_flags = [] | 401 cmake_flags = [] |
406 if options.afl_fuzz_dir: | 402 if options.afl_fuzz_dir: |
407 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) | 403 cc, cxx = AflFuzzCompilers(options.afl_fuzz_dir) |
408 else: | 404 else: |
409 cc, cxx, _, _ = CompilersForHost(host) | 405 cc, cxx, _, _ = CompilersForHost(host) |
410 hashables = [cc, cxx, CHROME_LIBCXX_STATIC] | 406 hashables = [cc, cxx] |
411 | 407 |
412 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) | 408 cmake_flags.extend(['-DCMAKE_C_COMPILER='+cc, '-DCMAKE_CXX_COMPILER='+cxx]) |
413 if ProgramPath('ccache'): | 409 if ProgramPath('ccache'): |
414 cmake_flags.extend(['-DSYSTEM_HAS_CCACHE=ON']) | 410 cmake_flags.extend(['-DSYSTEM_HAS_CCACHE=ON']) |
415 | 411 |
416 # There seems to be a bug in chrome clang where it exposes the msan interface | 412 # There seems to be a bug in chrome clang where it exposes the msan interface |
417 # (even when compiling without msan) but then does not link with an | 413 # (even when compiling without msan) but then does not link with an |
418 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory | 414 # msan-enabled compiler_rt, leaving references to __msan_allocated_memory |
419 # undefined. | 415 # undefined. |
420 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE') | 416 cmake_flags.append('-DHAVE_SANITIZER_MSAN_INTERFACE_H=FALSE') |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1358 SANDBOXED_TRANSLATOR_ARCHES)) | 1354 SANDBOXED_TRANSLATOR_ARCHES)) |
1359 | 1355 |
1360 tb = toolchain_main.PackageBuilder(packages, | 1356 tb = toolchain_main.PackageBuilder(packages, |
1361 upload_packages, | 1357 upload_packages, |
1362 leftover_args) | 1358 leftover_args) |
1363 return tb.Main() | 1359 return tb.Main() |
1364 | 1360 |
1365 | 1361 |
1366 if __name__ == '__main__': | 1362 if __name__ == '__main__': |
1367 sys.exit(main()) | 1363 sys.exit(main()) |
OLD | NEW |