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 |
3481 # The choice of toolchain used to build the IRT does not depend on the toolchain | 3484 # The choice of toolchain used to build the IRT does not depend on the toolchain |
3482 # used to build user/test code. The PNaCl toolchain is used on x86, except on | 3485 # used to build user/test code. PNaCl is used on mips because that's currently |
3483 # Windows (because pnacl-clang doesn't run on Windows XP. If we stop supporting | 3486 # the only compiler for mips. nacl-clang is used on x86. |
3484 # building on XP, we can remove this exception). See | 3487 if nacl_irt_env.Bit('build_mips32'): |
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'))): | |
3489 nacl_irt_env.SetBits('bitcode') | 3488 nacl_irt_env.SetBits('bitcode') |
3490 else: | 3489 else: |
3491 nacl_irt_env.ClearBits('bitcode') | 3490 nacl_irt_env.ClearBits('bitcode') |
3492 nacl_irt_env.ClearBits('pnacl_generate_pexe') | 3491 if nacl_irt_env.Bit('build_x86_64') or nacl_irt_env.Bit('build_x86_32'): |
3493 nacl_irt_env.ClearBits('use_sandboxed_translator') | 3492 nacl_irt_env.SetBits('nacl_clang') |
| 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 |
3494 nacl_irt_env.Tool('naclsdk') | 3503 nacl_irt_env.Tool('naclsdk') |
3495 # These are unfortunately clobbered by running Tool, which | 3504 # These are unfortunately clobbered by running Tool, which |
3496 # we needed to do to get the destination directory reset. | 3505 # we needed to do to get the destination directory reset. |
3497 # We want all the same values from nacl_env. | 3506 # We want all the same values from nacl_env. |
3498 nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'], | 3507 nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'], |
3499 EXTRA_CXXFLAGS=nacl_env['EXTRA_CXXFLAGS'], | 3508 EXTRA_CXXFLAGS=nacl_env['EXTRA_CXXFLAGS'], |
3500 CCFLAGS=nacl_env['CCFLAGS'], | 3509 CCFLAGS=nacl_env['CCFLAGS'], |
3501 CFLAGS=nacl_env['CFLAGS'], | 3510 CFLAGS=nacl_env['CFLAGS'], |
3502 CXXFLAGS=nacl_env['CXXFLAGS']) | 3511 CXXFLAGS=nacl_env['CXXFLAGS']) |
3503 FixWindowsAssembler(nacl_irt_env) | 3512 FixWindowsAssembler(nacl_irt_env) |
3504 # Make it find the libraries it builds, rather than the SDK ones. | 3513 # Make it find the libraries it builds, rather than the SDK ones. |
3505 nacl_irt_env.Replace(LIBPATH='${LIB_DIR}') | 3514 nacl_irt_env.Replace(LIBPATH='${LIB_DIR}') |
3506 | 3515 |
3507 if nacl_irt_env.Bit('bitcode'): | 3516 if nacl_irt_env.Bit('bitcode'): |
3508 if nacl_irt_env.Bit('build_x86_64'): | 3517 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native']) |
3509 nacl_irt_env.Append(CCFLAGS=['--target=x86_64-unknown-nacl']) | 3518 if nacl_irt_env.Bit('build_mips32'): |
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'): | |
3523 # Disable the PNaCl IRT verifier since it will complain about | 3519 # Disable the PNaCl IRT verifier since it will complain about |
3524 # __executable_start symbol not being a valid external symbol. | 3520 # __executable_start symbol not being a valid external symbol. |
3525 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check']) | 3521 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check']) |
3526 | 3522 |
3527 # The IRT is C only, don't link with the C++ linker so that it doesn't | 3523 # The IRT is C only, don't link with the C++ linker so that it doesn't |
3528 # start depending on the C++ standard library and (in the case of | 3524 # start depending on the C++ standard library and (in the case of |
3529 # libc++) pthread. | 3525 # libc++) pthread. |
3530 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. | 3526 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. |
3531 replace('pnacl-clang++', 'pnacl-clang'))) | 3527 replace('pnacl-clang++', 'pnacl-clang'))) |
| 3528 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. |
| 3529 replace('nacl-clang++', 'nacl-clang'))) |
3532 | 3530 |
3533 if nacl_irt_env.Bit('bitcode'): | |
3534 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native']) | |
3535 | 3531 |
3536 # All IRT code must avoid direct use of the TLS ABI register, which | 3532 # All IRT code must avoid direct use of the TLS ABI register, which |
3537 # is reserved for user TLS. Instead, ensure all TLS accesses use a | 3533 # is reserved for user TLS. Instead, ensure all TLS accesses use a |
3538 # call to __nacl_read_tp, which the IRT code overrides to segregate | 3534 # call to __nacl_read_tp, which the IRT code overrides to segregate |
3539 # IRT-private TLS from user TLS. This only applies to mips now, on | 3535 # IRT-private TLS from user TLS. This only applies to mips now, on |
3540 # other platforms we modify the TLS register through tls_edit as a | 3536 # other platforms we modify the TLS register through tls_edit as a |
3541 # post process. | 3537 # post process. |
3542 if nacl_irt_env.Bit('build_mips32'): | 3538 if nacl_irt_env.Bit('build_mips32'): |
3543 nacl_irt_env.Append(LINKFLAGS=['-Wt,-mtls-use-call']) | 3539 nacl_irt_env.Append(LINKFLAGS=['-Wt,-mtls-use-call']) |
3544 | 3540 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4019 nacl_env.ValidateSdk() | 4015 nacl_env.ValidateSdk() |
4020 | 4016 |
4021 if BROKEN_TEST_COUNT > 0: | 4017 if BROKEN_TEST_COUNT > 0: |
4022 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 4018 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
4023 if GetOption('brief_comstr'): | 4019 if GetOption('brief_comstr'): |
4024 msg += " Add --verbose to the command line for more information." | 4020 msg += " Add --verbose to the command line for more information." |
4025 print msg | 4021 print msg |
4026 | 4022 |
4027 # separate warnings from actual build output | 4023 # separate warnings from actual build output |
4028 Banner('B U I L D - O U T P U T:') | 4024 Banner('B U I L D - O U T P U T:') |
OLD | NEW |