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 os | 7 import os |
8 import platform | 8 import platform |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 2241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2252 ]) | 2252 ]) |
2253 # /usr/lib makes sense for most configuration except this one | 2253 # /usr/lib makes sense for most configuration except this one |
2254 # No ARM compatible libs can be found there. | 2254 # No ARM compatible libs can be found there. |
2255 # So this just makes the command lines longer and sometimes results | 2255 # So this just makes the command lines longer and sometimes results |
2256 # in linker warnings referring to this directory. | 2256 # in linker warnings referring to this directory. |
2257 env.FilterOut(LIBPATH=['/usr/lib']) | 2257 env.FilterOut(LIBPATH=['/usr/lib']) |
2258 | 2258 |
2259 # get_plugin_dirname.cc has a dependency on dladdr | 2259 # get_plugin_dirname.cc has a dependency on dladdr |
2260 env.Append(LIBS=['dl']) | 2260 env.Append(LIBS=['dl']) |
2261 | 2261 |
2262 def SetupLinuxEnvMips(env): | |
2263 jail = '${SCONSTRUCT_DIR}/toolchain/linux_mips-trusted' | |
2264 if env.Bit('built_elsewhere'): | |
2265 def FakeInstall(dest, source, env): | |
2266 print 'Not installing', dest | |
2267 # Replace build commands with no-ops | |
2268 env.Replace(CC='true', CXX='true', LD='true', | |
2269 AR='true', RANLIB='true', INSTALL=FakeInstall) | |
2270 # Allow emulation on x86 hosts for testing built_elsewhere flag | |
2271 if not platform.machine().startswith('mips'): | |
2272 env.Replace(EMULATOR=jail + '/run_under_qemu_mips32') | |
2273 else: | |
2274 TC_DIR = os.path.join(os.getcwd(), 'toolchain', 'linux_mips-trusted', | |
Mark Seaborn
2012/09/20 02:40:42
Nit: use lower-case 'TC_DIR'
petarj
2012/09/20 15:33:00
Done.
| |
2275 'mips-release', 'bin') | |
2276 if not which(os.path.join(TC_DIR,'mips-linux-gnu-gcc')): | |
Mark Seaborn
2012/09/20 02:40:42
Nit: add space after comma. Same below.
petarj
2012/09/20 15:33:00
Done.
| |
2277 print ("\nERRROR: MIPS trusted TC is not installed - try running:\n" | |
2278 "tools/trusted_cross_toolchains/trusted-toolchain-creator" | |
2279 ".mipsel.squeeze.sh trusted_sdk") | |
2280 sys.exit(-1) | |
2281 env.Replace(CC=os.path.join(TC_DIR,'mips-linux-gnu-gcc'), | |
2282 CXX=os.path.join(TC_DIR,'mips-linux-gnu-g++'), | |
2283 LD=os.path.join(TC_DIR,'mips-linux-gnu-ld'), | |
2284 EMULATOR=os.path.join(jail, | |
2285 'run_under_qemu_mips32'), | |
2286 ASFLAGS=[], | |
2287 LIBPATH=['${LIB_DIR}', | |
2288 jail + '/mips-release/mips-linux-gnu/libc/el/usr/lib'], | |
2289 LINKFLAGS=['-EL', '-T', | |
2290 os.path.join(jail,'ld_script_mips_trusted')] | |
2291 ) | |
2292 | |
2293 env.Append(LIBS=['rt', 'dl', 'pthread'], | |
2294 CCFLAGS=['-EL', '-Wl,-EL', '-march=mips32r2']) | |
2295 | |
2262 def MakeLinuxEnv(): | 2296 def MakeLinuxEnv(): |
2263 linux_env = MakeUnixLikeEnv().Clone( | 2297 linux_env = MakeUnixLikeEnv().Clone( |
2264 BUILD_TYPE = '${OPTIMIZATION_LEVEL}-linux', | 2298 BUILD_TYPE = '${OPTIMIZATION_LEVEL}-linux', |
2265 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', | 2299 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', |
2266 tools = ['target_platform_linux'], | 2300 tools = ['target_platform_linux'], |
2267 # TODO(bradnelson): this should really be able to live in unix_like_env | 2301 # TODO(bradnelson): this should really be able to live in unix_like_env |
2268 # but can't due to what the target_platform_x module is | 2302 # but can't due to what the target_platform_x module is |
2269 # doing. | 2303 # doing. |
2270 LINK = '$CXX', | 2304 LINK = '$CXX', |
2271 ) | 2305 ) |
(...skipping 18 matching lines...) Expand all Loading... | |
2290 LINKFLAGS = ['-m32', '-L/usr/lib32', ], | 2324 LINKFLAGS = ['-m32', '-L/usr/lib32', ], |
2291 ) | 2325 ) |
2292 elif linux_env.Bit('build_x86_64'): | 2326 elif linux_env.Bit('build_x86_64'): |
2293 linux_env.Prepend( | 2327 linux_env.Prepend( |
2294 CCFLAGS = ['-m64', ], | 2328 CCFLAGS = ['-m64', ], |
2295 LINKFLAGS = ['-m64', '-L/usr/lib64', ], | 2329 LINKFLAGS = ['-m64', '-L/usr/lib64', ], |
2296 ) | 2330 ) |
2297 elif linux_env.Bit('build_arm'): | 2331 elif linux_env.Bit('build_arm'): |
2298 SetupLinuxEnvArm(linux_env) | 2332 SetupLinuxEnvArm(linux_env) |
2299 elif linux_env.Bit('build_mips32'): | 2333 elif linux_env.Bit('build_mips32'): |
2300 # TODO(petarj): Add support for MIPS. | 2334 SetupLinuxEnvMips(linux_env) |
2301 pass | |
2302 else: | 2335 else: |
2303 Banner('Strange platform: %s' % GetPlatform()) | 2336 Banner('Strange platform: %s' % GetPlatform()) |
2304 | 2337 |
2305 # These are desireable options for every Linux platform: | 2338 # These are desireable options for every Linux platform: |
2306 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions | 2339 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions |
2307 # -fPIE/-pie: create a position-independent executable | 2340 # -fPIE/-pie: create a position-independent executable |
2308 # relro/now: "hardening" options for linking | 2341 # relro/now: "hardening" options for linking |
2309 # noexecstack: ensure that the executable does not get a PT_GNU_STACK | 2342 # noexecstack: ensure that the executable does not get a PT_GNU_STACK |
2310 # header that causes the kernel to set the READ_IMPLIES_EXEC | 2343 # header that causes the kernel to set the READ_IMPLIES_EXEC |
2311 # personality flag, which disables NX page protection. | 2344 # personality flag, which disables NX page protection. |
2312 linux_env.Prepend( | 2345 linux_env.Prepend( |
2313 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], | 2346 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], |
2314 LINKFLAGS=['-pie', '-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'], | 2347 LINKFLAGS=['-pie', '-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'], |
2315 ) | 2348 ) |
2316 # The ARM toolchain has a linker that doesn't handle the code its | 2349 # The ARM toolchain has a linker that doesn't handle the code its |
2317 # compiler generates under -fPIE. | 2350 # compiler generates under -fPIE. |
2318 if linux_env.Bit('build_arm'): | 2351 if linux_env.Bit('build_arm') or linux_env.Bit('build_mips32'): |
2319 linux_env.Prepend(CCFLAGS=['-fPIC']) | 2352 linux_env.Prepend(CCFLAGS=['-fPIC']) |
2320 # TODO(mcgrathr): Temporarily punt _FORTIFY_SOURCE for ARM because | 2353 # TODO(mcgrathr): Temporarily punt _FORTIFY_SOURCE for ARM because |
2321 # it causes a libc dependency newer than the old bots have installed. | 2354 # it causes a libc dependency newer than the old bots have installed. |
2322 linux_env.FilterOut(CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']]) | 2355 linux_env.FilterOut(CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']]) |
2323 else: | 2356 else: |
2324 linux_env.Prepend(CCFLAGS=['-fPIE']) | 2357 linux_env.Prepend(CCFLAGS=['-fPIE']) |
2325 | 2358 |
2326 # We always want to use the same flags for .S as for .c because | 2359 # We always want to use the same flags for .S as for .c because |
2327 # code-generation flags affect the predefines we might test there. | 2360 # code-generation flags affect the predefines we might test there. |
2328 linux_env.Replace(ASFLAGS=['${CCFLAGS}']) | 2361 linux_env.Replace(ASFLAGS=['${CCFLAGS}']) |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3275 nacl_env.ValidateSdk() | 3308 nacl_env.ValidateSdk() |
3276 | 3309 |
3277 if BROKEN_TEST_COUNT > 0: | 3310 if BROKEN_TEST_COUNT > 0: |
3278 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3311 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3279 if GetOption('brief_comstr'): | 3312 if GetOption('brief_comstr'): |
3280 msg += " Add --verbose to the command line for more information." | 3313 msg += " Add --verbose to the command line for more information." |
3281 print msg | 3314 print msg |
3282 | 3315 |
3283 # separate warnings from actual build output | 3316 # separate warnings from actual build output |
3284 Banner('B U I L D - O U T P U T:') | 3317 Banner('B U I L D - O U T P U T:') |
OLD | NEW |