Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,20 @@ outside JSPI, gives the module's exports short names: an abort prints
only what the program uses. `tools/test/emscripten_test.py` pins each level
and its order.

**A program on wasip2 or wasip3 built without debug symbols carries no debug
information** (the Jamroot's region `wasi-strip-debug`): with
`<debug-symbols>off`, as a release build has it, it links with
`-Wl,--strip-debug`, which wasm-component-ld passes to wasm-ld, so the core
module of the component has no `.debug` section. wasi-sdk's prebuilt libc++,
libc++abi and libunwind carry DWARF, which wasm-ld otherwise copies into
every program that links them, a release one too: xactor's release example
`xactor_quick_start` was 3,489,365 bytes on wasip2 and is 397,678. A debug
build, or a release that asks for `debug-symbols=on`, keeps it.
`tools/test/webcpp_jam_test.py` reads every custom section of a release, a
debug and a `debug-symbols=on` program on both targets, nested core modules
included. An Emscripten release link, at `-O3`, keeps no debug section
already.

**The suspension variant on emscripten.** A program on emscripten that
suspends, waiting inside a call for the browser's event loop, is built for
one of two variants, the feature `webcpp-suspend` (the region `suspend` of
Expand Down
8 changes: 8 additions & 0 deletions CODING-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,14 @@ site's own decisions follow in the next sections.
late value keeps gcc's Unix link options (`--start-group`, `-Bstatic`,
rpath), which wasm-component-ld rejects, from being chosen.
Source: `AGENTS.md` (webcpp); `Jamroot` (webcpp).
- **A wasip2 or wasip3 program built without debug symbols, as a release
is, carries no debug information: the Jamroot links it with
`-Wl,--strip-debug` (its region `wasi-strip-debug`); a debug build keeps
its DWARF.** The owner decided it on 2026-11-17. wasi-sdk's prebuilt
libc++, libc++abi and libunwind carry DWARF, which wasm-ld copied into
every program: a release example of xactor was 3,489,365 bytes on wasip2,
397,678 without it.
Source: `AGENTS.md` (webcpp); `Jamroot` (webcpp).
- **Every target builds with exceptions on and RTTI is never restricted; a
build without exceptions is its builder's choice, which every library
supports.** Whether a program uses exceptions is the choice of whoever
Expand Down
11 changes: 11 additions & 0 deletions Jamroot
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ project /webcpp
<toolset>clang-wasip3,<exception-handling>on:<cxxflags>"-fwasm-exceptions -mllvm -wasm-use-legacy-eh=false"
<toolset>clang-wasip3,<exception-handling>on:<linkflags>"-fwasm-exceptions -lunwind"
# end::wasi-exceptions[]
# wasi-sdk's prebuilt libc++, libc++abi and libunwind carry DWARF, which
# wasm-ld copies into every program that links them, a release one
# too: up to most of its bytes, naming the paths of the machine that
# built wasi-sdk. A program built without debug symbols, as a release
# is, is linked with --strip-debug, which wasm-component-ld passes to
# wasm-ld, so the core module of a wasip2 or wasip3 component has no
# .debug section. A debug build, or one that asks for debug-symbols=on,
# keeps them.
# tag::wasi-strip-debug[]
<target-os>wasi,<debug-symbols>off:<linkflags>-Wl,--strip-debug
# end::wasi-strip-debug[]
# The compiler first: a broken one would fail Boost's check too.
<conditional>@gcc-probe
<conditional>@boost-check
Expand Down
1 change: 1 addition & 0 deletions doc/releases/0.1.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ None.
== Tools and build

* Fixed emscripten release programs linking unoptimized; they now link at `-O3`.
* Fixed WASI release programs carrying wasi-sdk's libc++ debug information, most of their size; they now link with `--strip-debug`.
* Fixed clean CMake consumer audits rejecting system libraries and phony dependency rules.
* Changed CI to consume verified prepared environments without rebuilding images in PR jobs.
* Added verified archive caches and isolated container availability from unrelated CI lanes.
Expand Down
61 changes: 60 additions & 1 deletion tools/test/webcpp_jam_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"""Checks tools/webcpp.jam: a program is built only for the targets its Jamfile declares, and only
once per target; every target builds with exceptions, and a build without them is the user's own
request, which links the handler on any target and reaches every program but one that declares
<exception-handling>on; no variant is built without RTTI; an example is compared with its expected
<exception-handling>on; a WASI program built without debug symbols, as a release is, carries no
debug information in any core module of its component, and one built with them keeps it; no variant
is built without RTTI; an example is compared with its expected
output, its standard input its .input file or nothing; every public header compiles alone, each call
of webcpp.headers-alone taking the headers its globs match, with requirements and targets of its
own, and a header two calls take or a glob that matches none refused; a compile-diagnostic test
Expand Down Expand Up @@ -76,6 +78,40 @@ def stand_in_emscripten(root):
config.write_text(config.read_text() + f'using emscripten : : "{emcc}" ;\n')


def leb128(data, offset):
"""The unsigned LEB128 number at offset in data, and the offset after it."""
value = shift = 0
while True:
byte = data[offset]
offset += 1
value |= (byte & 0x7f) << shift
shift += 7
if not byte & 0x80:
return value, offset


def custom_sections(data):
"""The names of the custom sections of the WebAssembly binary data, a core module or a
component, and of every core module and component a component nests, at any depth."""
assert data[:4] == b'\0asm', data[:8]
layer = int.from_bytes(data[6:8], 'little')
names = []
offset = 8
while offset < len(data):
identifier = data[offset]
size, offset = leb128(data, offset + 1)
body = data[offset:offset + size]
if identifier == 0:
length, start = leb128(body, 0)
names.append(body[start:start + length].decode())
elif layer == 1 and identifier in (1, 4):
# A component's core module section (1) and component section (4) each hold a whole
# binary of their own.
names += custom_sections(body)
offset += size
return names


NATIVE_DEMO = {'pass', 'fails', 'rejects', 'native_only', 'native_only_compiles', 'alone-demo',
'alone-demo-answer', 'suite', 'parses_json'}

Expand Down Expand Up @@ -161,6 +197,28 @@ def test_wasip3_catches_a_throw(root):
assert 'legacy_exceptions feature required' in refused.stdout, (version, refused.stdout)


def test_a_wasi_release_program_carries_no_debug_information(root):
# wasi-sdk's prebuilt libc++ and libc++abi carry DWARF, which wasm-ld would copy into every
# program, a release one too, as most of its bytes. A program built without debug symbols, as
# a release is, is linked with --strip-debug, which drops every .debug section of its core
# module; a debug build, or a release that asks for debug symbols, keeps them. A wasip2 or
# wasip3 program is a component, whose core modules are read too.
for target in (WASIP2, WASIP3):
for request, debug in ((('variant=release',), False), (('variant=debug',), True),
(('variant=release', 'debug-symbols=on'), True)):
shutil.rmtree(root / 'bin', ignore_errors=True)
result = harness.run_b2(root, *target, *request, 'libs/demo/example')
harness.expect(result, True)
assert output_of(root, 'catches.output') == 'caught: boom\n'
program = sorted((root / 'bin').rglob('catches.wasm'))
assert len(program) == 1, program
data = program[0].read_bytes()
assert data[6:8] == b'\x01\x00', (target, request, data[:8])
sections = custom_sections(data)
found = [name for name in sections if name.startswith('.debug')]
assert bool(found) == debug, (target, request, sections)


def test_compile_builds_only_where_declared(root):
# native_only_compiles compiles native_only.cpp, which stops with #error when built for WASI.
# Declared native, it passes natively and is skipped on wasip2.
Expand Down Expand Up @@ -1390,6 +1448,7 @@ def test_the_pair_is_found_by_its_directory_on_every_path_separator(root):
test_link_fail_checks_linking_and_keeps_success_controls,
test_source_only_corpus_is_not_loaded_as_a_build,
test_native_builds_exactly_the_declared_programs,
test_a_wasi_release_program_carries_no_debug_information,
test_wasip2_skips_native_only_and_has_exceptions,
test_wasip3_catches_a_throw,
test_compile_builds_only_where_declared,
Expand Down
Loading