Skip to content

Commit a8ce8f6

Browse files
committed
Re-enable NaCl toolchains when requested
With some minor fixes, the build is able to run and produce an irt_core binary when configured with the Saigo toolchain. Added documentation how to do this to the README. Still keeping the 'if nacltools' guards I added so that sel_ldr can be built without acquiring any NaCl toolchains.
1 parent b20136b commit a8ce8f6

File tree

4 files changed

+42
-17
lines changed

4 files changed

+42
-17
lines changed

README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,28 @@ Dependencies:
77
- LLVM (must be installed in /usr/bin)
88
- SCons
99

10-
Build with:
10+
### Build the NaCl loader and boostrap loader
1111
```
12-
scons platform=x86-64 MODE=opt-host naclsdk_validate=0 sysinfo=0 sel_ldr
12+
scons --mode=opt-host platform=x86-64 sel_ldr
13+
```
14+
15+
### Build the IRT
16+
This requires the Saigo NaCl toolchain. You can provide it by either
17+
(a) passing `saigo_newlib_dir=<path>` on the command line (the directory
18+
you want to target is normally called `saigo_newlib`), or
19+
(b) dropping the toolchain in `toolchain/linux_x86/` and renaming its
20+
top-level directory from `saigo_newlib` to `saigo_newlib_raw`.
21+
22+
The following command builds one `irt_core_raw.nexe`. You need to strip it
23+
yourself; ordinary Linux `strip` seems to work.
24+
```
25+
scons --mode=nacl saigo=1 platform=x86-64 irt_core_raw [optional saigo_newlib_dir=...]
26+
```
27+
28+
### Try some tests
29+
This builds both components and runs some tests.
30+
```
31+
scons --mode=opt-host,nacl saigo=1 platform=x86-64 --keep-going small_tests medium_tests
1332
```
1433
---
1534

SConstruct

+9-11
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ import pynacl.platform
3434
import gc
3535
gc.disable()
3636

