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

integration-test: rust-lld invoked by cargo xtask integration-test vm fails to find libraries #907

Open
vadorovsky opened this issue Mar 13, 2024 · 0 comments · May be fixed by #908
Open

Comments

@vadorovsky
Copy link
Member

vadorovsky commented Mar 13, 2024

Happens every time on Gentoo with musl-llvm profile, but it's likely to happen on non-GNU userlands in general:

cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error

Specifying -L /lib -L /usr/lib doesn't help, even though I have llvm-libgcc and musl in these directories (both shared and static).

It originally happened in CI in my cross build / binstall attempts here: https://github.com/aya-rs/bpf-linker/actions/runs/8267383737/job/22617773928?pr=129

Using system-wide LLD makes the issue disappear.

vadorovsky added a commit to vadorovsky/aya that referenced this issue Mar 13, 2024
rust-lld is unaware of system libraries and seems like there is no way
to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

Using system-wide LLD makes the issue disappear.

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Sep 7, 2024
rust-lld is unaware of system libraries and seems like there is no way
to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

Using system-wide LLD makes the issue disappear.

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Sep 7, 2024
rust-lld on Linux  is unaware of system libraries and seems like there is
no way to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

More explanation:

https://users.rust-lang.org/t/enabling-rust-lld-for-aarch64-unknown-linux-gnu/113243/2
rust-lang/rust#130062 (comment)

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Sep 7, 2024
rust-lld on Linux  is unaware of system libraries and seems like there is
no way to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

More explanation:

https://users.rust-lang.org/t/enabling-rust-lld-for-aarch64-unknown-linux-gnu/113243/2
rust-lang/rust#130062 (comment)

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Sep 7, 2024
rust-lld on Linux  is unaware of system libraries and seems like there is
no way to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

More explanation:

https://users.rust-lang.org/t/enabling-rust-lld-for-aarch64-unknown-linux-gnu/113243/2
rust-lang/rust#130062 (comment)

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Oct 8, 2024
rust-lld on Linux  is unaware of system libraries and seems like there is
no way to point it to them. That often triggers issues like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

More explanation:

https://users.rust-lang.org/t/enabling-rust-lld-for-aarch64-unknown-linux-gnu/113243/2
rust-lang/rust#130062 (comment)

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Oct 9, 2024
The recommendation (coming from rust-lang/rust#130062) is using C
compiler driver as a linker, which is able to find system-wide
libraries. Using linker binaries directly in `-C linker` (e.g.
`-C linker=rust-lld`) often results in errors like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Oct 9, 2024
The recommendation (coming from rust-lang/rust#130062) for Linux hosts
is using C compiler driver as a linker, which is able to find
system-wide libraries. Using linker binaries directly in `-C linker`
(e.g. `-C linker=rust-lld`) often results in errors like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

However, `-C linker=rust-lld` still works the best on macOS, where
Rust toolchains come with unwinder and runtime and there is usually no
need to link system libraries. Keep setting it only for macOS.

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Oct 9, 2024
The recommendation (coming from rust-lang/rust#130062) for Linux hosts
is using C compiler driver as a linker, which is able to find
system-wide libraries. Using linker binaries directly in `-C linker`
(e.g. `-C linker=rust-lld`) often results in errors like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

Not touching the linker settings is usually the best approach for Linux
systems. Native builds pick up the default C toolchain. Cross builds
default to GCC cross wrapper, but that's easy to supress with clang
and lld using RUSTFLAGS.

However, `-C linker=rust-lld` still works the best on macOS, where
Rust toolchains come with unwinder and runtime and there is usually no
need to link system libraries. Keep setting it only for macOS.

Fixes aya-rs#907
vadorovsky added a commit to vadorovsky/aya that referenced this issue Oct 9, 2024
The recommendation (coming from rust-lang/rust#130062) for Linux hosts
is using C compiler driver as a linker, which is able to find
system-wide libraries. Using linker binaries directly in `-C linker`
(e.g. `-C linker=rust-lld`) often results in errors like:

```
cargo:warning=error: linking with `rust-lld` failed: exit status: 1ger, ppv-lite86, libc...
cargo:warning=  |
cargo:warning=  = note: LC_ALL="C" PATH="/home/vadorovsky/.rustup/toolchains/stable-x86_64-un
cargo:warning=  = note: rust-lld: error: unable to find library -lgcc_s
cargo:warning=          rust-lld: error: unable to find library -lc
cargo:warning=
cargo:warning=
cargo:warning=
cargo:warning=error: aborting due to 1 previous error
```

Not touching the linker settings is usually the best approach for Linux
systems. Native builds pick up the default C toolchain. Cross builds
default to GCC cross wrapper, but that's easy to supress with clang
and lld using RUSTFLAGS.

However, `-C linker=rust-lld` still works the best on macOS, where
Rust toolchains come with unwinder and runtime and there is usually no
need to link system libraries. Keep setting it only for macOS.

Fixes aya-rs#907
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 a pull request may close this issue.

1 participant