Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix shared library build with llvm-19 #526

Merged
merged 7 commits into from
Aug 28, 2024
Merged

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Aug 13, 2024

No description provided.

* for non libc.so libraries, don't forget to link libc.so

* avoid link errors on linker-provided symbols.
  i feel this is a workaround for a wasm-ld bug.
@TerrorJack
Copy link
Contributor

TerrorJack commented Aug 13, 2024

I'm seeing the following error when integrating it into a wasi-sdk build:

 "/workspace/wasi-sdk/build/install/bin/wasm-ld" -m wasm32 -L/workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi /workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/crt1-reactor.o --entry _initialize -shared --whole-archive build/wasm32-wasi/libdl.so.a --no-whole-archive --allow-undefined-file=linker-provided-symbols.txt -lc /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a -o /workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libdl.so
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory

In the build directory, compiler-rt seems to be present in the following paths:

/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasi/libclang_rt.builtins-wasm32.a
/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasip1/libclang_rt.builtins-wasm32.a
/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasip2/libclang_rt.builtins-wasm32.a

I wonder why the path mismatch didn't happen before this patch though..

when building a shared library, specify all CFLAGS because
it can contain options like -resource-dir.
@yamt
Copy link
Contributor Author

yamt commented Aug 13, 2024

I'm seeing the following error when integrating it into a wasi-sdk build:

 "/workspace/wasi-sdk/build/install/bin/wasm-ld" -m wasm32 -L/workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi /workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/crt1-reactor.o --entry _initialize -shared --whole-archive build/wasm32-wasi/libdl.so.a --no-whole-archive --allow-undefined-file=linker-provided-symbols.txt -lc /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a -o /workspace/wasi-sdk/build/sysroot/install/share/wasi-sysroot/lib/wasm32-wasi/libdl.so
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory
wasm-ld: error: cannot open /workspace/wasi-sdk/build/install/lib/clang/19/lib/wasm32-unknown-wasi/libclang_rt.builtins.a: No such file or directory

In the build directory, compiler-rt seems to be present in the following paths:

/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasi/libclang_rt.builtins-wasm32.a
/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasip1/libclang_rt.builtins-wasm32.a
/workspace/wasi-sdk/build/sysroot/install/wasi-resource-dir/lib/wasip2/libclang_rt.builtins-wasm32.a

I wonder why the path mismatch didn't happen before this patch though..

i pushed a commit which might fix it.

@TerrorJack
Copy link
Contributor

Thanks, I've verified it fixes wasi-sdk build.

@@ -0,0 +1,3 @@
__heap_base
__heap_end
__c_longjmp
Copy link
Member

Choose a reason for hiding this comment

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

Can you open a wasm-ld bug regarding this? I think these should not be necessary.

Also, perhaps add a comment here (or in the Makefile) with a link the bug so we know its temporary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yamt added a commit to yamt/wasi-libmalloc that referenced this pull request Aug 16, 2024
230d4be6c54bec93181050f9e25c87150506bdd0
plus WebAssembly/wasi-libc#526
yamt added a commit to yamt/wasi-sdk that referenced this pull request Aug 23, 2024
yamt added a commit to yamt/wasi-sdk that referenced this pull request Aug 23, 2024
In the wasi-sdk windows job, when building libc.so, for some reasons,
the -isystem option in CFLAGS here seems to prevent the linker from
finding compiler-rt.

I don't understand how it happens because:

* Afaik, -isystem should not affect how the linker search objects

* The compiler-rt path is explicitly given as BUILTINS_LIB

Anyway, this commit tries to work it around by passing only a subset
of the options.
@abrown abrown merged commit 3f812ab into WebAssembly:main Aug 28, 2024
8 checks passed
yamt added a commit to yamt/wasi-sdk that referenced this pull request Aug 28, 2024
yamt added a commit to yamt/wasi-sdk that referenced this pull request Sep 18, 2024
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.

4 participants