37-
nacltool = False # Daemon: not yet implemented
38-
3937
# REPORT
4038
CMD_COUNTER = {}
4139
ENV_COUNTER = {}
@@ -2798,7 +2796,7 @@ pre_base_env.Append(
27982796
nacl_env = MakeArchSpecificEnv()
27992797
# See comment below about libc++ and libpthread in NONIRT_LIBS.
28002798
using_nacl_libcxx = nacl_env.Bit('bitcode') or nacl_env.Bit('nacl_clang')
2801-
if nacltool: nacl_env = nacl_env.Clone(
2799+
if UsingNaclMode(): nacl_env = nacl_env.Clone(
28022800
tools = ['naclsdk'],
28032801
NACL_BUILD_FAMILY = 'UNTRUSTED',
28042802
BUILD_TYPE = 'nacl',
@@ -3138,7 +3136,7 @@ if nacl_env.Bit('running_on_valgrind'):
31383136
nacl_env.Append(LINKFLAGS = ['-Wl,-u,have_nacl_valgrind_interceptors'],
31393137
LIBS = ['valgrind'])
31403138

3141-
if nacltool: environment_list.append(nacl_env)
3139+
if UsingNaclMode(): environment_list.append(nacl_env)
31423140

31433141
if not nacl_env.Bit('nacl_glibc'):
31443142
# These are all specific to nacl-newlib so we do not include them
@@ -3392,11 +3390,11 @@ nacl_irt_env.ClearBits('bitcode')
33923390
# used to build user/test code. nacl-clang is used everywhere for the IRT.
33933391
nacl_irt_env.SetBits('nacl_clang')
33943392

3395-
if nacltool: nacl_irt_env.Tool('naclsdk')
3393+
if UsingNaclMode(): nacl_irt_env.Tool('naclsdk')
33963394
# These are unfortunately clobbered by running Tool, which
33973395
# we needed to do to get the destination directory reset.
33983396
# We want all the same values from nacl_env.
3399-
if nacltool: nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'],
3397+
if UsingNaclMode(): nacl_irt_env.Replace(EXTRA_CFLAGS=nacl_env['EXTRA_CFLAGS'],
34003398
EXTRA_CXXFLAGS=nacl_env['EXTRA_CXXFLAGS'],
34013399
CCFLAGS=nacl_env['CCFLAGS'],
34023400
CFLAGS=nacl_env['CFLAGS'],
@@ -3417,7 +3415,7 @@ if nacl_irt_env.Bit('build_x86_32'):
34173415
# The IRT is C only, don't link with the C++ linker so that it doesn't
34183416
# start depending on the C++ standard library and (in the case of
34193417
# libc++) pthread.
3420-
if nacltool: nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK'].
3418+
if UsingNaclMode(): nacl_irt_env.Replace(LINK=(nacl_irt_env['LINK'].
34213419
replace('nacl-clang++', 'nacl-clang')))
34223420

34233421
# TODO(mcgrathr): Clean up uses of these methods.
@@ -3533,8 +3531,8 @@ def AddImplicitLibs(env):
35333531
# The -B<dir>/ flag is necessary to tell gcc to look for crt[1in].o there.
35343532
env.Prepend(LINKFLAGS=['-B${LIB_DIR}/'])
35353533

3536-
if nacltool: AddImplicitLibs(nacl_env)
3537-
if nacltool: AddImplicitLibs(nacl_irt_env)
3534+
if UsingNaclMode(): AddImplicitLibs(nacl_env)
3535+
if UsingNaclMode(): AddImplicitLibs(nacl_irt_env)
35383536

35393537
nacl_irt_env.Append(
35403538
BUILD_SCONSCRIPTS = [
@@ -3549,7 +3547,7 @@ nacl_irt_env.Append(
35493547
])
35503548
nacl_irt_env.AddChromeFilesFromGroup('untrusted_irt_scons_files')
35513549

3552-
if nacltool: environment_list.append(nacl_irt_env)
3550+
if UsingNaclMode(): environment_list.append(nacl_irt_env)
35533551

35543552
# Since browser_tests already use the IRT normally, those are fully covered
35553553
# in nacl_env. But the non_browser_tests don't use the IRT in nacl_env.
@@ -3614,7 +3612,7 @@ def IrtTestAddNodeToTestSuite(env, node, suite_name, node_name=None,
36143612
is_broken, is_flaky)
36153613
nacl_irt_test_env.AddMethod(IrtTestAddNodeToTestSuite, 'AddNodeToTestSuite')
36163614

3617-
if nacltool: environment_list.append(nacl_irt_test_env)
3615+
if UsingNaclMode(): environment_list.append(nacl_irt_test_env)
36183616

36193617

36203618
windows_coverage_env = windows_debug_env.Clone(

site_scons/site_init.py

+5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ def BuildEnvironmentSConscripts(env):
131131
'Bad location for a SConscript. "%s" is not under '
132132
'\$TARGET_ROOT or \$MAIN_DIR' % c_script)
133133

134+
def UsingNaclMode():
135+
build_modes = SCons.Script.ARGUMENTS.get('MODE') or SCons.Script.GetOption('build_mode')
136+
build_modes = build_modes.split(',')
137+
return any('nacl' in mode for mode in build_modes)
138+
134139
def FilterEnvironments(environments):
135140
"""Filters out the environments to be actually build from the specified list
136141

src/trusted/validator_ragel/build.scons

+7-4
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,13 @@ ragel_targets = set([
164164
'dfachecktries'])
165165
ragel_involved = ragel_targets.intersection(COMMAND_LINE_TARGETS)
166166

167-
#gas = env.MakeUntrustedNativeEnv()['AS']
168-
#objdump = env.MakeUntrustedNativeEnv()['OBJDUMP']
169-
gas = "AAAAAAAAAAAAA"
170-
objdump = "BBBBBBB"
167+
if UsingNaclMode():
168+
gas = env.MakeUntrustedNativeEnv()['AS']
169+
objdump = env.MakeUntrustedNativeEnv()['OBJDUMP']
170+
else:
171+
gas = 'AS_UNAVAILABLE_WITHOUT_MODE_NACL'
172+
objdump = 'OBJDUMP_UNAVAILABLE_WITHOUT_MODE_NACL'
173+
171174

172175
if ragel_involved:
173176
if not env.Bit('host_linux'):

0 commit comments

Comments
 (0)