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 sys.path.append('tools/trusted_cross_toolchains') |
| 2275 from setup_mips32_trusted_toolchain import mips32_env |
| 2276 sys.path.pop() |
| 2277 # Allow env vars to override these settings, for what it's worth. |
| 2278 mips32_env = mips32_env.copy() |
| 2279 mips32_env.update(os.environ) |
| 2280 env.Replace(CC=mips32_env.get('MIPS32_CC', 'NO-MIPSEL-CC-SPECIFIED'), |
| 2281 CXX=mips32_env.get('MIPS32_CXX', 'NO-MIPSEL-CXX-SPECIFIED'), |
| 2282 LD=mips32_env.get('MIPS32_LD', 'NO-MIPSEL-LD-SPECIFIED'), |
| 2283 EMULATOR=mips32_env.get('MIPS32_EMU', ''), |
| 2284 ASFLAGS=[], |
| 2285 LIBPATH=['${LIB_DIR}', |
| 2286 mips32_env.get('MIPS32_LIB_DIR', '').split()], |
| 2287 LINKFLAGS=mips32_env.get('MIPS32_LINKFLAGS', ''), |
| 2288 ) |
| 2289 |
| 2290 env.Append(LIBS=['rt', 'dl', 'pthread'], |
| 2291 CCFLAGS=['-EL', '-Wl,-EL', '-march=mips32r2']) |
| 2292 |
2262 def MakeLinuxEnv(): | 2293 def MakeLinuxEnv(): |
2263 linux_env = MakeUnixLikeEnv().Clone( | 2294 linux_env = MakeUnixLikeEnv().Clone( |
2264 BUILD_TYPE = '${OPTIMIZATION_LEVEL}-linux', | 2295 BUILD_TYPE = '${OPTIMIZATION_LEVEL}-linux', |
2265 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', | 2296 BUILD_TYPE_DESCRIPTION = 'Linux ${OPTIMIZATION_LEVEL} build', |
2266 tools = ['target_platform_linux'], | 2297 tools = ['target_platform_linux'], |
2267 # TODO(bradnelson): this should really be able to live in unix_like_env | 2298 # 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 | 2299 # but can't due to what the target_platform_x module is |
2269 # doing. | 2300 # doing. |
2270 LINK = '$CXX', | 2301 LINK = '$CXX', |
2271 ) | 2302 ) |
(...skipping 18 matching lines...) Expand all Loading... |
2290 LINKFLAGS = ['-m32', '-L/usr/lib32', ], | 2321 LINKFLAGS = ['-m32', '-L/usr/lib32', ], |
2291 ) | 2322 ) |
2292 elif linux_env.Bit('build_x86_64'): | 2323 elif linux_env.Bit('build_x86_64'): |
2293 linux_env.Prepend( | 2324 linux_env.Prepend( |
2294 CCFLAGS = ['-m64', ], | 2325 CCFLAGS = ['-m64', ], |
2295 LINKFLAGS = ['-m64', '-L/usr/lib64', ], | 2326 LINKFLAGS = ['-m64', '-L/usr/lib64', ], |
2296 ) | 2327 ) |
2297 elif linux_env.Bit('build_arm'): | 2328 elif linux_env.Bit('build_arm'): |
2298 SetupLinuxEnvArm(linux_env) | 2329 SetupLinuxEnvArm(linux_env) |
2299 elif linux_env.Bit('build_mips32'): | 2330 elif linux_env.Bit('build_mips32'): |
2300 # TODO(petarj): Add support for MIPS. | 2331 SetupLinuxEnvMips(linux_env) |
2301 pass | |
2302 else: | 2332 else: |
2303 Banner('Strange platform: %s' % GetPlatform()) | 2333 Banner('Strange platform: %s' % GetPlatform()) |
2304 | 2334 |
2305 # These are desireable options for every Linux platform: | 2335 # These are desireable options for every Linux platform: |
2306 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions | 2336 # _FORTIFY_SOURCE: general paranoia "hardening" option for library functions |
2307 # -fPIE/-pie: create a position-independent executable | 2337 # -fPIE/-pie: create a position-independent executable |
2308 # relro/now: "hardening" options for linking | 2338 # relro/now: "hardening" options for linking |
2309 # noexecstack: ensure that the executable does not get a PT_GNU_STACK | 2339 # noexecstack: ensure that the executable does not get a PT_GNU_STACK |
2310 # header that causes the kernel to set the READ_IMPLIES_EXEC | 2340 # header that causes the kernel to set the READ_IMPLIES_EXEC |
2311 # personality flag, which disables NX page protection. | 2341 # personality flag, which disables NX page protection. |
2312 linux_env.Prepend( | 2342 linux_env.Prepend( |
2313 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], | 2343 CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']], |
2314 LINKFLAGS=['-pie', '-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'], | 2344 LINKFLAGS=['-pie', '-Wl,-z,relro', '-Wl,-z,now', '-Wl,-z,noexecstack'], |
2315 ) | 2345 ) |
2316 # The ARM toolchain has a linker that doesn't handle the code its | 2346 # The ARM toolchain has a linker that doesn't handle the code its |
2317 # compiler generates under -fPIE. | 2347 # compiler generates under -fPIE. |
2318 if linux_env.Bit('build_arm'): | 2348 if linux_env.Bit('build_arm') or linux_env.Bit('build_mips32'): |
2319 linux_env.Prepend(CCFLAGS=['-fPIC']) | 2349 linux_env.Prepend(CCFLAGS=['-fPIC']) |
2320 # TODO(mcgrathr): Temporarily punt _FORTIFY_SOURCE for ARM because | 2350 # TODO(mcgrathr): Temporarily punt _FORTIFY_SOURCE for ARM because |
2321 # it causes a libc dependency newer than the old bots have installed. | 2351 # it causes a libc dependency newer than the old bots have installed. |
2322 linux_env.FilterOut(CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']]) | 2352 linux_env.FilterOut(CPPDEFINES=[['-D_FORTIFY_SOURCE', '2']]) |
2323 else: | 2353 else: |
2324 linux_env.Prepend(CCFLAGS=['-fPIE']) | 2354 linux_env.Prepend(CCFLAGS=['-fPIE']) |
2325 | 2355 |
2326 # We always want to use the same flags for .S as for .c because | 2356 # 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. | 2357 # code-generation flags affect the predefines we might test there. |
2328 linux_env.Replace(ASFLAGS=['${CCFLAGS}']) | 2358 linux_env.Replace(ASFLAGS=['${CCFLAGS}']) |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3275 nacl_env.ValidateSdk() | 3305 nacl_env.ValidateSdk() |
3276 | 3306 |
3277 if BROKEN_TEST_COUNT > 0: | 3307 if BROKEN_TEST_COUNT > 0: |
3278 msg = "There are %d broken tests." % BROKEN_TEST_COUNT | 3308 msg = "There are %d broken tests." % BROKEN_TEST_COUNT |
3279 if GetOption('brief_comstr'): | 3309 if GetOption('brief_comstr'): |
3280 msg += " Add --verbose to the command line for more information." | 3310 msg += " Add --verbose to the command line for more information." |
3281 print msg | 3311 print msg |
3282 | 3312 |
3283 # separate warnings from actual build output | 3313 # separate warnings from actual build output |
3284 Banner('B U I L D - O U T P U T:') | 3314 Banner('B U I L D - O U T P U T:') |
OLD | NEW |