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

Add musl's lib folder to library search path #2893

Merged
merged 1 commit into from Aug 31, 2022

Conversation

wesleywiser
Copy link
Member

Prior to this change, libc.a was being found in rustc's self-contained
musl target folder instead of the libc.a that we've built or
downloaded. This doesn't seem to have caused any noticeable issues as the
versions of musl we built/installed and the version shipped in rustc's
target matched exactly.

To resolve this, we pass the path to our version of musl's lib folder
directly as a RUSTFLAG which causes it to be found first.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@wesleywiser
Copy link
Member Author

I found this while working on #2088 as libc-test was failing in bors with errors like

error: linking with `musl-gcc` failed: exit status: 1
...
  = note: /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /checkout/target/arm-unknown-linux-musleabihf/debug/deps/main-c15914ff48b4bfd8.3ktu7j0zei2358zy.rcgu.o: in function `main::fn_fstat':
          /checkout/target/arm-unknown-linux-musleabihf/debug/build/libc-test-db8b07dfa915a081/out/main.rs:(.text._ZN4main8fn_fstat17hd33ed8048ecb6f41E+0x38): undefined reference to `__fstat_time64'
          /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: /checkout/target/arm-unknown-linux-musleabihf/debug/deps/main-c15914ff48b4bfd8.3ktu7j0zei2358zy.rcgu.o: in function `main::fn_stat':
          /checkout/target/arm-unknown-linux-musleabihf/debug/build/libc-test-db8b07dfa915a081/out/main.rs:(.text._ZN4main7fn_stat17h0ceed805fc807102E+0x38): undefined reference to `__stat_time64'
...

because it was trying to link musl 1.1 from the rustc target instead of musl 1.2.3 which we were compiling.

Prior to this change, `libc.a` was being found in rustc's self-contained
musl target folder instead of the `libc.a` that we've built or
downloaded. This doesn't seem to have caused any noticeable issues as the
versions of musl we built/installed and the version shipped in rustc's
target matched exactly.

To resolve this, we pass the path to our version of musl's lib folder
directly as a `RUSTFLAG` which causes it to be found first.
@12101111
Copy link
Contributor

You can use RUSTFLAGS=-Clink-self-contained=off -L/path/to/musl/lib

https://doc.rust-lang.org/rustc/codegen-options/index.html#link-self-contained

@wesleywiser
Copy link
Member Author

I gave that a try but it results in linker errors trying to resolve libunwind on i686/x86_64:

error: could not compile `libc-test` due to previous error
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit status: 1
...
  = note: /usr/bin/ld: cannot find -lunwind
          collect2: error: ld returned 1 exit status

Which it's currently getting from the self-contained location.

Copy link
Member

@JohnTitor JohnTitor left a comment

Choose a reason for hiding this comment

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

Sounds sensible to me!

@JohnTitor
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 31, 2022

📌 Commit ea73035 has been approved by JohnTitor

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 31, 2022

⌛ Testing commit ea73035 with merge f1c3cfe...

@bors
Copy link
Contributor

bors commented Aug 31, 2022

☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14
Approved by: JohnTitor
Pushing f1c3cfe to master...

@bors bors merged commit f1c3cfe into rust-lang:master Aug 31, 2022
@wesleywiser wesleywiser deleted the fix_ci_testing branch August 31, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants