Fix path reolution in sandboxed build environments - #5338
Open
ephemeralriggs wants to merge 1 commit into
Open
Conversation
This fixes an invalid relative module path resolution in src/new/glibc/sysdeps/nptl/mod.rs that causes build failures in sandboxed/hermetic build environments (e.g. Bazel, Nix, and isolated containers). When rustc runs inside these sandboxes, calling open() on sysdeps/nptl/bits/../../x86/nptl/bits/struct_mutex.rs may fail with ENOENT because the bits directory may not exist. Signed-off-by: Thomas Zander <thomasalpinus@google.com>
ephemeralriggs
force-pushed
the
pathresolution
branch
from
July 29, 2026 11:08
7eafe39 to
51df56b
Compare
tgross35
reviewed
Jul 29, 2026
Comment on lines
9
to
34
| #[cfg_attr( | ||
| any( | ||
| target_arch = "mips", | ||
| target_arch = "mips32r6", | ||
| target_arch = "mips", | ||
| target_arch = "mips32r6", | ||
| ), | ||
| path = "../../mips/nptl/bits/struct_mutex.rs" | ||
| any(target_arch = "mips", target_arch = "mips32r6",), | ||
| path = "../mips/nptl/bits/struct_mutex.rs" | ||
| )] | ||
| #[cfg_attr( | ||
| any(target_arch = "powerpc", target_arch = "powerpc64"), | ||
| path = "../../powerpc/nptl/bits/struct_mutex.rs" | ||
| path = "../powerpc/nptl/bits/struct_mutex.rs" | ||
| )] | ||
| #[cfg_attr(target_arch = "s390x", path = "../../s390/nptl/bits/struct_mutex.rs")] | ||
| #[cfg_attr(target_arch = "s390x", path = "../s390/nptl/bits/struct_mutex.rs")] | ||
| #[cfg_attr( | ||
| any(target_arch = "x86", target_arch = "x86_64"), | ||
| path = "../../x86/nptl/bits/struct_mutex.rs" | ||
| path = "../x86/nptl/bits/struct_mutex.rs" | ||
| )] | ||
| #[cfg_attr( | ||
| not(any( | ||
| target_arch = "mips", | ||
| target_arch = "mips32r6", | ||
| target_arch = "powerpc", | ||
| target_arch = "powerpc64", | ||
| target_arch = "s390x", | ||
| target_arch = "x86", | ||
| target_arch = "x86_64", | ||
| )), | ||
| path = "bits/struct_mutex.rs" | ||
| )] | ||
| pub(crate) mod struct_mutex; |
Contributor
There was a problem hiding this comment.
Could this use cfg_if (repeating mod struct_mutex in each) so we get the fallback without needing to duplicate the arch list?
Contributor
|
Actually, is the issue that the Separately I wonder if |
Contributor
|
@rustbot author, awaiting feedback |
Collaborator
|
Reminder, once the PR becomes ready for a review, use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This fixes an invalid relative module path resolution in src/new/glibc/sysdeps/nptl/mod.rs that causes build failures in sandboxed/hermetic build environments (e.g. Bazel, Nix, and isolated containers).
When rustc runs inside these sandboxes, calling
open()onsysdeps/nptl/bits/../../x86/nptl/bits/struct_mutex.rsmay fail withENOENTbecause the bits directory may not exist.Checklist
libc-test/semverhave been updated*LASTor*MAXhave the standarddoc comment
cargo test -p libc-test --target mytarget); also tested on Fuchsia CI builders@rustbot label +stable-nominated