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