Initial commit
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
From 3ecce665198e3420d70139d86ed22e74804c9379 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Wed, 28 Dec 2022 22:35:55 -0800
|
||||
Subject: [PATCH] Do not use LFS64 on linux with musl
|
||||
|
||||
glibc is providing open64 and other lfs64 functions but musl aliases
|
||||
them to normal equivalents since off_t is always 64-bit on musl,
|
||||
therefore check for target env along when target OS is linux before
|
||||
using open64, this is more available. Latest Musl has made these
|
||||
namespace changes [1]
|
||||
|
||||
[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
|
||||
|
||||
Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/106246]
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
library/std/src/os/linux/fs.rs | 9 ++++++++-
|
||||
library/std/src/sys/unix/fd.rs | 14 ++++++++++----
|
||||
library/std/src/sys/unix/fs.rs | 27 ++++++++++++++++++++-------
|
||||
3 files changed, 38 insertions(+), 12 deletions(-)
|
||||
|
||||
Index: rustc-1.70.0-src/library/std/src/os/linux/fs.rs
|
||||
===================================================================
|
||||
--- rustc-1.70.0-src.orig/library/std/src/os/linux/fs.rs
|
||||
+++ rustc-1.70.0-src/library/std/src/os/linux/fs.rs
|
||||
@@ -329,7 +329,14 @@ pub trait MetadataExt {
|
||||
impl MetadataExt for Metadata {
|
||||
#[allow(deprecated)]
|
||||
fn as_raw_stat(&self) -> &raw::stat {
|
||||
- unsafe { &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat) }
|
||||
+ #[cfg(target_env = "musl")]
|
||||
+ unsafe {
|
||||
+ &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat)
|
||||
+ }
|
||||
+ #[cfg(not(target_env = "musl"))]
|
||||
+ unsafe {
|
||||
+ &*(self.as_inner().as_inner() as *const libc::stat64 as *const raw::stat)
|
||||
+ }
|
||||
}
|
||||
fn st_dev(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_dev as u64
|
||||
Index: rustc-1.70.0-src/library/std/src/sys/unix/fd.rs
|
||||
===================================================================
|
||||
--- rustc-1.70.0-src.orig/library/std/src/sys/unix/fd.rs
|
||||
+++ rustc-1.70.0-src/library/std/src/sys/unix/fd.rs
|
||||
@@ -121,9 +121,12 @@ impl FileDesc {
|
||||
}
|
||||
|
||||
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
|
||||
- #[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
+ #[cfg(not(any(
|
||||
+ all(target_os = "linux", not(target_env = "musl")),
|
||||
+ target_os = "android"
|
||||
+ )))]
|
||||
use libc::pread as pread64;
|
||||
- #[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
|
||||
use libc::pread64;
|
||||
|
||||
unsafe {
|
||||
@@ -276,9 +279,12 @@ impl FileDesc {
|
||||
}
|
||||
|
||||
pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
|
||||
- #[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
+ #[cfg(not(any(
|
||||
+ all(target_os = "linux", not(target_env = "musl")),
|
||||
+ target_os = "android"
|
||||
+ )))]
|
||||
use libc::pwrite as pwrite64;
|
||||
- #[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
+ #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
|
||||
use libc::pwrite64;
|
||||
|
||||
unsafe {
|
||||
Index: rustc-1.70.0-src/library/std/src/sys/unix/fs.rs
|
||||
===================================================================
|
||||
--- rustc-1.70.0-src.orig/library/std/src/sys/unix/fs.rs
|
||||
+++ rustc-1.70.0-src/library/std/src/sys/unix/fs.rs
|
||||
@@ -47,9 +47,13 @@ use libc::{c_int, mode_t};
|
||||
all(target_os = "linux", target_env = "gnu")
|
||||
))]
|
||||
use libc::c_char;
|
||||
-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "android"))]
|
||||
+#[cfg(any(
|
||||
+ all(target_os = "linux", not(target_env = "musl")),
|
||||
+ target_os = "emscripten",
|
||||
+ target_os = "android"
|
||||
+))]
|
||||
use libc::dirfd;
|
||||
-#[cfg(any(target_os = "linux", target_os = "emscripten"))]
|
||||
+#[cfg(any(not(target_env = "musl"), target_os = "emscripten"))]
|
||||
use libc::fstatat64;
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
@@ -58,9 +62,10 @@ use libc::fstatat64;
|
||||
target_os = "redox",
|
||||
target_os = "illumos",
|
||||
target_os = "nto",
|
||||
+ target_env = "musl",
|
||||
))]
|
||||
use libc::readdir as readdir64;
|
||||
-#[cfg(target_os = "linux")]
|
||||
+#[cfg(all(target_os = "linux", not(target_env = "musl")))]
|
||||
use libc::readdir64;
|
||||
#[cfg(any(target_os = "emscripten", target_os = "l4re"))]
|
||||
use libc::readdir64_r;
|
||||
@@ -81,7 +86,13 @@ use libc::{
|
||||
dirent as dirent64, fstat as fstat64, fstatat as fstatat64, ftruncate64, lseek64,
|
||||
lstat as lstat64, off64_t, open as open64, stat as stat64,
|
||||
};
|
||||
+#[cfg(target_env = "musl")]
|
||||
+use libc::{
|
||||
+ dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
|
||||
+ lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
|
||||
+};
|
||||
#[cfg(not(any(
|
||||
+ target_env = "musl",
|
||||
target_os = "linux",
|
||||
target_os = "emscripten",
|
||||
target_os = "l4re",
|
||||
@@ -91,7 +102,7 @@ use libc::{
|
||||
dirent as dirent64, fstat as fstat64, ftruncate as ftruncate64, lseek as lseek64,
|
||||
lstat as lstat64, off_t as off64_t, open as open64, stat as stat64,
|
||||
};
|
||||
-#[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))]
|
||||
+#[cfg(any(not(target_env = "musl"), target_os = "emscripten", target_os = "l4re"))]
|
||||
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
|
||||
|
||||
pub use crate::sys_common::fs::try_exists;
|
||||
@@ -278,6 +289,7 @@ unsafe impl Sync for Dir {}
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
+ not(target_env = "musl"),
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
target_os = "fuchsia",
|
||||
@@ -312,6 +324,7 @@ struct dirent64_min {
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
+ target_env = "musl",
|
||||
target_os = "android",
|
||||
target_os = "linux",
|
||||
target_os = "solaris",
|
||||
@@ -787,7 +800,7 @@ impl DirEntry {
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
- any(target_os = "linux", target_os = "emscripten", target_os = "android"),
|
||||
+ any(not(target_env = "musl"), target_os = "emscripten", target_os = "android"),
|
||||
not(miri)
|
||||
))]
|
||||
pub fn metadata(&self) -> io::Result<FileAttr> {
|
||||
@@ -811,7 +824,7 @@ impl DirEntry {
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
- not(any(target_os = "linux", target_os = "emscripten", target_os = "android")),
|
||||
+ not(any(not(target_env = "musl"), target_os = "emscripten", target_os = "android")),
|
||||
miri
|
||||
))]
|
||||
pub fn metadata(&self) -> io::Result<FileAttr> {
|
||||
+114
File diff suppressed because one or more lines are too long
@@ -0,0 +1,46 @@
|
||||
Do not use open64 on linux with musl
|
||||
|
||||
glibc is providing open64 and other lfs64 functions but musl aliases
|
||||
them to normal equivalents since off_t is always 64-bit on musl,
|
||||
therefore check for target env along when target OS is linux before
|
||||
using open64, this is more available. Latest Musl has made these
|
||||
namespace changes [1]
|
||||
|
||||
There is no need for using LFS64 open explicitly as we are only using it
|
||||
for opening device files and not real files
|
||||
|
||||
[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
|
||||
|
||||
Upstream-Status: Backport [https://github.com/rust-random/getrandom/commit/7f73e3ccc1f53bfc419e4ddcfd343766aa5837b6]
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
|
||||
--- a/vendor/getrandom/.cargo-checksum.json
|
||||
+++ b/vendor/getrandom/.cargo-checksum.json
|
||||
@@ -1 +1 @@
|
||||
-{"files":{"CHANGELOG.md":"cb054908f44d0e7f229dcc4580bcc4f2c3e2da198c84292710f730b33cc3d5f6","Cargo.toml":"708a5d9c89443b937aa50260e26a01f9ebfdd50a7ae312956795834e3187baf3","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"7ae74633326a22fd6298d7f209fb14884277bd98049795f444945acbb2b0dfbd","benches/mod.rs":"c01b05c6d690a4b8937d25252f1385a6bff378517318ce832ea520036aabd571","src/3ds.rs":"0f48fc15f89b518fb92e06aaa4838b62dc073598e8f288df56ad1e5a9251af1e","src/bsd_arandom.rs":"d90c419d4def20f83e7535cd3f5ec07035045011a50c3652951d196a120c5d3e","src/custom.rs":"ce4640776d36872dbbd5e194bf29f6bcda3ef4549ca04fe59f5aeab1dea1d821","src/dragonfly.rs":"47f933eac189f6ea48ecf021efd0747ebce1b43d1bece6bbf72a951bab705987","src/error.rs":"ff09a7e02d7aff3e45eca6bbef6c686cc46f3c2371a0897a856e4dec4b942e46","src/error_impls.rs":"9c34832ebb99cd5e31bc5c8ffc5beb5b3fa6f7ff0226aaa1cdf8e10e6d64b324","src/espidf.rs":"19f101486584fde6dad962f4d9792de168658047312106641a5caf6866a5bbcf","src/fuchsia.rs":"470d8509deb5b06fa6417f294c0a49e0e35a580249a5d8944c3be5aa746f64ea","src/ios.rs":"4bad4f5c096a50338b86aeac91a937c18bc55b9555e6f34806ad13732e64523d","src/js.rs":"370610a19045012c87c986279aad6b150cd728a44015dcc5779256e4a2e6629b","src/lib.rs":"8e5c2c8edcbdbf2cee46b86d96d951cc6d5c00f7c11cfc9c27de27e756b5c4cc","src/linux_android.rs":"ec24575aa4ae71b6991290dadfdea931b05397c3faababf24bd794f1a9624835","src/macos.rs":"6c09827ad5292cd022e063efa79523bfdb50ed08b9867ebaa007cd321b8d218e","src/openbsd.rs":"450a23ead462d4a840fee4aa0bfdab1e3d88c8f48e4bb608d457429ddeca69c0","src/rdrand.rs":"79d23183b1905d61bd9df9729dc798505a2ed750d3339e342ab144e1709827e4","src/solaris_illumos.rs":"d52fee9dd7d661f960c01894edd563c1ff8a512c111f7803092d9aa2ff98718e","src/solid.rs":"997035d54c9762d22a5a14f54e7fbed4dd266cdeacbdf6aab7d8aee05537e8ba","src/use_file.rs":"16e42eb0a56e375c330c1ca8eb58c444e82ef3ad35230b961fdba96a02a68804","src/util.rs":"da6964dc1523f1cb8d26365fa6a8ece46360587e6974931624b271f0c72cda8b","src/util_libc.rs":"2a63ac0e6dab16b85c4728b79a16e0640301e8b876f151b0a1db0b4394fa219f","src/vxworks.rs":"a5aa0e40f890e0f35626458bb656a3340b8af3111e4bacd2e12505a8d50a3505","src/wasi.rs":"dfdd0a870581948bd03abe64d49ca4295d9cfa26e09b97a526fd5e17148ad9ca","src/windows.rs":"d0b4f2afd1959660aa9abcd9477764bd7dc0b7d7048aee748804b37963c77c6f","tests/common/mod.rs":"b6beee8f535d2d094a65711fe0af91a6fc220aa09729ed7269fe33cafdc9177f","tests/custom.rs":"9f2c0193193f6bcf641116ca0b3653b33d2015e0e98ce107ee1d1f60c5eeae3a","tests/normal.rs":"9e1c4b1e468a09ed0225370dfb6608f8b8135e0fabb09bbc1a718105164aade6","tests/rdrand.rs":"4474ccebf9d33c89288862a7e367018405968dddc55c7c6f97e21b5fe2264601"},"package":"c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"}
|
||||
\ No newline at end of file
|
||||
+{"files":{"CHANGELOG.md":"cb054908f44d0e7f229dcc4580bcc4f2c3e2da198c84292710f730b33cc3d5f6","Cargo.toml":"708a5d9c89443b937aa50260e26a01f9ebfdd50a7ae312956795834e3187baf3","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"209fbbe0ad52d9235e37badf9cadfe4dbdc87203179c0899e738b39ade42177b","README.md":"7ae74633326a22fd6298d7f209fb14884277bd98049795f444945acbb2b0dfbd","benches/mod.rs":"c01b05c6d690a4b8937d25252f1385a6bff378517318ce832ea520036aabd571","src/3ds.rs":"0f48fc15f89b518fb92e06aaa4838b62dc073598e8f288df56ad1e5a9251af1e","src/bsd_arandom.rs":"d90c419d4def20f83e7535cd3f5ec07035045011a50c3652951d196a120c5d3e","src/custom.rs":"ce4640776d36872dbbd5e194bf29f6bcda3ef4549ca04fe59f5aeab1dea1d821","src/dragonfly.rs":"47f933eac189f6ea48ecf021efd0747ebce1b43d1bece6bbf72a951bab705987","src/error.rs":"ff09a7e02d7aff3e45eca6bbef6c686cc46f3c2371a0897a856e4dec4b942e46","src/error_impls.rs":"9c34832ebb99cd5e31bc5c8ffc5beb5b3fa6f7ff0226aaa1cdf8e10e6d64b324","src/espidf.rs":"19f101486584fde6dad962f4d9792de168658047312106641a5caf6866a5bbcf","src/fuchsia.rs":"470d8509deb5b06fa6417f294c0a49e0e35a580249a5d8944c3be5aa746f64ea","src/ios.rs":"4bad4f5c096a50338b86aeac91a937c18bc55b9555e6f34806ad13732e64523d","src/js.rs":"370610a19045012c87c986279aad6b150cd728a44015dcc5779256e4a2e6629b","src/lib.rs":"8e5c2c8edcbdbf2cee46b86d96d951cc6d5c00f7c11cfc9c27de27e756b5c4cc","src/linux_android.rs":"ec24575aa4ae71b6991290dadfdea931b05397c3faababf24bd794f1a9624835","src/macos.rs":"6c09827ad5292cd022e063efa79523bfdb50ed08b9867ebaa007cd321b8d218e","src/openbsd.rs":"450a23ead462d4a840fee4aa0bfdab1e3d88c8f48e4bb608d457429ddeca69c0","src/rdrand.rs":"79d23183b1905d61bd9df9729dc798505a2ed750d3339e342ab144e1709827e4","src/solaris_illumos.rs":"d52fee9dd7d661f960c01894edd563c1ff8a512c111f7803092d9aa2ff98718e","src/solid.rs":"997035d54c9762d22a5a14f54e7fbed4dd266cdeacbdf6aab7d8aee05537e8ba","src/use_file.rs":"16e42eb0a56e375c330c1ca8eb58c444e82ef3ad35230b961fdba96a02a68804","src/util.rs":"da6964dc1523f1cb8d26365fa6a8ece46360587e6974931624b271f0c72cda8b","src/util_libc.rs":"a47b20e73637fed248405650f56358f3339e511b217b7ba80e32011d8ee2ca22","src/vxworks.rs":"a5aa0e40f890e0f35626458bb656a3340b8af3111e4bacd2e12505a8d50a3505","src/wasi.rs":"dfdd0a870581948bd03abe64d49ca4295d9cfa26e09b97a526fd5e17148ad9ca","src/windows.rs":"d0b4f2afd1959660aa9abcd9477764bd7dc0b7d7048aee748804b37963c77c6f","tests/common/mod.rs":"b6beee8f535d2d094a65711fe0af91a6fc220aa09729ed7269fe33cafdc9177f","tests/custom.rs":"9f2c0193193f6bcf641116ca0b3653b33d2015e0e98ce107ee1d1f60c5eeae3a","tests/normal.rs":"9e1c4b1e468a09ed0225370dfb6608f8b8135e0fabb09bbc1a718105164aade6","tests/rdrand.rs":"4474ccebf9d33c89288862a7e367018405968dddc55c7c6f97e21b5fe2264601"},"package":"c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"}
|
||||
\ No newline at end of file
|
||||
--- a/vendor/getrandom/src/util_libc.rs
|
||||
+++ b/vendor/getrandom/src/util_libc.rs
|
||||
@@ -135,19 +135,11 @@ impl Weak {
|
||||
}
|
||||
}
|
||||
|
||||
-cfg_if! {
|
||||
- if #[cfg(any(target_os = "linux", target_os = "emscripten"))] {
|
||||
- use libc::open64 as open;
|
||||
- } else {
|
||||
- use libc::open;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
// SAFETY: path must be null terminated, FD must be manually closed.
|
||||
pub unsafe fn open_readonly(path: &str) -> Result<libc::c_int, Error> {
|
||||
debug_assert_eq!(path.as_bytes().last(), Some(&0));
|
||||
loop {
|
||||
- let fd = open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC);
|
||||
+ let fd = libc::open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC);
|
||||
if fd >= 0 {
|
||||
return Ok(fd);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
When building for the target, some build paths end up embedded in the binaries.
|
||||
These changes remove that. Further investigation is needed to work out the way
|
||||
to resolve these issues properly upstream.
|
||||
|
||||
Upstream-Status: Inappropriate [patches need rework]
|
||||
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
|
||||
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
|
||||
|
||||
--- rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/context.rs.orig 2023-04-21 08:38:23.092458478 +0100
|
||||
+++ rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/context.rs 2023-04-21 08:39:00.266819755 +0100
|
||||
@@ -156,46 +156,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- // Ensure the data-layout values hardcoded remain the defaults.
|
||||
- if sess.target.is_builtin {
|
||||
- let tm = crate::back::write::create_informational_target_machine(tcx.sess);
|
||||
- llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm);
|
||||
- llvm::LLVMRustDisposeTargetMachine(tm);
|
||||
-
|
||||
- let llvm_data_layout = llvm::LLVMGetDataLayoutStr(llmod);
|
||||
- let llvm_data_layout = str::from_utf8(CStr::from_ptr(llvm_data_layout).to_bytes())
|
||||
- .expect("got a non-UTF8 data-layout from LLVM");
|
||||
-
|
||||
- // Unfortunately LLVM target specs change over time, and right now we
|
||||
- // don't have proper support to work with any more than one
|
||||
- // `data_layout` than the one that is in the rust-lang/rust repo. If
|
||||
- // this compiler is configured against a custom LLVM, we may have a
|
||||
- // differing data layout, even though we should update our own to use
|
||||
- // that one.
|
||||
- //
|
||||
- // As an interim hack, if CFG_LLVM_ROOT is not an empty string then we
|
||||
- // disable this check entirely as we may be configured with something
|
||||
- // that has a different target layout.
|
||||
- //
|
||||
- // Unsure if this will actually cause breakage when rustc is configured
|
||||
- // as such.
|
||||
- //
|
||||
- // FIXME(#34960)
|
||||
- let cfg_llvm_root = option_env!("CFG_LLVM_ROOT").unwrap_or("");
|
||||
- let custom_llvm_used = !cfg_llvm_root.trim().is_empty();
|
||||
-
|
||||
- if !custom_llvm_used && target_data_layout != llvm_data_layout {
|
||||
- bug!(
|
||||
- "data-layout for target `{rustc_target}`, `{rustc_layout}`, \
|
||||
- differs from LLVM target's `{llvm_target}` default layout, `{llvm_layout}`",
|
||||
- rustc_target = sess.opts.target_triple,
|
||||
- rustc_layout = target_data_layout,
|
||||
- llvm_target = sess.target.llvm_target,
|
||||
- llvm_layout = llvm_data_layout
|
||||
- );
|
||||
- }
|
||||
- }
|
||||
-
|
||||
let data_layout = SmallCStr::new(&target_data_layout);
|
||||
llvm::LLVMSetDataLayout(llmod, data_layout.as_ptr());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2022 Wind River Systems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
unsetenv("LD_LIBRARY_PATH");
|
||||
execvp("target-rust-ccld-wrapper", argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user