| OLD | NEW |
| 1 # -*- python -*- | 1 # -*- python -*- |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 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('env') | 6 Import('env') |
| 7 | 7 |
| 8 # This directory contains untrusted C and ASM source for low-level | 8 # This directory contains untrusted C and ASM source for low-level |
| 9 # CPU-specific libraries implicitly supplied by the compiler driver. | 9 # CPU-specific libraries implicitly supplied by the compiler driver. |
| 10 # Unlike most untrusted SDK code, conditional compilation may be | 10 # Unlike most untrusted SDK code, conditional compilation may be |
| 11 # freely used, as the target will never be PNaCl. | 11 # freely used, as the target will never be PNaCl. |
| 12 | 12 |
| 13 def GetPlatformSuffix(env): | 13 def GetPlatformSuffix(env): |
| 14 platform = env.get('TARGET_FULLARCH') | 14 platform = env.get('TARGET_FULLARCH') |
| 15 assert platform in ['x86-32', 'x86-64', 'arm'] | 15 assert platform in ['x86-32', 'x86-64', 'arm'] |
| 16 # we do not like hyphens in file names | 16 # we do not like hyphens in file names |
| 17 return platform.replace('-', '_') | 17 return platform.replace('-', '_') |
| 18 | 18 |
| 19 platform = GetPlatformSuffix(env) | 19 platform = GetPlatformSuffix(env) |
| 20 | 20 |
| 21 native_env = env.Clone() |
| 22 if native_env.Bit('bitcode'): |
| 23 native_env.PNaClForceNative() |
| 21 | 24 |
| 22 if env.Bit('bitcode'): | 25 # This is a dummy linker script (a source file), not an actual object file. |
| 23 # NOTE: we make sure everything in this directory gets compiled | 26 crt1 = env.InstallAs('crt1${OBJSUFFIX}', 'crt1.x') |
| 24 # all the way down into native code. | 27 env.AddObjectToSdk([crt1]) |
| 25 # This is tricky in the pnacl case where a .c file would | |
| 26 # normally compiled into a bitcode file. | |
| 27 env.Replace(OBJSUFFIX='.o') | |
| 28 env.Append(ASFLAGS=['-arch', '${TARGET_FULLARCH}']) | |
| 29 env.Append(CCFLAGS=['-arch', '${TARGET_FULLARCH}', | |
| 30 '--pnacl-allow-translate']) | |
| 31 | |
| 32 | |
| 33 # the nacl-gcc toolchain does not want to switch to using | |
| 34 # src/untrusted/startup/nacl_startup.c | |
| 35 # c.f. http://code.google.com/p/nativeclient/issues/detail?id=651 | |
| 36 if env.Bit('bitcode'): | |
| 37 crt1 = env.ComponentObject('crt1', ['crt1_%s.S' % platform]) | |
| 38 else: | |
| 39 crt1 = env.ComponentObject('crt1', ['crt1_x86.S']) | |
| 40 | |
| 41 if env.Bit('bitcode'): | |
| 42 bookends = [] | |
| 43 else: | |
| 44 bookends = [env.ComponentObject('crti', ['crti_%s.S' % platform]), | |
| 45 env.ComponentObject('crtn', ['crtn_%s.S' % platform])] | |
| 46 | 28 |
| 47 # NOTE: we only provide setjmp/longjmp for pnacl, nacl-gcc obtains | 29 # NOTE: we only provide setjmp/longjmp for pnacl, nacl-gcc obtains |
| 48 # them from newlib, while pnacl's newlib is arch neutral | 30 # them from newlib, while pnacl's newlib is arch neutral |
| 49 platform_objs = [] | 31 platform_objs = [] |
| 50 | 32 |
| 51 if env.Bit('bitcode'): | 33 if env.Bit('bitcode'): |
| 52 platform_objs.append(env.StaticObject('setjmp.o', ['setjmp_%s.S' % platform])) | 34 bookends = [] |
| 35 platform_objs.append(native_env.StaticObject('setjmp.o', |
| 36 ['setjmp_%s.S' % platform])) |
| 37 else: |
| 38 bookends = [native_env.ComponentObject('crti', ['crti_%s.S' % platform]), |
| 39 native_env.ComponentObject('crtn', ['crtn_%s.S' % platform])] |
| 53 | 40 |
| 54 if env.Bit('target_arm'): | 41 if env.Bit('target_arm'): |
| 55 platform_objs.append('aeabi_read_tp.S') | 42 platform_objs.append('aeabi_read_tp.S') |
| 56 | 43 |
| 57 crt_platform = env.StaticLibrary('crt_platform', platform_objs) | 44 crt_platform = native_env.StaticLibrary('crt_platform', platform_objs) |
| 58 | 45 |
| 59 env.AddObjectToSdk([crt1, crt_platform] + bookends, is_platform=True) | 46 native_env.AddObjectToSdk([crt_platform] + bookends, is_platform=True) |
| OLD | NEW |