OLD | NEW |
1 #! -*- python -*- | 1 #! -*- python -*- |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import atexit | 6 import atexit |
7 import json | 7 import json |
8 import os | 8 import os |
9 import platform | 9 import platform |
10 import re | 10 import re |
(...skipping 3460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3471 | 3471 |
3472 | 3472 |
3473 # The IRT-building environment was cloned from nacl_env, but it should | 3473 # The IRT-building environment was cloned from nacl_env, but it should |
3474 # ignore the --nacl_glibc, nacl_pic=1 and bitcode=1 switches. | 3474 # ignore the --nacl_glibc, nacl_pic=1 and bitcode=1 switches. |
3475 # We have to reinstantiate the naclsdk.py magic after clearing those flags, | 3475 # We have to reinstantiate the naclsdk.py magic after clearing those flags, |
3476 # so it regenerates the tool paths right. | 3476 # so it regenerates the tool paths right. |
3477 # TODO(mcgrathr,bradnelson): could get cleaner if naclsdk.py got folded back in. | 3477 # TODO(mcgrathr,bradnelson): could get cleaner if naclsdk.py got folded back in. |
3478 nacl_irt_env.ClearBits('nacl_glibc') | 3478 nacl_irt_env.ClearBits('nacl_glibc') |
3479 nacl_irt_env.ClearBits('nacl_pic') | 3479 nacl_irt_env.ClearBits('nacl_pic') |
3480 nacl_irt_env.ClearBits('nacl_clang') | 3480 nacl_irt_env.ClearBits('nacl_clang') |
3481 nacl_irt_env.ClearBits('pnacl_generate_pexe') | |
3482 nacl_irt_env.ClearBits('use_sandboxed_translator') | |
3483 | |
3484 # The choice of toolchain used to build the IRT does not depend on the toolchain | 3481 # The choice of toolchain used to build the IRT does not depend on the toolchain |
3485 # used to build user/test code. PNaCl is used on mips because that's currently | 3482 # used to build user/test code. The PNaCl toolchain is used on x86, except on |
3486 # the only compiler for mips. nacl-clang is used on x86. | 3483 # Windows (because pnacl-clang doesn't run on Windows XP. If we stop supporting |
3487 if nacl_irt_env.Bit('build_mips32'): | 3484 # building on XP, we can remove this exception). See |
| 3485 # https://code.google.com/p/nativeclient/issues/detail?id=3936 |
| 3486 if (nacl_irt_env.Bit('build_mips32') or nacl_irt_env.Bit('build_x86_64') or |
| 3487 (nacl_irt_env.Bit('build_x86_32') and |
| 3488 not nacl_irt_env.Bit('host_windows'))): |
3488 nacl_irt_env.SetBits('bitcode') | 3489 nacl_irt_env.SetBits('bitcode') |
3489 else: | 3490 else: |
3490 nacl_irt_env.ClearBits('bitcode') | 3491 nacl_irt_env.ClearBits('bitcode') |
3491 if nacl_irt_env.Bit('build_x86_64') or nacl_irt_env.Bit('build_x86_32'): | 3492 nacl_irt_env.ClearBits('pnacl_generate_pexe') |
3492 nacl_irt_env.SetBits('nacl_clang') | 3493 nacl_irt_env.ClearBits('use_sandboxed_translator') |
3493 # The IRT must be built using LLVM's assembler on x86-64 to preserve sandbox | |
3494 # base address hiding (a security hardening mechanism). | |
3495 # It's also used on x86-32 for consistency. | |
3496 # See https://code.google.com/p/nativeclient/issues/detail?id=1235 | |
3497 nacl_irt_env.Append(CCFLAGS=['-integrated-as']) | |
3498 if nacl_irt_env.Bit('build_x86_32'): | |
3499 # The x86-32 IRT needs to be callable with an under-aligned stack. | |
3500 # See https://code.google.com/p/nativeclient/issues/detail?id=3935 | |
3501 nacl_irt_env.Append(CCFLAGS=['-mstackrealign', '-mno-sse']) | |
3502 | |
3503 nacl_irt_env.Tool('naclsdk') | 3494 nacl_irt_env.Tool('naclsdk') |
3504 # These are unfortunately clobbered by running Tool, which | 3495 # These are unfortunately clobbered by running Tool, which |
3505 # we needed to do to get the destination directory reset. | 3496 # we needed to do to get the destination directory reset. |
3506 # We want all the same values from nacl_env. | 3497 # We want all the same values from nacl_env. |
3507 nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'], | 3498 nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'], |
3508 EXTRA_CXXFLAGS=nacl_env['EXTRA_CXXFLAGS'], | 3499 EXTRA_CXXFLAGS=nacl_env['EXTRA_CXXFLAGS'], |
3509 CCFLAGS=nacl_env['CCFLAGS'], | 3500 CCFLAGS=nacl_env['CCFLAGS'], |
3510 CFLAGS=nacl_env['CFLAGS'], | 3501 CFLAGS=nacl_env['CFLAGS'], |
3511 CXXFLAGS=nacl_env['CXXFLAGS']) | 3502 CXXFLAGS=nacl_env['CXXFLAGS']) |
3512 FixWindowsAssembler(nacl_irt_env) | 3503 FixWindowsAssembler(nacl_irt_env) |
3513 # Make it find the libraries it builds, rather than the SDK ones. | 3504 # Make it find the libraries it builds, rather than the SDK ones. |
3514 nacl_irt_env.Replace(LIBPATH='${LIB_DIR}') | 3505 nacl_irt_env.Replace(LIBPATH='${LIB_DIR}') |
3515 | 3506 |
3516 if nacl_irt_env.Bit('bitcode'): | 3507 if nacl_irt_env.Bit('bitcode'): |
3517 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native']) | 3508 if nacl_irt_env.Bit('build_x86_64'): |
3518 if nacl_irt_env.Bit('build_mips32'): | 3509 nacl_irt_env.Append(CCFLAGS=['--target=x86_64-unknown-nacl']) |
| 3510 nacl_irt_env.Append(LINKFLAGS=['--target=x86_64-unknown-nacl', |
| 3511 '--pnacl-allow-translate', |
| 3512 '-arch', 'x86-64']) |
| 3513 elif nacl_irt_env.Bit('build_x86_32'): |
| 3514 nacl_irt_env.Append(CCFLAGS=['--target=i686-unknown-nacl']) |
| 3515 # X86-32 IRT needs to be callable with an under-aligned stack, so we disable |
| 3516 # SSE instructions, which can fault on misaligned addresses: see |
| 3517 # https://code.google.com/p/nativeclient/issues/detail?id=3935 |
| 3518 nacl_irt_env.Append(LINKFLAGS=['--target=i686-unknown-nacl', |
| 3519 '--pnacl-allow-translate', |
| 3520 '-arch', 'x86-32', |
| 3521 '-Wt,-mattr=-sse']) |
| 3522 elif nacl_irt_env.Bit('build_mips32'): |
3519 # Disable the PNaCl IRT verifier since it will complain about | 3523 # Disable the PNaCl IRT verifier since it will complain about |
3520 # __executable_start symbol not being a valid external symbol. | 3524 # __executable_start symbol not being a valid external symbol. |
3521 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check']) | 3525 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check']) |
3522 | 3526 |
3523 # The IRT is C only, don't link with the C++ linker so that it doesn't | 3527 # The IRT is C only, don't link with the C++ linker so that it doesn't |
3524 # start depending on the C++ standard library and (in the case of | 3528 # start depending on the C++ standard library and (in the case of |
3525 # libc++) pthread. | 3529 # libc++) pthread. |
3526 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. | 3530 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. |
3527 replace('pnacl-clang++', 'pnacl-clang'))) | 3531 replace('pnacl-clang++', 'pnacl-clang'))) |
3528 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. | |
3529 replace('nacl-clang++', 'nacl-clang'))) | |
3530 | 3532 |
| 3533 if nacl_irt_env.Bit('bitcode'): |
| 3534 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native']) |
3531 | 3535 |
3532 # All IRT code must avoid direct use of the TLS ABI register, which | 3536 # All IRT code must avoid direct use of the TLS ABI register, which |
3533 # is reserved for user TLS. Instead, ensure all TLS accesses use a | 3537 # is reserved for user TLS. Instead, ensure all TLS accesses use a |
3534 # call to __nacl_read_tp, which the IRT code overrides to segregate | 3538 # call to __nacl_read_tp, which the IRT code overrides to segregate |
3535 # IRT-private TLS from user TLS. This only applies to mips now, on | 3539 # IRT-private TLS from user TLS. This only applies to mips now, on |
3536 # other platforms we modify the TLS register through tls_edit as a | 3540 # other platforms we modify the TLS register through tls_edit as a |
3537 # post process. | 3541 # post process. |
3538 if nacl_irt_env.Bit('build_mips32'): | 3542 if nacl_irt_env.Bit('build_mips32'): |
3539 nacl_irt_env.Append(LINKFLAGS=['-Wt,-mtls-use-call']) | 3543 nacl_irt_env.Append(LINKFLAGS=['-Wt,-mtls-use-call']) |
3540 | 3544 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4015 nacl_env.ValidateSdk() | 4019 nacl_env.ValidateSdk() |
4016 | 4020 |
4017 if BROKEN_TEST_COUNT > 0: | 4021 if BROKEN_TEST_COUNT > 0: |
4018 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 4022 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
4019 if GetOption('brief_comstr'): | 4023 if GetOption('brief_comstr'): |
4020 msg += " Add --verbose to the command line for more information." | 4024 msg += " Add --verbose to the command line for more information." |
4021 print msg | 4025 print msg |
4022 | 4026 |
4023 # separate warnings from actual build output | 4027 # separate warnings from actual build output |
4024 Banner('B U I L D - O U T P U T:') | 4028 Banner('B U I L D - O U T P U T:') |
OLD | NEW |