Stream: git-wasmtime

Topic: wasmtime / issue #3731 When i use c++ to link wasmtime li...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 17:42):

vaptu opened issue #3731:

I tried changing the type of build c-api library to make it a static library.

sed -i '14c crate-type=["staticlib"]' crates/c-api/Cargo.toml

(.text+0x3c): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__environ' defined in .bss section in /usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/libc.a(environ.o)

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 17:45):

vaptu edited issue #3731:

I tried changing the type of build c-api library to make it a static library.

sed -i '14c crate-type=["staticlib"]' crates/c-api/Cargo.toml

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc

cargo build --target aarch64-unknown-linux-gnu --release --manifest-path crates/c-api/Cargo.toml

ld

(.text+0x3c): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__environ' defined in .bss section in /usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/libc.a(environ.o)

When I used it, I was prompted for such an error. After my investigation, I found that it was caused by linking the wasmtime library. What is the reason for this and how can I fix it

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 17:47):

vaptu edited issue #3731:

I tried changing the type of build c-api library to make it a static library.

sed -i '14c crate-type=["staticlib"]' crates/c-api/Cargo.toml

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc

cargo build --target aarch64-unknown-linux-gnu --release --manifest-path crates/c-api/Cargo.toml

When I use gcc -static static link all library,ld return the error

(.text+0x3c): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__environ' defined in .bss section in /usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/libc.a(environ.o)

When I used it, I was prompted for such an error. After my investigation, I found that it was caused by linking the wasmtime library. What is the reason for this and how can I fix it

view this post on Zulip Wasmtime GitHub notifications bot (Jan 27 2022 at 18:45):

alexcrichton commented on issue #3731:

This looks like a generic linker error which is related to a platform-specific limitation. This is probably related to your use of -static on the linker command line, and this may go away if such an option is removed. I don't personally have any experience building static glibc-based binaries but it may be the case that wasmtime is blowing some sort of size limit to prevent linking.

Otherwise though this issue generally doesn't look related to Wasmtime itself but rather just trying to link static Rust executables in general with glibc.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 14:53):

vaptu commented on issue #3731:

I see that the c-api in the release version is a dynamic link library. Can you provide a static library for the target platform? Or how to compile a library that can be statically linked. xthanks

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 15:00):

vaptu commented on issue #3731:

This problem does not exist on x86_64 machines

view this post on Zulip Wasmtime GitHub notifications bot (Jan 28 2022 at 19:56):

alexcrichton commented on issue #3731:

My own personal experience of building static binaries with Rust for Linux systems only involves using musl, which is a target that we do not provide precompiled binaries for (and a few things don't work like trap backtraces I think). We do provide libwasmtime.a for the glibc target but I don't know whether it works to build into a static library. My guess would be no but I do not have any experience building static glibc binaries. If you're able to get it working though we could evaluate whether it makes sense to build artifacts for that as well.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 29 2022 at 03:17):

vaptu commented on issue #3731:

Thank you so much

view this post on Zulip Wasmtime GitHub notifications bot (Jan 29 2022 at 03:17):

vaptu closed issue #3731:

I tried changing the type of build c-api library to make it a static library.

sed -i '14c crate-type=["staticlib"]' crates/c-api/Cargo.toml

export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc

cargo build --target aarch64-unknown-linux-gnu --release --manifest-path crates/c-api/Cargo.toml

When I use gcc -static static link all library,ld return the error

(.text+0x3c): relocation truncated to fit: R_AARCH64_LD64_GOTPAGE_LO15 against symbol `__environ' defined in .bss section in /usr/lib/gcc/aarch64-linux-gnu/10/../../../aarch64-linux-gnu/libc.a(environ.o)

When I used it, I was prompted for such an error. After my investigation, I found that it was caused by linking the wasmtime library. What is the reason for this and how can I fix it

view this post on Zulip Wasmtime GitHub notifications bot (Feb 01 2022 at 05:34):

vaptu commented on issue #3731:

I solved this problem by switching from Debian distribution to fedora. Static linking no longer prompts this problem, but I don't know why. I guess it is caused by the fact that Glibc does not use the -mcmodel=large compile option on some distributions


Last updated: Oct 23 2024 at 20:03 UTC