From 79da1f6803df549aea8ddc7683d65ee459f3a6bc Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 11:09:40 -0300 Subject: [PATCH] cobalt: the no-exceptions driver and stack probe under the -O3 link The superproject links an emscripten program at its compile's level of optimization (webcpporg/webcpp#18), -O3 in a release build, which turns Emscripten's ASSERTIONS off. Native code's abort() then prints "Aborted()" where a debug link prints "Aborted(native code called abort())", and the driver of test/no_exceptions, which required the second, failed move_off and borrowed_race_off in release, in the exceptions and borrowed_race lanes. It now requires either line, exactly: no other abort of Emscripten's runtime has an empty reason, and a trap, or an abort for another reason, prints neither. Checked against both builds, and against stand-in programs that trap or abort for another reason, which it rejects. cobalt_stack_optimized_link_* linked release with -O3, which release now does itself; the probe keeps its debug and release builds. --- test/Jamfile | 6 ++++-- test/no_exceptions/driver.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index cbb40f3..0b58ce3 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -111,10 +111,12 @@ for local handling in on off webcpp.lane cobalt : $(.cobalt) : native emscripten ; webcpp.lane cobalt_asyncify : $(.cobalt-emscripten) : emscripten ; +# Cobalt's suspensions leave half of Asyncify's stack in each build a +# program can get, whatever variant the lane builds: debug, compiled and +# linked at -O0, the deepest, and release, at -O3. .asyncify-stack-debug = debug ; .asyncify-stack-release = release ; -.asyncify-stack-optimized_link = release -O3 ; -for local build in debug release optimized_link +for local build in debug release { for local handling in on off { diff --git a/test/no_exceptions/driver.py b/test/no_exceptions/driver.py index c3974be..f261ca1 100644 --- a/test/no_exceptions/driver.py +++ b/test/no_exceptions/driver.py @@ -37,12 +37,19 @@ if expected_abort: assert result.returncode != 0, result.stdout + result.stderr assert 'after move\n' not in result.stderr, result.stderr - # Emscripten's release libc++ omits the native verbose-abort text. - # The direct exception-ptr control identifies the same runtime path. - diagnostic = ('RuntimeError: Aborted(native code called abort())' if - program.endswith('.js') else - 'make_exception_ptr was called in -fno-exceptions mode') - assert diagnostic in result.stderr, result.stderr + if program.endswith('.js'): + # Emscripten's abort prints the line Aborted() before it + # throws. A link with ASSERTIONS (debug, at -O0) gives native + # code's abort() its reason; a link without them (release, at + # -O3) gives it none, and omits libc++'s verbose-abort text. No + # other abort of Emscripten's runtime has an empty reason, and a + # trap, or an abort for another reason, prints another line. + native_abort = {'Aborted(native code called abort())', 'Aborted()'} + assert native_abort & set(result.stderr.splitlines()), result.stderr + else: + # The direct exception-ptr control identifies the same runtime path. + assert ('make_exception_ptr was called in -fno-exceptions mode' + in result.stderr), result.stderr verdict = 'known-libc++-abort' else: assert result.returncode == 0, result.stdout + result.stderr