summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-12-28 23:12:30 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-12-31 17:08:29 +0000
commit755540ec8f978c21d3d7a49177da2da861301d74 (patch)
tree0c3af9e15881652ce658c6b8ca97478799662c6a /meta/recipes-devtools
parent96df183b605348e964296fec949d0d8055f1640e (diff)
downloadpoky-755540ec8f978c21d3d7a49177da2da861301d74.tar.gz
rust,libstd-rs: Fix build with latest musl
newer musl do not provide lfs64 functions anymore since off_t is always 64bit on musl using normal functions would suffice (From OE-Core rev: f01b2ab83068e4d7f263c31dca2a3fa9ef77a98e) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/rust/files/0001-Do-not-use-LFS64-on-linux-with-musl.patch168
-rw-r--r--meta/recipes-devtools/rust/rust-source.inc5
2 files changed, 173 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rust/files/0001-Do-not-use-LFS64-on-linux-with-musl.patch b/meta/recipes-devtools/rust/files/0001-Do-not-use-LFS64-on-linux-with-musl.patch
new file mode 100644
index 0000000000..da72665bbd
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/0001-Do-not-use-LFS64-on-linux-with-musl.patch
@@ -0,0 +1,168 @@
1From 3ecce665198e3420d70139d86ed22e74804c9379 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 28 Dec 2022 22:35:55 -0800
4Subject: [PATCH] Do not use LFS64 on linux with musl
5
6glibc is providing open64 and other lfs64 functions but musl aliases
7them to normal equivalents since off_t is always 64-bit on musl,
8therefore check for target env along when target OS is linux before
9using open64, this is more available. Latest Musl has made these
10namespace changes [1]
11
12[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
13
14Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/106246]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 library/std/src/os/linux/fs.rs | 9 ++++++++-
18 library/std/src/sys/unix/fd.rs | 14 ++++++++++----
19 library/std/src/sys/unix/fs.rs | 27 ++++++++++++++++++++-------
20 3 files changed, 38 insertions(+), 12 deletions(-)
21
22diff --git a/library/std/src/os/linux/fs.rs b/library/std/src/os/linux/fs.rs
23index 479bbcc17a8..ab0b2a3eda3 100644
24--- a/library/std/src/os/linux/fs.rs
25+++ b/library/std/src/os/linux/fs.rs
26@@ -329,7 +329,14 @@ pub trait MetadataExt {
27 impl MetadataExt for Metadata {
28 #[allow(deprecated)]
29 fn as_raw_stat(&self) -> &raw::stat {
30- unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) }
31+ #[cfg(target_env = "musl")]
32+ unsafe {
33+ &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
34+ }
35+ #[cfg(not(target_env = "musl"))]
36+ unsafe {
37+ &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
38+ }
39 }
40 fn st_dev(&self) -> u64 {
41 self.as_inner().as_inner().st_dev as u64
42diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs
43index dbaa3c33e2e..5d31557bd11 100644
44--- a/library/std/src/sys/unix/fd.rs
45+++ b/library/std/src/sys/unix/fd.rs
46@@ -115,9 +115,12 @@ pub fn read_to_end(&self, buf: &mut Vec<u8>) -> io::Result<usize> {
47 }
48
49 pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
50- #[cfg(not(any(target_os = "linux", target_os = "android")))]
51+ #[cfg(not(any(
52+ all(target_os = "linux", not(target_env = "musl")),
53+ target_os = "android"
54+ )))]
55 use libc::pread as pread64;
56- #[cfg(any(target_os = "linux", target_os = "android"))]
57+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
58 use libc::pread64;
59
60 unsafe {
61@@ -181,9 +184,12 @@ pub fn is_write_vectored(&self) -> bool {
62 }
63
64 pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
65- #[cfg(not(any(target_os = "linux", target_os = "android")))]
66+ #[cfg(not(any(
67+ all(target_os = "linux", not(target_env = "musl")),
68+ target_os = "android"
69+ )))]
70 use libc::pwrite as pwrite64;
71- #[cfg(any(target_os = "linux", target_os = "android"))]
72+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
73 use libc::pwrite64;
74
75 unsafe {
76diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
77index aea0c26ee8b..e7be4729ca6 100644
78--- a/library/std/src/sys/unix/fs.rs
79+++ b/library/std/src/sys/unix/fs.rs
80@@ -45,19 +45,24 @@
81 all(target_os = "linux", target_env = "gnu")
82 ))]
83 use libc::c_char;
84-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))]
85+#[cfg(any(
86+ all(target_os = "linux", not(target_env = "musl")),
87+ target_os = "emscripten",
88+ target_os = "android"
89+))]
90 use libc::dirfd;
91-#[cfg(any(target_os = "linux", target_os = "emscripten"))]
92+#[cfg(any(not(target_env = "musl"), target_os = "emscripten"))]
93 use libc::fstatat64;
94 #[cfg(any(
95 target_os = "android",
96 target_os = "solaris",
97 target_os = "fuchsia",
98 target_os = "redox",
99- target_os = "illumos"
100+ target_os = "illumos",
101+ target_env = "musl"
102 ))]
103 use libc::readdir as readdir64;
104-#[cfg(target_os = "linux")]
105+#[cfg(all(target_os = "linux", not(target_env = "musl")))]
106 use libc::readdir64;
107 #[cfg(any(target_os = "emscripten", target_os = "l4re"))]
108 use libc::readdir64_r;
109@@ -77,7 +82,13 @@
110 dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
111 lstat as lstat64, off64_t, open as open64, stat as stat64,
112 };
113+#[cfg(target_env = "musl")]
114+use libc::{
115+ dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
116+ lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
117+};
118 #[cfg(not(any(
119+ target_env = "musl",
120 target_os = "linux",
121 target_os = "emscripten",
122 target_os = "l4re",
123@@ -87,7 +98,7 @@
124 dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
125 lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
126 };
127-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))]
128+#[cfg(any(not(target_env = "musl"), target_os = "emscripten", target_os = "l4re"))]
129 use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
130
131 pub use crate::sys_common::fs::try_exists;
132@@ -260,6 +271,7 @@ unsafe impl Sync for Dir {}
133 #[cfg(any(
134 target_os = "android",
135 target_os = "linux",
136+ not(target_env = "musl"),
137 target_os = "solaris",
138 target_os = "illumos",
139 target_os = "fuchsia",
140@@ -292,6 +304,7 @@ struct dirent64_min {
141 }
142
143 #[cfg(not(any(
144+ target_env = "musl",
145 target_os = "android",
146 target_os = "linux",
147 target_os = "solaris",
148@@ -745,7 +758,7 @@ pub fn file_name(&self) -> OsString {
149 }
150
151 #[cfg(all(
152- any(target_os = "linux", target_os = "emscripten", target_os = "android"),
153+ any(not(target_env = "musl"), target_os = "emscripten", target_os = "android"),
154 not(miri)
155 ))]
156 pub fn metadata(&self) -> io::Result<FileAttr> {
157@@ -769,7 +782,7 @@ pub fn metadata(&self) -> io::Result<FileAttr> {
158 }
159
160 #[cfg(any(
161- not(any(target_os = "linux", target_os = "emscripten", target_os = "android")),
162+ not(any(not(target_env = "musl"), target_os = "emscripten", target_os = "android")),
163 miri
164 ))]
165 pub fn metadata(&self) -> io::Result<FileAttr> {
166--
1672.39.0
168
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index f94d616d26..643494b37e 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -2,8 +2,13 @@ RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}"
2SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust" 2SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust"
3SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c" 3SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c"
4 4
5SRC_URI:append:class-target:pn-libstd-rs = "\
6 file://0001-Do-not-use-LFS64-on-linux-with-musl.patch;patchdir=../.. \
7"
8
5SRC_URI:append:class-target:pn-rust = " \ 9SRC_URI:append:class-target:pn-rust = " \
6 file://getrandom-open64.patch \ 10 file://getrandom-open64.patch \
11 file://0001-Do-not-use-LFS64-on-linux-with-musl.patch \
7 file://hardcodepaths.patch \ 12 file://hardcodepaths.patch \
8 file://crossbeam_atomic.patch" 13 file://crossbeam_atomic.patch"
9SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch" 14SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch"