Skip to content

port(wasm): Error on undefined strong symbols by default and add --allow-undefined - #2345

Open
lapla-cogito wants to merge 3 commits into
wild-linker:mainfrom
lapla-cogito:wasm_undef
Open

port(wasm): Error on undefined strong symbols by default and add --allow-undefined#2345
lapla-cogito wants to merge 3 commits into
wild-linker:mainfrom
lapla-cogito:wasm_undef

Conversation

@lapla-cogito

@lapla-cogito lapla-cogito commented Aug 5, 2026

Copy link
Copy Markdown
Member

commits:

  1. Define the linker-defined __global_base at the start of static data (after the stack when --stack-first), as expected by wasi-libc and similar inputs once undefined symbols are enforced.

  2. Non-weak undefined functions/globals without EXPLICIT_NAME, and unresolved data symbols, are link errors by default.

  3. Support --allow-undefined which leave unresolved strong functions (as host imports) / undefined data.

Part of #1431


//#Config:data
//#CompArgs: -DTEST_DATA
//#LinkArgs: --allow-undefined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I add -fPIC to the flags, this test fails. Same for the data test in undefined-strong.c.

Comment thread libwild/src/wasm.rs
// Data
#[strum(serialize = "__data_end")]
DataEnd,
#[strum(serialize = "__global_base")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be somewhat tempted to have at least the "__global_base" commit as a separate PR, unless there's some reason why it needs to be together with the other changes? But I don't feel strongly, so if you want to keep all three commits together in a single PR, that's also fine.

Comment thread libwild/src/wasm.rs
// Data
#[strum(serialize = "__data_end")]
DataEnd,
#[strum(serialize = "__global_base")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good if we had integration tests for things like __global_base for the usual reasons - mostly it let's us verify against wasm-ld. But if it's not practical for some reason, then the unit tests will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants