rust: 1.71.0

This commit is contained in:
Owen Rafferty 2023-07-19 20:08:30 -05:00
parent ea0cb1da5d
commit b2f9046d41
No known key found for this signature in database
8 changed files with 3277 additions and 15 deletions

View File

@ -2,7 +2,9 @@
export DESTDIR="$1"
patch -p1 < fix-curl.patch
for p in *.patch; do
patch -p1 < "$p"
done
# Instruct the compiler to trim absolute paths in resulting binaries and instead
# change them to relative paths ($PWD/... ./...).
@ -14,14 +16,22 @@ sed 's/\(crt_static_default = \)true/\1false/' \
mv -f _ compiler/rustc_target/src/spec/linux_musl_base.rs
# Ignore checksums of files modified above.
sed 's/\("files":{\)[^}]*/\1/' \
vendor/curl-sys/.cargo-checksum.json > _
mv -f _ vendor/curl-sys/.cargo-checksum.json
for p in \
curl-sys \
getrandom-0.2.8 \
libc \
libc-0.2.138 \
libc-0.2.139 \
libc-0.2.140 \
libc-0.2.143
do
sed 's/\("files":{\)[^}]*/\1/' vendor/"$p"/.cargo-checksum.json > _
mv -f _ vendor/"$p"/.cargo-checksum.json
done
cat > config.toml <<EOF
[llvm]
link-shared = true
skip-rebuild = true
[build]
build = "x86_64-unknown-linux-musl"
@ -66,7 +76,7 @@ EOF
# This mimics the download process of rust's 'x.py'
# bootstrap library to allow for the removal of the internet
# connection requirement per build.
mkdir -p "${cache_dir:=build/cache/2023-03-28}"
mkdir -p "${cache_dir:=build/cache/2023-06-01}"
for tarball in *.tar.xz\?no-extract; do
mv -f "$tarball" "$cache_dir/${tarball%%\?no-extract}"

View File

@ -1,5 +1,9 @@
d6f1c510023b719784883f5538fcd2a94fd5fbe97c4ceab65fd43b9d9747ad169d
de41e09af69693640ce41236a8ab3f246becaf3777af2debf6728e664e74990e67
3b1c01735f26ce7c00f39c64cc679b96696e303118144e4f9dbcbf5ac62c9d4bcd
c04b22160824bb3429877edae2e1c7ba5bbc6e7f22a6c9ab4f1dbeb2c92ef8adbf
bd58fef26b44e5e67417ed1e67ef77561df69384bbb4ab77826ebc88b1505d3382
a1625920c2162fd0844f18ae6292fae7a9a2208253d8e236286c555c65cde60c92
384c95ec0d374c288e2b39ac184f845169a572543138b06b8999242a1820111b59
a0a409bae3de782f84a56ed4b7387079adb46915ead28931762c777b52a126f3f3
f7b83d9cf2335af67330b057b864926ca3635f7597f009add1f501a33544e3af08
97086f892efe0679b6429e507aa65138ff21d1c776f583e593f5c1911e83bf1e7a
86c5061bd6d52d79b2a41a82a08c60aa1e4562ffee8ca97deccb8090e9f2b92cee
1265a7cf31f4977cae95ae624134636617d1401535684fdbf128a331519be649de
490c7bf34c246d9c01e782bf8e9321698f8cdb547f9c133e28fefe148822384145

View File

@ -0,0 +1,150 @@
Patch-Source: https://github.com/rust-lang/rust/pull/111698
--
From 6b8fcb8e5918911c0ba4e155cb2a97e804c62e81 Mon Sep 17 00:00:00 2001
From: Amanieu d'Antras <amanieu@gmail.com>
Date: Wed, 17 May 2023 23:53:04 +0200
Subject: [PATCH] Force all native libraries to be statically linked when
linking a static binary
---
compiler/rustc_codegen_ssa/src/back/link.rs | 38 ++++++++++++++++++---
compiler/rustc_target/src/spec/mod.rs | 11 ++++++
2 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index ea06cb02d8baf..91598e8d879ee 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2129,7 +2129,14 @@ fn linker_with_args<'a>(
cmd.add_as_needed();
// Local native libraries of all kinds.
- add_local_native_libraries(cmd, sess, archive_builder_builder, codegen_results, tmpdir);
+ add_local_native_libraries(
+ cmd,
+ sess,
+ archive_builder_builder,
+ codegen_results,
+ tmpdir,
+ link_output_kind,
+ );
// Upstream rust crates and their non-dynamic native libraries.
add_upstream_rust_crates(
@@ -2139,10 +2146,18 @@ fn linker_with_args<'a>(
codegen_results,
crate_type,
tmpdir,
+ link_output_kind,
);
// Dynamic native libraries from upstream crates.
- add_upstream_native_libraries(cmd, sess, archive_builder_builder, codegen_results, tmpdir);
+ add_upstream_native_libraries(
+ cmd,
+ sess,
+ archive_builder_builder,
+ codegen_results,
+ tmpdir,
+ link_output_kind,
+ );
// Link with the import library generated for any raw-dylib functions.
for (raw_dylib_name, raw_dylib_imports) in
@@ -2397,6 +2412,7 @@ fn add_native_libs_from_crate(
cnum: CrateNum,
link_static: bool,
link_dynamic: bool,
+ link_output_kind: LinkOutputKind,
) {
if !sess.opts.unstable_opts.link_native_libraries {
// If `-Zlink-native-libraries=false` is set, then the assumption is that an
@@ -2476,8 +2492,16 @@ fn add_native_libs_from_crate(
}
}
NativeLibKind::Unspecified => {
- if link_dynamic {
- cmd.link_dylib(name, verbatim, true);
+ // If we are generating a static binary, prefer static library when the
+ // link kind is unspecified.
+ if !link_output_kind.can_link_dylib() && !sess.target.crt_static_allows_dylibs {
+ if link_static {
+ cmd.link_staticlib(name, verbatim)
+ }
+ } else {
+ if link_dynamic {
+ cmd.link_dylib(name, verbatim, true);
+ }
}
}
NativeLibKind::Framework { as_needed } => {
@@ -2504,6 +2528,7 @@ fn add_local_native_libraries(
archive_builder_builder: &dyn ArchiveBuilderBuilder,
codegen_results: &CodegenResults,
tmpdir: &Path,
+ link_output_kind: LinkOutputKind,
) {
if sess.opts.unstable_opts.link_native_libraries {
// User-supplied library search paths (-L on the command line). These are the same paths
@@ -2533,6 +2558,7 @@ fn add_local_native_libraries(
LOCAL_CRATE,
link_static,
link_dynamic,
+ link_output_kind,
);
}
@@ -2543,6 +2569,7 @@ fn add_upstream_rust_crates<'a>(
codegen_results: &CodegenResults,
crate_type: CrateType,
tmpdir: &Path,
+ link_output_kind: LinkOutputKind,
) {
// All of the heavy lifting has previously been accomplished by the
// dependency_format module of the compiler. This is just crawling the
@@ -2620,6 +2647,7 @@ fn add_upstream_rust_crates<'a>(
cnum,
link_static,
link_dynamic,
+ link_output_kind,
);
}
}
@@ -2630,6 +2658,7 @@ fn add_upstream_native_libraries(
archive_builder_builder: &dyn ArchiveBuilderBuilder,
codegen_results: &CodegenResults,
tmpdir: &Path,
+ link_output_kind: LinkOutputKind,
) {
let search_path = OnceCell::new();
for &cnum in &codegen_results.crate_info.used_crates {
@@ -2658,6 +2687,7 @@ fn add_upstream_native_libraries(
cnum,
link_static,
link_dynamic,
+ link_output_kind,
);
}
}
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index ba4b89c9ea10b..e1915e16e2002 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -596,6 +596,17 @@ impl LinkOutputKind {
_ => return None,
})
}
+
+ pub fn can_link_dylib(self) -> bool {
+ match self {
+ LinkOutputKind::StaticNoPicExe | LinkOutputKind::StaticPicExe => false,
+ LinkOutputKind::DynamicNoPicExe
+ | LinkOutputKind::DynamicPicExe
+ | LinkOutputKind::DynamicDylib
+ | LinkOutputKind::StaticDylib
+ | LinkOutputKind::WasiReactorExe => true,
+ }
+ }
}
impl fmt::Display for LinkOutputKind {

View File

@ -0,0 +1,25 @@
diff --git a/vendor/getrandom-0.2.8/src/util_libc.rs b/vendor/getrandom-0.2.8/src/util_libc.rs
index d057071..83a3f2b 100644
--- a/vendor/getrandom-0.2.8/src/util_libc.rs
+++ b/vendor/getrandom-0.2.8/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);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
Patch-Source: https://github.com/rust-lang/rust/pull/106246
--
From e2355ea7f22219f1fb3919a45e4f07502652ee5c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 19 May 2023 09:22:21 -0700
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
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 | 25 +++++++++++++++++++------
3 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/library/std/src/os/linux/fs.rs b/library/std/src/os/linux/fs.rs
index 479bbcc17a89e..ab0b2a3eda3f5 100644
--- a/library/std/src/os/linux/fs.rs
+++ b/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
diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs
index cb630eede6da0..c1e0c05213ac2 100644
--- a/library/std/src/sys/unix/fd.rs
+++ b/library/std/src/sys/unix/fd.rs
@@ -122,9 +122,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 {
@@ -277,9 +280,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 {
diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
index 09db5b11dbfd3..e31f987c7dc9a 100644
--- a/library/std/src/sys/unix/fs.rs
+++ b/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",
@@ -798,7 +811,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> {
@@ -822,7 +835,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> {

View File

@ -1,5 +1,9 @@
https://static.rust-lang.org/dist/rustc-1.69.0-src.tar.xz
https://static.rust-lang.org/dist/2023-03-28/rust-std-1.68.2-x86_64-unknown-linux-musl.tar.xz?no-extract
https://static.rust-lang.org/dist/2023-03-28/rustc-1.68.2-x86_64-unknown-linux-musl.tar.xz?no-extract
https://static.rust-lang.org/dist/2023-03-28/cargo-1.68.2-x86_64-unknown-linux-musl.tar.xz?no-extract
https://static.rust-lang.org/dist/rustc-1.71.0-src.tar.xz
https://static.rust-lang.org/dist/2023-06-01/rust-std-1.70.0-x86_64-unknown-linux-musl.tar.xz?no-extract
https://static.rust-lang.org/dist/2023-06-01/rustc-1.70.0-x86_64-unknown-linux-musl.tar.xz?no-extract
https://static.rust-lang.org/dist/2023-06-01/cargo-1.70.0-x86_64-unknown-linux-musl.tar.xz?no-extract
patches/fix-crt-static.patch
patches/fix-curl.patch
patches/lfs64-getrandom.patch
patches/lfs64-libc.patch
patches/lfs64-rust.patch

View File

@ -1 +1 @@
1.69.0 1
1.71.0 1