Chromium Code Reviews| Index: SConstruct |
| diff --git a/SConstruct b/SConstruct |
| index 1661234a75e88514aebf1029af1510114bbf969b..c15b380b203c185349423919b6cc1727c569d9c6 100755 |
| --- a/SConstruct |
| +++ b/SConstruct |
| @@ -261,6 +261,9 @@ def SetUpArgumentBits(env): |
| BitFromArgument(env, 'bitcode', default=False, |
| desc='We are building bitcode') |
| + BitFromArgument(env, 'nacl_clang', default=False, |
| + desc='Use native nacl-clang compiler') |
| + |
| BitFromArgument(env, 'translate_fast', default=False, |
| desc='When using pnacl TC (bitcode=1) use accelerated translation step') |
| @@ -1240,7 +1243,8 @@ def GetToolchainDir(env, platform_build_dir=None, toolchain_name=None, |
| if toolchain_name is None: |
| # Fill in default arguments based on environment. |
| if is_pnacl is None: |
| - is_pnacl = env.Bit('bitcode') |
| + # For the purposes of finding the toolchain dir, nacl_clang is PNaCl. |
| + is_pnacl = env.Bit('bitcode') or env.Bit('nacl_clang') |
| if lib_name is None: |
| if is_pnacl or not env.Bit('nacl_glibc'): |
| lib_name = 'newlib' |
| @@ -2908,6 +2912,8 @@ pre_base_env.Append( |
| # independent binaries |
| # NOTE: this loads stuff from: site_scons/site_tools/naclsdk.py |
| nacl_env = MakeArchSpecificEnv() |
| +# See comment below about libc++ and libpthread in NONIRT_LIBS. |
| +using_nacl_libcxx = nacl_env.Bit('nacl_clang') |
|
Roland McGrath
2014/10/09 22:01:37
Drop this variable. All it seems to be doing is m
Derek Schuff
2014/10/09 22:22:00
In the original version of this CL, this variable
|
| nacl_env = nacl_env.Clone( |
| tools = ['naclsdk'], |
| NACL_BUILD_FAMILY = 'UNTRUSTED', |
| @@ -2961,10 +2967,17 @@ nacl_env = nacl_env.Clone( |
| # These are settings for in-tree, non-browser tests to use. |
| # They use libraries that circumvent the IRT-based implementations |
| # in the public libraries. |
| - # Note that pthread_private is part of NONIRT_LIBS for PNaCl because |
| - # libc++ depends on it. |
| + # Note that pthread_private is part of NONIRT_LIBS for clang because |
| + # libc++ depends on libpthread. However we can't just add |
| + # libpthread_private to the link line because those libs get added before |
| + # the standard libs, so the references that come from libc++ itself will |
| + # still get satisfied from libpthread instead of libpthread_private (and |
| + # that code will crash because it requires the IRT). So put libc++ on the |
| + # user link line before libpthread_private to ensure that its references |
| + # to libpthread also get satisfied by libpthread_private. |
| + # TODO(dschuff): Also remove the hack in pnacl-ld and use this for pnacl. |
| NONIRT_LIBS = (['nacl_sys_private'] + |
| - (['pthread_private'] if nacl_env.Bit('bitcode') else [])), |
| + (['c++','pthread_private'] if using_nacl_libcxx else [])), |
| PTHREAD_LIBS = ['pthread_private'], |
| DYNCODE_LIBS = ['nacl_dyncode_private'], |
| EXCEPTION_LIBS = ['nacl_exception_private'], |
| @@ -3162,6 +3175,10 @@ if nacl_env.Bit('bitcode'): |
| # http://code.google.com/p/nativeclient/issues/detail?id=2861 |
| nacl_env.Append(CCFLAGS=['-Wno-unused-private-field']) |
| +if nacl_env.Bit('nacl_clang'): |
| + # third_party/valgrind/nacl_valgrind.h uses asm instead of __asm__ |
|
Roland McGrath
2014/10/09 22:01:37
File a bug and a TODO for just fixing that header.
Derek Schuff
2014/10/09 22:22:00
Done.
|
| + nacl_env.Append(CCFLAGS=['-Wno-language-extension-token']) |
| + |
| # We use a special environment for building the IRT image because it must |
| # always use the newlib toolchain, regardless of --nacl_glibc. We clone |
| # it from nacl_env here, before too much other cruft has been added. |
| @@ -3190,6 +3207,7 @@ target_variant_map = [ |
| ('nacl_glibc', 'glibc'), |
| ('pnacl_generate_pexe', 'pexe'), |
| ('nonsfi_nacl', 'nonsfi'), |
| + ('nacl_clang', 'clang'), |
| ] |
| for variant_bit, variant_suffix in target_variant_map: |
| if nacl_env.Bit(variant_bit): |
| @@ -3659,6 +3677,10 @@ def AddImplicitLibs(env): |
| # TODO(mcgrathr): multilib nonsense defeats -B! figure out a better way. |
| if GetTargetPlatform() == 'x86-32': |
| implicit_libs.append(os.path.join('32', 'crt1.o')) |
| + # libc++ depends on libpthread, and because PPAPI applications always need |
| + # threads anyway, nacl-clang just includes -lpthread unconditionally. |
| + if using_nacl_libcxx and env['NACL_BUILD_FAMILY'] != 'UNTRUSTED_IRT': |
| + implicit_libs += ['libpthread.a'] |
| if implicit_libs != []: |
| env['IMPLICIT_LIBS'] = [env.File(os.path.join('${LIB_DIR}', file)) |