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

Side by Side Diff: SConstruct

Issue 639113003: Add nacl-clang testing to SCons (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: review, add libc++ pthread link fix Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pnacl/support/clang_direct/crtbegin.c » ('j') | tests/fixedfeaturecpu/nacl.scons » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after
2901 # Do this before the site_scons/site_tools/naclsdk.py stuff to pass it along. 2905 # Do this before the site_scons/site_tools/naclsdk.py stuff to pass it along.
2902 pre_base_env.Append( 2906 pre_base_env.Append(
2903 PNACL_BCLDFLAGS = ARGUMENTS.get('pnacl_bcldflags', '').split(':')) 2907 PNACL_BCLDFLAGS = ARGUMENTS.get('pnacl_bcldflags', '').split(':'))
2904 2908
2905 2909
2906 # The nacl_env is used to build native_client modules 2910 # The nacl_env is used to build native_client modules
2907 # using a special tool chain which produces platform 2911 # using a special tool chain which produces platform
2908 # independent binaries 2912 # independent binaries
2909 # NOTE: this loads stuff from: site_scons/site_tools/naclsdk.py 2913 # NOTE: this loads stuff from: site_scons/site_tools/naclsdk.py
2910 nacl_env = MakeArchSpecificEnv() 2914 nacl_env = MakeArchSpecificEnv()
2915 # See comment below about libc++ and libpthread in NONIRT_LIBS.
2916 needs_pthread = nacl_env.Bit('bitcode') or nacl_env.Bit('nacl_clang')
2911 nacl_env = nacl_env.Clone( 2917 nacl_env = nacl_env.Clone(
2912 tools = ['naclsdk'], 2918 tools = ['naclsdk'],
2913 NACL_BUILD_FAMILY = 'UNTRUSTED', 2919 NACL_BUILD_FAMILY = 'UNTRUSTED',
2914 BUILD_TYPE = 'nacl', 2920 BUILD_TYPE = 'nacl',
2915 BUILD_TYPE_DESCRIPTION = 'NaCl module build', 2921 BUILD_TYPE_DESCRIPTION = 'NaCl module build',
2916 2922
2917 ARFLAGS = 'rc', 2923 ARFLAGS = 'rc',
2918 2924
2919 # ${SOURCE_ROOT} for #include <ppapi/...> 2925 # ${SOURCE_ROOT} for #include <ppapi/...>
2920 CPPPATH = [ 2926 CPPPATH = [
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 '__env__, RDirs, TARGET, SOURCE)} $)', 2960 '__env__, RDirs, TARGET, SOURCE)} $)',
2955 RPATHLINKPREFIX = '-Wl,-rpath-link,', 2961 RPATHLINKPREFIX = '-Wl,-rpath-link,',
2956 RPATHLINKSUFFIX = '', 2962 RPATHLINKSUFFIX = '',
2957 2963
2958 LIBS = [], 2964 LIBS = [],
2959 LINKFLAGS = ['${RPATH_LINK_FLAGS}'], 2965 LINKFLAGS = ['${RPATH_LINK_FLAGS}'],
2960 2966
2961 # These are settings for in-tree, non-browser tests to use. 2967 # These are settings for in-tree, non-browser tests to use.
2962 # They use libraries that circumvent the IRT-based implementations 2968 # They use libraries that circumvent the IRT-based implementations
2963 # in the public libraries. 2969 # in the public libraries.
2964 # Note that pthread_private is part of NONIRT_LIBS for PNaCl because 2970 # Note that pthread_private is part of NONIRT_LIBS for clang because
2965 # libc++ depends on it. 2971 # libc++ depends on libpthread. However we can't just add
2972 # libpthread_private to the link line because those libs get added before
2973 # the standard libs, so the references that come from libc++ itself will
2974 # stil get satisfied from libpthread instead of libpthread_private (and
jvoung (off chromium) 2014/10/09 17:35:01 "still get"
Derek Schuff 2014/10/09 18:40:40 Done.
2975 # that code will crash because it requires the IRT). So put libc++ on the
2976 # user link line before libpthread_private to ensure that its references
jvoung (off chromium) 2014/10/09 17:35:01 I guess this is the actual hack that was in pnacl-
Derek Schuff 2014/10/09 18:40:39 Yeah the idea was to allow this to remove the hack
2977 # to libpthread also get satisfied by libpthread_private.
2966 NONIRT_LIBS = (['nacl_sys_private'] + 2978 NONIRT_LIBS = (['nacl_sys_private'] +
2967 (['pthread_private'] if nacl_env.Bit('bitcode') else [])), 2979 (['c++','pthread_private'] if needs_pthread else [])),
2968 PTHREAD_LIBS = ['pthread_private'], 2980 PTHREAD_LIBS = ['pthread_private'],
2969 DYNCODE_LIBS = ['nacl_dyncode_private'], 2981 DYNCODE_LIBS = ['nacl_dyncode_private'],
2970 EXCEPTION_LIBS = ['nacl_exception_private'], 2982 EXCEPTION_LIBS = ['nacl_exception_private'],
2971 LIST_MAPPINGS_LIBS = ['nacl_list_mappings_private'], 2983 LIST_MAPPINGS_LIBS = ['nacl_list_mappings_private'],
2972 RANDOM_LIBS = ['nacl_random_private'], 2984 RANDOM_LIBS = ['nacl_random_private'],
2973 ) 2985 )
2974 2986
2975 def UsesAbiNote(env): 2987 def UsesAbiNote(env):
2976 """Return True if using a new-style GCC with .note.NaCl.ABI.* notes. 2988 """Return True if using a new-style GCC with .note.NaCl.ABI.* notes.
2977 This means there will always be an RODATA segment, even if just for the note.""" 2989 This means there will always be an RODATA segment, even if just for the note."""
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3155 3167
3156 # With pnacl's clang base/ code uses the "override" keyword. 3168 # With pnacl's clang base/ code uses the "override" keyword.
3157 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions']) 3169 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions'])
3158 # Allow extraneous semicolons. (Until these are removed.) 3170 # Allow extraneous semicolons. (Until these are removed.)
3159 # http://code.google.com/p/nativeclient/issues/detail?id=2861 3171 # http://code.google.com/p/nativeclient/issues/detail?id=2861
3160 nacl_env.Append(CCFLAGS=['-Wno-extra-semi']) 3172 nacl_env.Append(CCFLAGS=['-Wno-extra-semi'])
3161 # Allow unused private fields. (Until these are removed.) 3173 # Allow unused private fields. (Until these are removed.)
3162 # http://code.google.com/p/nativeclient/issues/detail?id=2861 3174 # http://code.google.com/p/nativeclient/issues/detail?id=2861
3163 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field']) 3175 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field'])
3164 3176
3177 if nacl_env.Bit('nacl_clang'):
3178 nacl_env.Append(CCFLAGS=['-Wno-format-security'])
jvoung (off chromium) 2014/10/09 17:35:01 Why is Wno-format-security needed for nacl_clang?
Derek Schuff 2014/10/09 18:40:39 Hm, i had it in there during bootstrapping for som
3179 # third_party/valgrind/nacl_valgrind.h uses asm instead of __asm__
3180 nacl_env.Append(CCFLAGS=['-Wno-language-extension-token'])
3181
3165 # We use a special environment for building the IRT image because it must 3182 # 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 3183 # 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. 3184 # 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. 3185 # We do some more magic below to instantiate it the way we need it.
3169 nacl_irt_env = nacl_env.Clone( 3186 nacl_irt_env = nacl_env.Clone(
3170 BUILD_TYPE = 'nacl_irt', 3187 BUILD_TYPE = 'nacl_irt',
3171 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build', 3188 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build',
3172 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT', 3189 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT',
3173 ) 3190 )
3174 3191
3175 # Provide access to the IRT build environment from the default environment 3192 # Provide access to the IRT build environment from the default environment
3176 # which is needed when compiling custom IRT for testing purposes. 3193 # which is needed when compiling custom IRT for testing purposes.
3177 nacl_env['NACL_IRT_ENV'] = nacl_irt_env 3194 nacl_env['NACL_IRT_ENV'] = nacl_irt_env
3178 3195
3179 # Since we don't build src/untrusted/pthread/nacl.scons in 3196 # 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. 3197 # 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') 3198 nacl_irt_env.Append(CPPPATH='${MAIN_DIR}/src/untrusted/pthread')
3182 3199
3183 # Map certain flag bits to suffices on the build output. This needs to 3200 # Map certain flag bits to suffices on the build output. This needs to
3184 # happen pretty early, because it affects any concretized directory names. 3201 # happen pretty early, because it affects any concretized directory names.
3185 target_variant_map = [ 3202 target_variant_map = [
3186 ('bitcode', 'pnacl'), 3203 ('bitcode', 'pnacl'),
3187 ('translate_fast', 'fast'), 3204 ('translate_fast', 'fast'),
3188 ('nacl_pic', 'pic'), 3205 ('nacl_pic', 'pic'),
3189 ('use_sandboxed_translator', 'sbtc'), 3206 ('use_sandboxed_translator', 'sbtc'),
3190 ('nacl_glibc', 'glibc'), 3207 ('nacl_glibc', 'glibc'),
3191 ('pnacl_generate_pexe', 'pexe'), 3208 ('pnacl_generate_pexe', 'pexe'),
3192 ('nonsfi_nacl', 'nonsfi'), 3209 ('nonsfi_nacl', 'nonsfi'),
3210 ('nacl_clang', 'clang'),
3193 ] 3211 ]
3194 for variant_bit, variant_suffix in target_variant_map: 3212 for variant_bit, variant_suffix in target_variant_map:
3195 if nacl_env.Bit(variant_bit): 3213 if nacl_env.Bit(variant_bit):
3196 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix 3214 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix
3197 3215
3198 if nacl_env.Bit('bitcode'): 3216 if nacl_env.Bit('bitcode'):
3199 nacl_env['TARGET_VARIANT'] += '-clang' 3217 nacl_env['TARGET_VARIANT'] += '-clang'
3200 3218
3201 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner']) 3219 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner'])
3202 # TODO(mseaborn): Drop this once chrome side has inlined this. 3220 # TODO(mseaborn): Drop this once chrome side has inlined this.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
3534 '--pnacl-allow-translate', 3552 '--pnacl-allow-translate',
3535 '-arch', 'x86-32', 3553 '-arch', 'x86-32',
3536 '-Wt,-mattr=-sse']) 3554 '-Wt,-mattr=-sse'])
3537 elif nacl_irt_env.Bit('target_mips32'): 3555 elif nacl_irt_env.Bit('target_mips32'):
3538 # Disable the PNaCl IRT verifier since it will complain about 3556 # Disable the PNaCl IRT verifier since it will complain about
3539 # __executable_start symbol not being a valid external symbol. 3557 # __executable_start symbol not being a valid external symbol.
3540 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check']) 3558 nacl_irt_env.Append(LINKFLAGS=['--pnacl-disable-abi-check'])
3541 3559
3542 # The IRT is C only, don't link with the C++ linker so that it doesn't 3560 # The IRT is C only, don't link with the C++ linker so that it doesn't
3543 # start depending on the C++ standard library and (in the case of 3561 # start depending on the C++ standard library and (in the case of
3544 # libc++) pthread. 3562 # libc++) pthread.
jvoung (off chromium) 2014/10/09 17:35:00 This was another hack, I think, from the libc++ de
Derek Schuff 2014/10/09 18:40:40 It looks like we still want it to avoid depending
jvoung (off chromium) 2014/10/09 19:05:01 Okay, and now it doesn't apply to plain bitcode=1
3545 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK']. 3563 nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK'].
3546 replace('pnacl-clang++', 'pnacl-clang'))) 3564 replace('pnacl-clang++', 'pnacl-clang')))
3547 3565
3548 if nacl_irt_env.Bit('bitcode'): 3566 if nacl_irt_env.Bit('bitcode'):
3549 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native']) 3567 nacl_irt_env.Append(LINKFLAGS=['--pnacl-allow-native'])
3550 3568
3551 # All IRT code must avoid direct use of the TLS ABI register, which 3569 # All IRT code must avoid direct use of the TLS ABI register, which
3552 # is reserved for user TLS. Instead, ensure all TLS accesses use a 3570 # is reserved for user TLS. Instead, ensure all TLS accesses use a
3553 # call to __nacl_read_tp, which the IRT code overrides to segregate 3571 # call to __nacl_read_tp, which the IRT code overrides to segregate
3554 # IRT-private TLS from user TLS. This only applies to mips now, on 3572 # IRT-private TLS from user TLS. This only applies to mips now, on
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 if env.Bit('bitcode'): 3670 if env.Bit('bitcode'):
3653 implicit_libs += ['libnacl.a'] 3671 implicit_libs += ['libnacl.a']
3654 else: 3672 else:
3655 implicit_libs += ['crt1.o', 3673 implicit_libs += ['crt1.o',
3656 'libnacl.a', 3674 'libnacl.a',
3657 'crti.o', 3675 'crti.o',
3658 'crtn.o'] 3676 'crtn.o']
3659 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. 3677 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way.
3660 if GetTargetPlatform() == 'x86-32': 3678 if GetTargetPlatform() == 'x86-32':
3661 implicit_libs.append(os.path.join('32', 'crt1.o')) 3679 implicit_libs.append(os.path.join('32', 'crt1.o'))
3680 # libc++ depends on libpthread, and because PPAPI applications always need
3681 # threads anyway, nacl-clang just includes -lpthread unconditionally.
3682 if ((env.Bit('nacl_clang') or env.Bit('bitcode')) and
jvoung (off chromium) 2014/10/09 17:35:01 Can use "needs_pthread" here too
Derek Schuff 2014/10/09 18:40:39 Done, and renamed.
3683 env['NACL_BUILD_FAMILY'] != 'UNTRUSTED_IRT'):
3684 implicit_libs += ['libpthread.a']
3662 3685
3663 if implicit_libs != []: 3686 if implicit_libs != []:
3664 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) 3687 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file))
3665 for file in implicit_libs] 3688 for file in implicit_libs]
3666 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. 3689 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there.
3667 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) 3690 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/'])
3668 3691
3669 AddImplicitLibs(nacl_env) 3692 AddImplicitLibs(nacl_env)
3670 AddImplicitLibs(nacl_irt_env) 3693 AddImplicitLibs(nacl_irt_env)
3671 3694
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 nacl_env.ValidateSdk() 4053 nacl_env.ValidateSdk()
4031 4054
4032 if BROKEN_TEST_COUNT > 0: 4055 if BROKEN_TEST_COUNT > 0:
4033 msg = "There are %d broken tests." % BROKEN_TEST_COUNT 4056 msg = "There are %d broken tests." % BROKEN_TEST_COUNT
4034 if GetOption('brief_comstr'): 4057 if GetOption('brief_comstr'):
4035 msg += " Add --verbose to the command line for more information." 4058 msg += " Add --verbose to the command line for more information."
4036 print msg 4059 print msg
4037 4060
4038 # separate warnings from actual build output 4061 # separate warnings from actual build output
4039 Banner('B U I L D - O U T P U T:') 4062 Banner('B U I L D - O U T P U T:')
OLDNEW
« no previous file with comments | « no previous file | pnacl/support/clang_direct/crtbegin.c » ('j') | tests/fixedfeaturecpu/nacl.scons » ('J')

Powered by Google App Engine
This is Rietveld 408576698