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

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: ncbray comment 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') | no next file with comments »
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 the native nacl-clang newlib compiler instead of nacl-gcc')
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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1231
1229 1232
1230 def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None, 1233 def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None,
1231 target_arch=None, is_pnacl=None, lib_name=None): 1234 target_arch=None, is_pnacl=None, lib_name=None):
1232 if platform_build_dir is None: 1235 if platform_build_dir is None:
1233 platform_build_dir = env.GetPlatformBuildTargetDir() 1236 platform_build_dir = env.GetPlatformBuildTargetDir()
1234 1237
1235 if toolchain_name is None: 1238 if toolchain_name is None:
1236 # Fill in default arguments based on environment. 1239 # Fill in default arguments based on environment.
1237 if is_pnacl is None: 1240 if is_pnacl is None:
1238 is_pnacl = env.Bit('bitcode') 1241 # For the purposes of finding the toolchain dir, nacl_clang is PNaCl.
1242 is_pnacl = env.Bit('bitcode') or env.Bit('nacl_clang')
1239 if lib_name is None: 1243 if lib_name is None:
1240 if is_pnacl or not env.Bit('nacl_glibc'): 1244 if is_pnacl or not env.Bit('nacl_glibc'):
1241 lib_name = 'newlib' 1245 lib_name = 'newlib'
1242 else: 1246 else:
1243 lib_name = 'glibc' 1247 lib_name = 'glibc'
1244 1248
1245 if target_arch is None: 1249 if target_arch is None:
1246 target_arch = pynacl.platform.GetArch(GetTargetPlatform()) 1250 target_arch = pynacl.platform.GetArch(GetTargetPlatform())
1247 1251
1248 if is_pnacl: 1252 if is_pnacl:
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 # Do this before the site_scons/site_tools/naclsdk.py stuff to pass it along. 2890 # Do this before the site_scons/site_tools/naclsdk.py stuff to pass it along.
2887 pre_base_env.Append( 2891 pre_base_env.Append(
2888 PNACL_BCLDFLAGS = ARGUMENTS.get('pnacl_bcldflags', '').split(':')) 2892 PNACL_BCLDFLAGS = ARGUMENTS.get('pnacl_bcldflags', '').split(':'))
2889 2893
2890 2894
2891 # The nacl_env is used to build native_client modules 2895 # The nacl_env is used to build native_client modules
2892 # using a special tool chain which produces platform 2896 # using a special tool chain which produces platform
2893 # independent binaries 2897 # independent binaries
2894 # NOTE: this loads stuff from: site_scons/site_tools/naclsdk.py 2898 # NOTE: this loads stuff from: site_scons/site_tools/naclsdk.py
2895 nacl_env = MakeArchSpecificEnv() 2899 nacl_env = MakeArchSpecificEnv()
2900 # See comment below about libc++ and libpthread in NONIRT_LIBS.
2901 using_nacl_libcxx = nacl_env.Bit('bitcode') or nacl_env.Bit('nacl_clang')
2896 nacl_env = nacl_env.Clone( 2902 nacl_env = nacl_env.Clone(
2897 tools = ['naclsdk'], 2903 tools = ['naclsdk'],
2898 NACL_BUILD_FAMILY = 'UNTRUSTED', 2904 NACL_BUILD_FAMILY = 'UNTRUSTED',
2899 BUILD_TYPE = 'nacl', 2905 BUILD_TYPE = 'nacl',
2900 BUILD_TYPE_DESCRIPTION = 'NaCl module build', 2906 BUILD_TYPE_DESCRIPTION = 'NaCl module build',
2901 2907
2902 ARFLAGS = 'rc', 2908 ARFLAGS = 'rc',
2903 2909
2904 # ${SOURCE_ROOT} for #include <ppapi/...> 2910 # ${SOURCE_ROOT} for #include <ppapi/...>
2905 CPPPATH = [ 2911 CPPPATH = [
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2939 '__env__, RDirs, TARGET, SOURCE)} $)', 2945 '__env__, RDirs, TARGET, SOURCE)} $)',
2940 RPATHLINKPREFIX = '-Wl,-rpath-link,', 2946 RPATHLINKPREFIX = '-Wl,-rpath-link,',
2941 RPATHLINKSUFFIX = '', 2947 RPATHLINKSUFFIX = '',
2942 2948
2943 LIBS = [], 2949 LIBS = [],
2944 LINKFLAGS = ['${RPATH_LINK_FLAGS}'], 2950 LINKFLAGS = ['${RPATH_LINK_FLAGS}'],
2945 2951
2946 # These are settings for in-tree, non-browser tests to use. 2952 # These are settings for in-tree, non-browser tests to use.
2947 # They use libraries that circumvent the IRT-based implementations 2953 # They use libraries that circumvent the IRT-based implementations
2948 # in the public libraries. 2954 # in the public libraries.
2949 # Note that pthread_private is part of NONIRT_LIBS for PNaCl because 2955 # Note that pthread_private is part of NONIRT_LIBS for clang because
2950 # libc++ depends on it. 2956 # libc++ depends on libpthread. However we can't just add
2957 # libpthread_private to the link line because those libs get added before
2958 # the standard libs, so the references that come from libc++ itself will
2959 # still get satisfied from libpthread instead of libpthread_private (and
2960 # that code will crash because it requires the IRT). So put libc++ on the
2961 # user link line before libpthread_private to ensure that its references
2962 # to libpthread also get satisfied by libpthread_private.
2963 # TODO(dschuff): Also remove the hack in pnacl-ld and use this for pnacl.
2951 NONIRT_LIBS = (['nacl_sys_private'] + 2964 NONIRT_LIBS = (['nacl_sys_private'] +
2952 (['pthread_private'] if nacl_env.Bit('bitcode') else [])), 2965 (['c++','pthread_private'] if using_nacl_libcxx else [])),
2953 PTHREAD_LIBS = ['pthread_private'], 2966 PTHREAD_LIBS = ['pthread_private'],
2954 DYNCODE_LIBS = ['nacl_dyncode_private'], 2967 DYNCODE_LIBS = ['nacl_dyncode_private'],
2955 EXCEPTION_LIBS = ['nacl_exception_private'], 2968 EXCEPTION_LIBS = ['nacl_exception_private'],
2956 LIST_MAPPINGS_LIBS = ['nacl_list_mappings_private'], 2969 LIST_MAPPINGS_LIBS = ['nacl_list_mappings_private'],
2957 RANDOM_LIBS = ['nacl_random_private'], 2970 RANDOM_LIBS = ['nacl_random_private'],
2958 ) 2971 )
2959 2972
2960 def UsesAbiNote(env): 2973 def UsesAbiNote(env):
2961 """Return True if using a new-style GCC with .note.NaCl.ABI.* notes. 2974 """Return True if using a new-style GCC with .note.NaCl.ABI.* notes.
2962 This means there will always be an RODATA segment, even if just for the note.""" 2975 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
3140 3153
3141 # With pnacl's clang base/ code uses the "override" keyword. 3154 # With pnacl's clang base/ code uses the "override" keyword.
3142 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions']) 3155 nacl_env.Append(CXXFLAGS=['-Wno-c++11-extensions'])
3143 # Allow extraneous semicolons. (Until these are removed.) 3156 # Allow extraneous semicolons. (Until these are removed.)
3144 # http://code.google.com/p/nativeclient/issues/detail?id=2861 3157 # http://code.google.com/p/nativeclient/issues/detail?id=2861
3145 nacl_env.Append(CCFLAGS=['-Wno-extra-semi']) 3158 nacl_env.Append(CCFLAGS=['-Wno-extra-semi'])
3146 # Allow unused private fields. (Until these are removed.) 3159 # Allow unused private fields. (Until these are removed.)
3147 # http://code.google.com/p/nativeclient/issues/detail?id=2861 3160 # http://code.google.com/p/nativeclient/issues/detail?id=2861
3148 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field']) 3161 nacl_env.Append(CCFLAGS=['-Wno-unused-private-field'])
3149 3162
3163 if nacl_env.Bit('nacl_clang'):
3164 # third_party/valgrind/nacl_valgrind.h uses asm instead of __asm__
3165 # https://code.google.com/p/nativeclient/issues/detail?id=3974
3166 # TODO(dschuff): change it to __asm__ and remove this suppression.
3167 nacl_env.Append(CCFLAGS=['-Wno-language-extension-token'])
3168
3150 # We use a special environment for building the IRT image because it must 3169 # We use a special environment for building the IRT image because it must
3151 # always use the newlib toolchain, regardless of --nacl_glibc. We clone 3170 # always use the newlib toolchain, regardless of --nacl_glibc. We clone
3152 # it from nacl_env here, before too much other cruft has been added. 3171 # it from nacl_env here, before too much other cruft has been added.
3153 # We do some more magic below to instantiate it the way we need it. 3172 # We do some more magic below to instantiate it the way we need it.
3154 nacl_irt_env = nacl_env.Clone( 3173 nacl_irt_env = nacl_env.Clone(
3155 BUILD_TYPE = 'nacl_irt', 3174 BUILD_TYPE = 'nacl_irt',
3156 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build', 3175 BUILD_TYPE_DESCRIPTION = 'NaCl IRT build',
3157 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT', 3176 NACL_BUILD_FAMILY = 'UNTRUSTED_IRT',
3158 ) 3177 )
3159 3178
3160 # Provide access to the IRT build environment from the default environment 3179 # Provide access to the IRT build environment from the default environment
3161 # which is needed when compiling custom IRT for testing purposes. 3180 # which is needed when compiling custom IRT for testing purposes.
3162 nacl_env['NACL_IRT_ENV'] = nacl_irt_env 3181 nacl_env['NACL_IRT_ENV'] = nacl_irt_env
3163 3182
3164 # Since we don't build src/untrusted/pthread/nacl.scons in 3183 # Since we don't build src/untrusted/pthread/nacl.scons in
3165 # nacl_irt_env, we must tell the IRT how to find the pthread.h header. 3184 # nacl_irt_env, we must tell the IRT how to find the pthread.h header.
3166 nacl_irt_env.Append(CPPPATH='${MAIN_DIR}/src/untrusted/pthread') 3185 nacl_irt_env.Append(CPPPATH='${MAIN_DIR}/src/untrusted/pthread')
3167 3186
3168 # Map certain flag bits to suffices on the build output. This needs to 3187 # Map certain flag bits to suffices on the build output. This needs to
3169 # happen pretty early, because it affects any concretized directory names. 3188 # happen pretty early, because it affects any concretized directory names.
3170 target_variant_map = [ 3189 target_variant_map = [
3171 ('bitcode', 'pnacl'), 3190 ('bitcode', 'pnacl'),
3172 ('translate_fast', 'fast'), 3191 ('translate_fast', 'fast'),
3173 ('nacl_pic', 'pic'), 3192 ('nacl_pic', 'pic'),
3174 ('use_sandboxed_translator', 'sbtc'), 3193 ('use_sandboxed_translator', 'sbtc'),
3175 ('nacl_glibc', 'glibc'), 3194 ('nacl_glibc', 'glibc'),
3176 ('pnacl_generate_pexe', 'pexe'), 3195 ('pnacl_generate_pexe', 'pexe'),
3177 ('nonsfi_nacl', 'nonsfi'), 3196 ('nonsfi_nacl', 'nonsfi'),
3197 ('nacl_clang', 'clang'),
3178 ] 3198 ]
3179 for variant_bit, variant_suffix in target_variant_map: 3199 for variant_bit, variant_suffix in target_variant_map:
3180 if nacl_env.Bit(variant_bit): 3200 if nacl_env.Bit(variant_bit):
3181 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix 3201 nacl_env['TARGET_VARIANT'] += '-' + variant_suffix
3182 3202
3183 if nacl_env.Bit('bitcode'): 3203 if nacl_env.Bit('bitcode'):
3184 nacl_env['TARGET_VARIANT'] += '-clang' 3204 nacl_env['TARGET_VARIANT'] += '-clang'
3185 3205
3186 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner']) 3206 nacl_env.Replace(TESTRUNNER_LIBS=['testrunner'])
3187 # TODO(mseaborn): Drop this once chrome side has inlined this. 3207 # TODO(mseaborn): Drop this once chrome side has inlined this.
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3637 if env.Bit('bitcode'): 3657 if env.Bit('bitcode'):
3638 implicit_libs += ['libnacl.a'] 3658 implicit_libs += ['libnacl.a']
3639 else: 3659 else:
3640 implicit_libs += ['crt1.o', 3660 implicit_libs += ['crt1.o',
3641 'libnacl.a', 3661 'libnacl.a',
3642 'crti.o', 3662 'crti.o',
3643 'crtn.o'] 3663 'crtn.o']
3644 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. 3664 # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way.
3645 if GetTargetPlatform() == 'x86-32': 3665 if GetTargetPlatform() == 'x86-32':
3646 implicit_libs.append(os.path.join('32', 'crt1.o')) 3666 implicit_libs.append(os.path.join('32', 'crt1.o'))
3667 # libc++ depends on libpthread, and because PPAPI applications always need
3668 # threads anyway, nacl-clang just includes -lpthread unconditionally.
3669 if using_nacl_libcxx and env['NACL_BUILD_FAMILY'] != 'UNTRUSTED_IRT':
3670 implicit_libs += ['libpthread.a']
3647 3671
3648 if implicit_libs != []: 3672 if implicit_libs != []:
3649 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) 3673 env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file))
3650 for file in implicit_libs] 3674 for file in implicit_libs]
3651 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there. 3675 # The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there.
3652 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/']) 3676 env.Prepend(LINKFLAGS=['-B${LIB_DIR}/'])
3653 3677
3654 AddImplicitLibs(nacl_env) 3678 AddImplicitLibs(nacl_env)
3655 AddImplicitLibs(nacl_irt_env) 3679 AddImplicitLibs(nacl_irt_env)
3656 3680
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
4015 nacl_env.ValidateSdk() 4039 nacl_env.ValidateSdk()
4016 4040
4017 if BROKEN_TEST_COUNT > 0: 4041 if BROKEN_TEST_COUNT > 0:
4018 msg = "There are %d broken tests." % BROKEN_TEST_COUNT 4042 msg = "There are %d broken tests." % BROKEN_TEST_COUNT
4019 if GetOption('brief_comstr'): 4043 if GetOption('brief_comstr'):
4020 msg += " Add --verbose to the command line for more information." 4044 msg += " Add --verbose to the command line for more information."
4021 print msg 4045 print msg
4022 4046
4023 # separate warnings from actual build output 4047 # separate warnings from actual build output
4024 Banner('B U I L D - O U T P U T:') 4048 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698