Skip to content

Commit fc0a2b6

Browse files
committed
dev-lang/rust: fix the build with musl-1.2.4
This fixes the build with musl-1.2.4, for those that are still experiencing issues these steps should resolve them: 1. Downgrade to musl-1.2.3 2. Rebuild dev-lang/rust with these patches 3. Upgrade to musl-1.2.4 again 4. Rebuild rust with USE=system-bootstrap At this point USE=system-boostrap will be required with >= musl-1.2.4 until uptream merges these patches and updates their boostrap. This was tested with musl-1.2.3, musl-1.2.4 and glibc-2.37-r3. Closes: https://bugs.gentoo.org/903607 Upstream-PR: rust-lang/rust#106246 Upstream-Issue: rust-lang/libc#2934 Upstream-PR: rust-lang/libc#2935 Upstream-PR: rust-random/getrandom#326 Upstream-Commit: rust-random/getrandom@7f73e3c Signed-off-by: orbea <orbea@riseup.net>
1 parent 1a60671 commit fc0a2b6

6 files changed

+2939
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
https://bugs.gentoo.org/903607
2+
https://github.com/rust-random/getrandom/pull/326
3+
https://github.com/rust-random/getrandom/commit/7f73e3ccc1f53bfc419e4ddcfd343766aa5837b6
4+
5+
From 7c80ae7cae663e5b85dcd953f3e93b13ed5b1b8e Mon Sep 17 00:00:00 2001
6+
From: Khem Raj <raj.khem@gmail.com>
7+
Date: Wed, 28 Dec 2022 21:44:17 -0800
8+
Subject: [PATCH] Use open instead of open64
9+
10+
glibc is providing open64 and other lfs64 functions but musl aliases
11+
them to normal equivalents since off_t is always 64-bit on musl,
12+
therefore check for target env along when target OS is linux before
13+
using open64, this is more available. Latest Musl has made these
14+
namespace changes [1]
15+
16+
There is no need for using LFS64 open explicitly as we are only using it
17+
for opening device files and not real files
18+
19+
[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
20+
21+
Signed-off-by: Khem Raj <raj.khem@gmail.com>
22+
---
23+
src/util_libc.rs | 10 +---------
24+
1 file changed, 1 insertion(+), 9 deletions(-)
25+
26+
diff --git a/src/util_libc.rs b/src/util_libc.rs
27+
index 63b060e7..bd9c7de1 100644
28+
--- a/src/util_libc.rs
29+
+++ b/src/util_libc.rs
30+
@@ -140,19 +140,11 @@ impl Weak {
31+
}
32+
}
33+
34+
-cfg_if! {
35+
- if #[cfg(any(target_os = "linux", target_os = "emscripten"))] {
36+
- use libc::open64 as open;
37+
- } else {
38+
- use libc::open;
39+
- }
40+
-}
41+
-
42+
// SAFETY: path must be null terminated, FD must be manually closed.
43+
pub unsafe fn open_readonly(path: &str) -> Result<libc::c_int, Error> {
44+
debug_assert_eq!(path.as_bytes().last(), Some(&0));
45+
loop {
46+
- let fd = open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC);
47+
+ let fd = libc::open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC);
48+
if fd >= 0 {
49+
return Ok(fd);
50+
}

0 commit comments

Comments
 (0)