Avoid weak-linking gettid on musl - #160114
Conversation
`current_os_id` uses an extern-weak `gettid` declaration so older glibc can fall back to a raw syscall. Rust-supported musl versions provide `gettid`, so musl does not need this probe. During fat LTO, LLVM can merge the weak declaration with a strong reference from another crate and keep the weak linkage. The static linker then does not extract `gettid.o` from `libc.a`, leaving the strong call without a definition. Call `gettid` directly on musl and add a regression test for the returned thread ID. This removes std's contribution to the collision; the underlying LTO linkage bug remains.
|
|
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
|
@bors try jobs=test-various |
This comment has been minimized.
This comment has been minimized.
Avoid weak-linking `gettid` on musl try-job: test-various
|
💔 Test for a5ba248 failed: CI. Failed job:
|
|
Looks like a download failure, @bors retry |
|
❗ You can only retry pull requests that are approved and have a previously failed auto build. |
|
@bors try jobs=test-various |
This comment has been minimized.
This comment has been minimized.
Avoid weak-linking `gettid` on musl try-job: test-various
|
💔 Test for de974aa failed: CI. Failed job:
|
The regression test also works on glibc. Change its target gate from musl to Linux so both libc environments exercise it. Signed-off-by: windsornguyen <win@dedaluslabs.ai>
Comments outside cfg_select arms describe multiple targets. Move the musl-specific explanation into its arm so it cannot be read as applying to the neighboring Linux/Android path. Signed-off-by: windsornguyen <win@dedaluslabs.ai>
|
If this fails again, will hold off for a while longer @bors try jobs=test-various Please squash as well |
This comment has been minimized.
This comment has been minimized.
Avoid weak-linking `gettid` on musl try-job: test-various
|
💔 Test for 1868143 failed: CI. Failed job:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
|
The job Click to see the possible cause of the failure (guessed by this bot)Important For more information how to resolve CI failures of this job, visit this link. |
|
It looks like the |
|
Huh - I wasn't able to reproduce the failure locally with glibc before. Wonder why it shows up here |
View all comments
Brief
current_os_idweak-linksgettidso older glibc can fall back to a raw syscall.Details
During fat LTO, LLVM can merge the weak declaration with a strong declaration from another crate and keep the weak linkage. A static linker then does not extract
gettid.ofromlibc.a, leaving the strong call without a definition.@bjorn3 traced the underlying compiler problem to fat LTO using LLVM’s legacy
ModuleLinker. Changing that compiler-level behavior is intentionally out of scope here, so that issue should remain open.Note that Rust-supported musl versions provide
gettid, so musl does not need that probe.This PR calls
gettiddirectly on musl. It follows the musl-specific branch suggested by @tgross35 in #154439.r? @tgross35