| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 # NOTE Command-line arguments are a SCons-ism that is separate from | 254 # NOTE Command-line arguments are a SCons-ism that is separate from |
| 255 # command-line options. Options are prefixed by "-" or "--" whereas arguments | 255 # command-line options. Options are prefixed by "-" or "--" whereas arguments |
| 256 # are not. The function SetBitFromOption can be used for options. | 256 # are not. The function SetBitFromOption can be used for options. |
| 257 # NOTE This function must be called before the bits are used | 257 # NOTE This function must be called before the bits are used |
| 258 # NOTE This function must be called after all modifications of ARGUMENTS have | 258 # NOTE This function must be called after all modifications of ARGUMENTS have |
| 259 # been performed. See: ExpandArguments | 259 # been performed. See: ExpandArguments |
| 260 def SetUpArgumentBits(env): | 260 def SetUpArgumentBits(env): |
| 261 BitFromArgument(env, 'bitcode', default=False, | 261 BitFromArgument(env, 'bitcode', default=False, |
| 262 desc='We are building bitcode') | 262 desc='We are building bitcode') |
| 263 | 263 |
| 264 BitFromArgument(env, 'nacl_clang', default=False, |
| 265 desc='Use native nacl-clang compiler') |
| 266 |
| 264 BitFromArgument(env, 'translate_fast', default=False, | 267 BitFromArgument(env, 'translate_fast', default=False, |
| 265 desc='When using pnacl TC (bitcode=1) use accelerated translation step') | 268 desc='When using pnacl TC (bitcode=1) use accelerated translation step') |
| 266 | 269 |
| 267 BitFromArgument(env, 'built_elsewhere', default=False, | 270 BitFromArgument(env, 'built_elsewhere', default=False, |
| 268 desc='The programs have already been built by another system') | 271 desc='The programs have already been built by another system') |
| 269 | 272 |
| 270 BitFromArgument(env, 'skip_trusted_tests', default=False, | 273 BitFromArgument(env, 'skip_trusted_tests', default=False, |
| 271 desc='Only run untrusted tests - useful for translator testing' | 274 desc='Only run untrusted tests - useful for translator testing' |
| 272 ' (also skips tests of the IRT itself') | 275 ' (also skips tests of the IRT itself') |
| 273 | 276 |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 | 1236 |
| 1234 | 1237 |
| 1235 def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None, | 1238 def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None, |
| 1236 target_arch=None, is_pnacl=None, lib_name=None): | 1239 target_arch=None, is_pnacl=None, lib_name=None): |
| 1237 if platform_build_dir is None: | 1240 if platform_build_dir is None: |
| 1238 platform_build_dir = env.GetPlatformBuildTargetDir() | 1241 platform_build_dir = env.GetPlatformBuildTargetDir() |
| 1239 | 1242 |
| 1240 if toolchain_name is None: | 1243 if toolchain_name is None: |
| 1241 # Fill in default arguments based on environment. | 1244 # Fill in default arguments based on environment. |
| 1242 if is_pnacl is None: | 1245 if is_pnacl is None: |
| 1243 is_pnacl = env.Bit('bitcode') | 1246 # For the purposes of finding the toolchain dir, nacl_clang is PNaCl. |
| 1247 is_pnacl = env.Bit('bitcode') or env.Bit('nacl_clang') |
| 1244 if lib_name is None: | 1248 if lib_name is None: |
| 1245 if is_pnacl or not env.Bit('nacl_glibc'): | 1249 if is_pnacl or not env.Bit('nacl_glibc'): |
| 1246 lib_name = 'newlib' | 1250 lib_name = 'newlib' |
| 1247 else: | 1251 else: |
| 1248 lib_name = 'glibc' | 1252 lib_name = 'glibc' |
| 1249 | 1253 |
| 1250 if target_arch is None: | 1254 if target_arch is None: |
| 1251 target_arch = pynacl.platform.GetArch(GetTargetPlatform()) | 1255 target_arch = pynacl.platform.GetArch(GetTargetPlatform()) |
| 1252 | 1256 |
| 1253 if is_pnacl: | 1257 if is_pnacl: |
| (...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 | 3159 |
| 3156 # With pnacl's clang base/ code uses the "override" keyword. | 3160 # With pnacl's clang base/ code uses the "override" keyword. |
| 3157 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions']) | 3161 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions']) |
| 3158 # Allow extraneous semicolons. (Until these are removed.) | 3162 # Allow extraneous semicolons. (Until these are removed.) |
| 3159 # http://code.google.com/p/nativeclient/issues/detail?id=2861 | 3163 # http://code.google.com/p/nativeclient/issues/detail?id=2861 |
| 3160 nacl_env.Append(CCFLAGS=['-Wno-extra-semi']) | 3164 nacl_env.Append(CCFLAGS=['-Wno-extra-semi']) |
| 3161 # Allow unused private fields. (Until these are removed.) | 3165 # Allow unused private fields. (Until these are removed.) |
| 3162 # http://code.google.com/p/nativeclient/issues/detail?id=2861 | 3166 # http://code.google.com/p/nativeclient/issues/detail?id=2861 |
| 3163 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field']) | 3167 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field']) |
| 3164 | 3168 |
| 3169 if nacl_env.Bit('nacl_clang'): |
| 3170 nacl_env.Append(CCFLAGS=['-Wno-format-security']) |
| 3171 # third_party/valgrind/nacl_valgrind.h uses asm instead of __asm__ |
| 3172 nacl_env.Append(CCFLAGS=['-Wno-language-extension-token']) |
| 3173 |
| 3165 # We use a special environment for building the IRT image because it must | 3174 # We use a special environment for building the IRT image because it must |
| 3166 # always use the newlib toolchain, regardless of --nacl_glibc. We clone | 3175 # always use the newlib toolchain, regardless of --nacl_glibc. We clone |
| 3167 # it from nacl_env here, before too much other cruft has been added. | 3176 # it from nacl_env here, before too much other cruft has been added. |
| 3168 # We do some more magic below to instantiate it the way we need it. | 3177 # We do some more magic below to instantiate it the way we need it. |
| 3169 nacl_irt_env = nacl_env.Clone( | 3178 nacl_irt_env = nacl_env.Clone( |
| 3170 BUILD_TYPE = 'nacl_irt', | 3179 BUILD_TYPE = 'nacl_irt', |
| 3171 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build', | 3180 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build', |
| 3172 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT', | 3181 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT', |
| 3173 ) | 3182 ) |
| 3174 | 3183 |
| 3175 # Provide access to the IRT build environment from the default environment | 3184 # Provide access to the IRT build environment from the default environment |
| 3176 # which is needed when compiling custom IRT for testing purposes. | 3185 # which is needed when compiling custom IRT for testing purposes. |
| 3177 nacl_env['NACL_IRT_ENV'] = nacl_irt_env | 3186 nacl_env['NACL_IRT_ENV'] = nacl_irt_env |
| 3178 | 3187 |
| 3179 # Since we don't build src/untrusted/pthread/nacl.scons in | 3188 # Since we don't build src/untrusted/pthread/nacl.scons in |
| 3180 # nacl_irt_env, we must tell the IRT how to find the pthread.h header. | 3189 # nacl_irt_env, we must tell the IRT how to find the pthread.h header. |
| 3181 nacl_irt_env.Append(CPPPATH='${MAIN_DIR}/src/untrusted/pthread') | 3190 nacl_irt_env.Append(CPPPATH='${MAIN_DIR}/src/untrusted/pthread') |
| 3182 | 3191 |
| 3183 # Map certain flag bits to suffices on the build output. This needs to | 3192 # Map certain flag bits to suffices on the build output. This needs to |
| 3184 # happen pretty early, because it affects any concretized directory names. | 3193 # happen pretty early, because it affects any concretized directory names. |
| 3185 target_variant_map = [ | 3194 target_variant_map = [ |
| 3186 ('bitcode', 'pnacl'), | 3195 ('bitcode', 'pnacl'), |
| 3187 ('translate_fast', 'fast'), | 3196 ('translate_fast', 'fast'), |
| 3188 ('nacl_pic', 'pic'), | 3197 ('nacl_pic', 'pic'), |
| 3189 ('use_sandboxed_translator', 'sbtc'), | 3198 ('use_sandboxed_translator', 'sbtc'), |
| 3190 ('nacl_glibc', 'glibc'), | 3199 ('nacl_glibc', 'glibc'), |
| 3191 ('pnacl_generate_pexe', 'pexe'), | 3200 ('pnacl_generate_pexe', 'pexe'), |
| 3192 ('nonsfi_nacl', 'nonsfi'), | 3201 ('nonsfi_nacl', 'nonsfi'), |
| 3202 ('nacl_clang', 'clang'), |
| 3193 ] | 3203 ] |
| 3194 for variant_bit, variant_suffix in target_variant_map: | 3204 for variant_bit, variant_suffix in target_variant_map: |
| 3195 if nacl_env.Bit(variant_bit): | 3205 if nacl_env.Bit(variant_bit): |
| 3196 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix | 3206 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix |
| 3197 | 3207 |
| 3198 if nacl_env.Bit('bitcode'): | 3208 if nacl_env.Bit('bitcode'): |
| 3199 nacl_env['TARGET_VARIANT'] += '-clang' | 3209 nacl_env['TARGET_VARIANT'] += '-clang' |
| 3200 | 3210 |
| 3201 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner']) | 3211 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner']) |
| 3202 # TODO(mseaborn): Drop this once chrome side has inlined this. | 3212 # TODO(mseaborn): Drop this once chrome side has inlined this. |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3652 if env.Bit('bitcode'): | 3662 if env.Bit('bitcode'): |
| 3653 implicit_libs += ['libnacl.a'] | 3663 implicit_libs += ['libnacl.a'] |
| 3654 else: | 3664 else: |
| 3655 implicit_libs += ['crt1.o', | 3665 implicit_libs += ['crt1.o', |
| 3656 'libnacl.a', | 3666 'libnacl.a', |
| 3657 'crti.o', | 3667 'crti.o', |
| 3658 'crtn.o'] | 3668 'crtn.o'] |
| 3659 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. | 3669 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. |
| 3660 if GetTargetPlatform() == 'x86-32': | 3670 if GetTargetPlatform() == 'x86-32': |
| 3661 implicit_libs.append(os.path.join('32', 'crt1.o')) | 3671 implicit_libs.append(os.path.join('32', 'crt1.o')) |
| 3672 # libc++ depends on libpthread, and because PPAPI applications always need |
| 3673 # threads anyway, nacl-clang just includes -lpthread unconditionally. |
| 3674 if ((env.Bit('nacl_clang') or env.Bit('bitcode')) and |
| 3675 env['NACL_BUILD_FAMILY'] != 'UNTRUSTED_IRT'): |
| 3676 implicit_libs += ['libpthread.a'] |
| 3662 | 3677 |
| 3663 if implicit_libs != []: | 3678 if implicit_libs != []: |
| 3664 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) | 3679 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) |
| 3665 for file in implicit_libs] | 3680 for file in implicit_libs] |
| 3666 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. | 3681 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. |
| 3667 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) | 3682 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) |
| 3668 | 3683 |
| 3669 AddImplicitLibs(nacl_env) | 3684 AddImplicitLibs(nacl_env) |
| 3670 AddImplicitLibs(nacl_irt_env) | 3685 AddImplicitLibs(nacl_irt_env) |
| 3671 | 3686 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4030 nacl_env.ValidateSdk() | 4045 nacl_env.ValidateSdk() |
| 4031 | 4046 |
| 4032 if BROKEN_TEST_COUNT > 0: | 4047 if BROKEN_TEST_COUNT > 0: |
| 4033 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 4048 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
| 4034 if GetOption('brief_comstr'): | 4049 if GetOption('brief_comstr'): |
| 4035 msg += " Add --verbose to the command line for more information." | 4050 msg += " Add --verbose to the command line for more information." |
| 4036 print msg | 4051 print msg |
| 4037 | 4052 |
| 4038 # separate warnings from actual build output | 4053 # separate warnings from actual build output |
| 4039 Banner('B U I L D - O U T P U T:') | 4054 Banner('B U I L D - O U T P U T:') |
| OLD | NEW |