From eb73deb42bb3673e418348791971afa8573d2db4 Mon Sep 17 00:00:00 2001 From: slipher Date: Wed, 12 Aug 2026 19:50:38 -0500 Subject: [PATCH 1/6] scons: refactor SetUpLinuxEnv --- SConstruct | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index a579737e2..63ff2e597 100755 --- a/SConstruct +++ b/SConstruct @@ -2520,22 +2520,23 @@ def which(cmd, paths=os.environ.get('PATH', '').split(os.pathsep)): return True return False +def SetUpNoBuildEnv(env): + def FakeInstall(dest, source, env): + print('Not installing', dest) + # Replace build commands with no-ops + env.Replace(CC='true', CXX='true', LD='true', + AR='true', RANLIB='true', INSTALL=FakeInstall) + def SetUpLinuxEnvX86(env): if env.Bit('built_elsewhere'): - def FakeInstall(dest, source, env): - print('Not installing', dest) - # Replace build commands with no-ops - env.Replace(CC='true', CXX='true', LD='true', - AR='true', RANLIB='true', INSTALL=FakeInstall) + SetUpNoBuildEnv(env) else: - env.Prepend(CCFLAGS=sysroot_flags, - ASFLAGS=[], - ) + env.Prepend(CCFLAGS=sysroot_flags) if env.Bit('clang'): # TODO use --target=i386-linux-gnu or whetever? env.Prepend( - CCFLAGS = ['-m32'] + sysroot_flags, - LINKFLAGS = ['-m32'] + sysroot_flags, + CCFLAGS = ['-m32'], + LINKFLAGS = ['-m32'], ) else: env.Replace(CC='i686-linux-gnu-gcc', @@ -2547,15 +2548,9 @@ def SetUpLinuxEnvArm(env): # Allow emulation on non-ARM hosts. env.Replace(EMULATOR='qemu-armhf -L /usr/arm-linux-gnueabihf/ -cpu cortex-a9') if env.Bit('built_elsewhere'): - def FakeInstall(dest, source, env): - print('Not installing', dest) - # Replace build commands with no-ops - env.Replace(CC='true', CXX='true', LD='true', - AR='true', RANLIB='true', INSTALL=FakeInstall) + SetUpNoBuildEnv(env) else: - env.Prepend(CCFLAGS=sysroot_flags, - ASFLAGS=[], - ) + env.Prepend(CCFLAGS=sysroot_flags) if env.Bit('clang'): env.Prepend(CCFLAGS=['--target=arm-linux-gnueabihf']) env.Prepend(LINKFLAGS=['--target=arm-linux-gnueabihf']) From c7ada7c9796f8722095498bcfec154656d772c8b Mon Sep 17 00:00:00 2001 From: slipher Date: Wed, 12 Aug 2026 22:18:13 -0500 Subject: [PATCH 2/6] scons: support built_elsewhere with x86-64 --- SConstruct | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 63ff2e597..538b271b1 100755 --- a/SConstruct +++ b/SConstruct @@ -2543,6 +2543,16 @@ def SetUpLinuxEnvX86(env): CXX='i686-linux-gnu-g++', LD='i686-linux-gnu-ld') +def SetUpLinuxEnvX8664(env): + if env.Bit('built_elsewhere'): + SetUpNoBuildEnv(env) + else: + # Assumes x86-64 is the native platform for now + env.Prepend( + CCFLAGS = ['-m64'] + sysroot_flags, + LINKFLAGS = ['-m64'] + sysroot_flags, + ) + def SetUpLinuxEnvArm(env): if not platform.machine().startswith('a'): # Allow emulation on non-ARM hosts. @@ -2747,10 +2757,7 @@ def MakeGenericLinuxEnv(platform=None): if linux_env.Bit('build_x86_32'): SetUpLinuxEnvX86(linux_env) elif linux_env.Bit('build_x86_64'): - linux_env.Prepend( - CCFLAGS = ['-m64'] + sysroot_flags, - LINKFLAGS = ['-m64'] + sysroot_flags, - ) + SetUpLinuxEnvX8664(linux_env) elif linux_env.Bit('build_arm'): SetUpLinuxEnvArm(linux_env) elif linux_env.Bit('build_mips32'): From e7c28cb34781b3522b40b64346acd77ded72cdd3 Mon Sep 17 00:00:00 2001 From: slipher Date: Wed, 12 Aug 2026 22:18:44 -0500 Subject: [PATCH 3/6] scons: avoid KeyError in tests/gdb --- site_scons/site_tools/naclsdk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site_scons/site_tools/naclsdk.py b/site_scons/site_tools/naclsdk.py index 28ad4aa63..419166ae6 100755 --- a/site_scons/site_tools/naclsdk.py +++ b/site_scons/site_tools/naclsdk.py @@ -65,7 +65,8 @@ def _StubOutEnvToolsForBuiltElsewhere(env): env.Replace(CC='true', CXX='true', LINK='true', AR='true', RANLIB='true', AS='true', ASPP='true', LD='true', STRIP='true', OBJDUMP='true', OBJCOPY='true', - PNACLOPT='true', PNACLFINALIZE='true') + PNACLOPT='true', PNACLFINALIZE='true', + GDB='false') def _SetEnvForNativeSdk(env, sdk_path): From 7d451aae00bae3dc07b8ebcc7b28156a9411a693 Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 16 Aug 2026 23:19:32 -0500 Subject: [PATCH 4/6] scons: Add run_strip_test nexe to all_programs So that it works with built_elsewhere. --- tests/toolchain/nacl.scons | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/toolchain/nacl.scons b/tests/toolchain/nacl.scons index a098fbd17..9dedce569 100644 --- a/tests/toolchain/nacl.scons +++ b/tests/toolchain/nacl.scons @@ -515,6 +515,7 @@ if not env.Bit('pnacl_generate_pexe'): # Test that both the layout and the nops are not munged by stripping. stripped_nexe = asm_env.Command('strip_test.nexe', nexe, '${STRIP} -o ${TARGET} ${SOURCES}') + asm_env.Alias('all_programs', stripped_nexe) node = asm_env.CommandSelLdrTestNacl('strip_test.out', stripped_nexe) asm_env.AddNodeToTestSuite(node, testsuite, 'run_strip_test') From bcba87d92d5c64374523fcfd84929a859a29d5cf Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 16 Aug 2026 23:19:32 -0500 Subject: [PATCH 5/6] Disable run_dis_section_test_* with built_elsewhere=1 objdump is replaced with the 'true' command with built_elsewhere. --- src/trusted/validator_ragel/build.scons | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trusted/validator_ragel/build.scons b/src/trusted/validator_ragel/build.scons index 0ecf5b70b..cbbc888b7 100644 --- a/src/trusted/validator_ragel/build.scons +++ b/src/trusted/validator_ragel/build.scons @@ -548,6 +548,7 @@ for bits in ['32', '64']: env.AddNodeToTestSuite( dis_section_test, ['small_tests', 'validator_tests'], + is_broken=env.Bit('built_elsewhere'), # OBJDUMP is stubbed out node_name='run_dis_section_test_%s' % bits) if env.Bit('regenerate_golden'): From 2ccbfd29d12a2a1a6d3007053517110ccc2d2470 Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 16 Aug 2026 23:19:32 -0500 Subject: [PATCH 6/6] Alleviate race condition in nacl_sync_test The test intentionally creates deadlocks from locking a mutex twice. Then a 2nd thread is supposed to decide the test's exit code in the event that a deadlock happens. But when testing with the box64 emulator, shutting down the program can be slow and the timeout thread triggered while the program was exiting normally and changed the exit code. Stop this from happening by setting a flag when the test is done, telling the other thread not to call exit(). --- src/shared/platform/nacl_sync_test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shared/platform/nacl_sync_test.c b/src/shared/platform/nacl_sync_test.c index 8aeb5ee93..4a29c568d 100644 --- a/src/shared/platform/nacl_sync_test.c +++ b/src/shared/platform/nacl_sync_test.c @@ -80,6 +80,8 @@ */ uint32_t g_timeout_milliseconds = 500; +volatile int g_done = 0; + /* * TimeOutThread is responsible for doing deadlock detection. If the * main thread hits a deadlock, then this thread will time out and @@ -114,7 +116,9 @@ void WINAPI TimeOutThread(void *thread_state) { * If we reach here, we assume that the main thread has deadlocked * and so we optimistically report that via the exit status. */ - exit(time_out_exit_status); + if (!g_done) { + exit(time_out_exit_status); + } } /* @@ -178,7 +182,7 @@ int TestLockTrylock(void) { int TestTrylockLock(void) { struct NaClMutex mu; struct NaClThread nt; - printf("TestLockTrylock\n"); + printf("TestTrylockLock\n"); printf("Constructing mutex\n"); if (!NaClMutexCtor(&mu)) return 1; printf("Trylocking mutex\n"); @@ -200,7 +204,7 @@ int TestTrylockLock(void) { int TestTrylockTrylock(void) { struct NaClMutex mu; struct NaClThread nt; - printf("TestLockTrylock\n"); + printf("TestTrylockTrylock\n"); printf("Constructing mutex\n"); if (!NaClMutexCtor(&mu)) return 1; printf("Trylocking mutex\n"); @@ -276,6 +280,7 @@ int main(int ac, char **av) { } NaClPlatformInit(); retcode = (*test_fn)(); + g_done = 1; NaClPlatformFini(); return retcode; }