aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--community/rust/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch61
-rw-r--r--community/rust/0014-Link-stage-2-tools-dynamically-to-libstd.patch20
-rw-r--r--community/rust/APKBUILD23
-rw-r--r--community/rust/alpine-change-rpath-to-rustlib.patch8
-rw-r--r--community/rust/link-musl-dynamically.patch52
-rw-r--r--community/rust/musl-fix-static-linking.patch72
6 files changed, 164 insertions, 72 deletions
diff --git a/community/rust/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch b/community/rust/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
new file mode 100644
index 0000000000..d32841103a
--- /dev/null
+++ b/community/rust/0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
@@ -0,0 +1,61 @@
+Additions for build.rs by q66, necessary for our musl setup.
+
+From 1eb558f246269606c6d8d73824ef6b44fa10764e Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Sat, 9 Sep 2017 00:14:16 -0500
+Subject: [PATCH 06/16] Prefer libgcc_eh over libunwind for musl
+
+---
+ src/libunwind/lib.rs | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
+index 9182e349b19..0377fbb58fc 100644
+--- a/src/libunwind/lib.rs
++++ b/src/libunwind/lib.rs
+@@ -23,6 +23,6 @@ cfg_if::cfg_if! {
+ }
+
+ #[cfg(target_env = "musl")]
+-#[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
++#[link(name = "gcc_eh", cfg(target_feature = "crt-static"))]
+ #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
+ extern {}
+diff --git a/src/libunwind/build.rs b/src/libunwind/build.rs
+index f24d957..28828e5 100644
+--- a/src/libunwind/build.rs
++++ b/src/libunwind/build.rs
+@@ -5,15 +5,11 @@ fn main() {
+ let target = env::var("TARGET").expect("TARGET was not set");
+
+ if cfg!(feature = "llvm-libunwind") &&
+- ((target.contains("linux") && !target.contains("musl")) ||
+- target.contains("fuchsia")) {
++ (target.contains("linux") || target.contains("fuchsia")) {
+ // Build the unwinding from libunwind C/C++ source code.
+ llvm_libunwind::compile();
+ } else if target.contains("linux") {
+- if target.contains("musl") {
+- // linking for musl is handled in lib.rs
+- llvm_libunwind::compile();
+- } else if !target.contains("android") {
++ if !target.contains("android") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ }
+ } else if target.contains("freebsd") {
+@@ -99,15 +95,6 @@ mod llvm_libunwind {
+ cfg.file(root.join("src").join(src));
+ }
+
+- if target_env == "musl" {
+- // use the same C compiler command to compile C++ code so we do not need to setup the
+- // C++ compiler env variables on the builders
+- cfg.cpp(false);
+- // linking for musl is handled in lib.rs
+- cfg.cargo_metadata(false);
+- println!("cargo:rustc-link-search=native={}", env::var("OUT_DIR").unwrap());
+- }
+-
+ cfg.compile("unwind");
+ }
+ }
diff --git a/community/rust/0014-Link-stage-2-tools-dynamically-to-libstd.patch b/community/rust/0014-Link-stage-2-tools-dynamically-to-libstd.patch
new file mode 100644
index 0000000000..632717f56b
--- /dev/null
+++ b/community/rust/0014-Link-stage-2-tools-dynamically-to-libstd.patch
@@ -0,0 +1,20 @@
+Replaces an older patch by Samuel Holland. The RUSTC_NO_PREFER_DYNAMIC
+env var was removed and replaced with the following logic in builder.rs.
+
+The idea for this patch is to link stage2 tools dynamically as these will
+be distributed (if built). Intermediate tools from previous stages will
+be statically linked for convenience.
+
+@q66
+
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -1228,6 +1228,8 @@ impl<'a> Builder<'a> {
+ // linking all deps statically into the dylib.
+ if let Mode::Std | Mode::Rustc | Mode::Codegen = mode {
+ rustflags.arg("-Cprefer-dynamic");
++ } else if stage >= 2 {
++ rustflags.arg("-Cprefer-dynamic");
+ }
+
+ Cargo {
diff --git a/community/rust/APKBUILD b/community/rust/APKBUILD
index 69bd76ce16..bb6d5e3d6f 100644
--- a/community/rust/APKBUILD
+++ b/community/rust/APKBUILD
@@ -4,10 +4,10 @@
# Contributor: Jeizsm <jeizsm@gmail.com>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=rust
-pkgver=1.38.0
+pkgver=1.39.0
_llvmver=9
-_bootver=1.37.0
-pkgrel=2
+_bootver=1.38.0
+pkgrel=0
pkgdesc="The Rust Programming Language"
url="https://www.rust-lang.org"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"
@@ -16,8 +16,7 @@ license="Apache-2.0 AND MIT"
# gcc is needed at runtime just for linking. Someday rustc might invoke
# the linker directly, and then we'll only need binutils.
# See: https://github.com/rust-lang/rust/issues/11937
-depends="$pkgname-stdlib=$pkgver-r$pkgrel gcc llvm-libunwind-dev
- llvm-libunwind-static musl-dev"
+depends="$pkgname-stdlib=$pkgver-r$pkgrel gcc musl-dev"
# * Rust is self-hosted, so you need rustc (and cargo) to build rustc...
# The last revision of this abuild that does not depend on itself (uses
@@ -65,12 +64,13 @@ source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz
need-rpath.patch
minimize-rpath.patch
alpine-move-py-scripts-to-share.patch
- alpine-change-rpath-to-rustlib.patch
alpine-target.patch
install-template-shebang.patch
check-rustc
link-musl-dynamically.patch
musl-dont-use-crt-static.patch
+ 0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
+ alpine-change-rpath-to-rustlib.patch
"
builddir="$srcdir/rustc-$pkgver-src"
@@ -312,16 +312,17 @@ _mv() {
mv "$@"
}
-sha512sums="eef16fcbd234ffe76158dd971fcc10ca129816c47f84ff2f2fe424c42509c8661ab45458f968cd88bb8eb6bab028d5d86920a4dee1f673f48270e1f446ffa882 rustc-1.38.0-src.tar.gz
-f5aa0124618acc0176dc30b2fab6d15327c1978db55ccf2074d1db88e0a1bbdaebc0bcdcfd5a8554964edb51be9830c6db64bc99f237463488a45c9804170a4e musl-fix-static-linking.patch
+sha512sums="77be74410b9f7a2e9f78f7a9860964e122ab9518553acc2cc80d5abeecf3302e9b3ed1fd29e022cccff1f9ff4a568b4015c0d3ac0a524f06e38e9cb360a3341e rustc-1.39.0-src.tar.gz
+8d52048070e9a158810f5ef71eae07a3b107b60986375a593c3509f4c47f8e2f7fcdff8bc558c03c46127dbf66c4077dd7b5b422a83f2c49fb5d52ecfae5697e musl-fix-static-linking.patch
41fd9e8a8dd99074d95d664e65f92dba644b8ef9fa37b9a1d781a01fe49eaa254c430f0f277622dc4f8203aad2d129a045fdf1679a0da526d549fac60654be26 musl-fix-linux_musl_base.patch
97e81c57af93df550577f41d795185a9eb0c37528776c250076cc57f06c87e81139eb71cd6b6a4730528511821ae50c304d7deb534d6422cd08bb44193ae605d static-pie.patch
d4659b56dbf1218da98b995a0a89a8cfd069dd94b3e9aef4aee987484d96fc8b92f6d695ea4123eff26711961f2db2f7324bf5b4043f41722cd89581aac97f1c need-rpath.patch
e90e544d2413ae79c553bb1d82eac9b41eb2a7c7ffb7cb28dc3573418bd453c27dcc48f38ce4b8e33bb994b5481db70303c707231b7d4f7fde561bebf0838f21 minimize-rpath.patch
35e0619672843d9dd41df4a086404a59b57c12fa014e42d06102bc3856a96ed021e716f9d581ec5c89444acbaedd3edcd2b8a85576df3bb4451c0edde3afbba5 alpine-move-py-scripts-to-share.patch
-4f5746acb08c18f749691a8455cc81ea2e9a361621790b006b884c9c895ab9e51a001b6638bed071a9af5c232ed8d1b43c58260839a3f6dce4eec3f495ce4348 alpine-change-rpath-to-rustlib.patch
080c3c1af15936c3795724d3cf0f60798ef470bce898e43b6757843bf56f6d46de3dd5b9ea3b116b2011b40373cf8daf17abc94cfff4bdb6221bd431aa0844fd alpine-target.patch
7d59258d4462eba0207739a5c0c8baf1f19d9a396e5547bb4d59d700eb94d50ba6add2e523f3e94e29e993821018594625ea4ac86304fb58f7f8c82622a26ab0 install-template-shebang.patch
c31fdfe8a9b3411576c75da46645cf0465b9053000a2ab49cf9b2f2733f679d6d33acbf236d67a20e14935d094a685453b7f1840180249f39d610fd0902c3125 check-rustc
-78484210917af128a0fa1cfd762b937e2ff047764829e4ba5a10c1f4589bfb2420bf183b039ef88d8d9a2a60e5e150b7e1cd7e7aa1b1154baa2034d485a8a3bf link-musl-dynamically.patch
-795194976763326c5e4a9eefc8b651b6d5fb533d2d000631ed48a92bafac90e9ca33b8d662e6c53ef109ea1a90c69def715d7d7154e3f9fb9035a58a313a7db3 musl-dont-use-crt-static.patch"
+2a91c0d149f19a2268b2db8e375e0c10820529f588161d8d8e68900d929235d9b1cb4f0d64539c1e20ecca3948b4715f2d9d3d16a2754373d56b4b5808bed6bd link-musl-dynamically.patch
+795194976763326c5e4a9eefc8b651b6d5fb533d2d000631ed48a92bafac90e9ca33b8d662e6c53ef109ea1a90c69def715d7d7154e3f9fb9035a58a313a7db3 musl-dont-use-crt-static.patch
+f15c8e6a4c8ad33ee5874580ed76463e2a7359e9b4a8651eb974ea5354c3f992fd2ce1d04661ee8cff2105b25967428894ecdd144a6a45f09c7e1952b2f3731c 0006-Prefer-libgcc_eh-over-libunwind-for-musl.patch
+7755637b140c5ddf01a8805b74b1b71a7e581c32d7deabf1372a94ccec30b6c494603cd5ab362f429b8b537ff4f7ee22de1b1ff43d5131c9130216319464773f alpine-change-rpath-to-rustlib.patch"
diff --git a/community/rust/alpine-change-rpath-to-rustlib.patch b/community/rust/alpine-change-rpath-to-rustlib.patch
index 3eb1a5d02e..8e3e018500 100644
--- a/community/rust/alpine-change-rpath-to-rustlib.patch
+++ b/community/rust/alpine-change-rpath-to-rustlib.patch
@@ -22,12 +22,12 @@ Related upstream issues:
* https://github.com/rust-lang/rust/issues/37971
* https://github.com/rust-lang-nursery/rustup.rs/issues/837
---- a/src/bootstrap/bin/rustc.rs
-+++ b/src/bootstrap/bin/rustc.rs
-@@ -224,11 +224,11 @@
+--- a/src/bootstrap/builder.rs
++++ b/src/bootstrap/builder.rs
+@@ -967,11 +967,11 @@
// so. Note that this is definitely a hack, and we should likely
// flesh out rpath support more fully in the future.
- cmd.arg("-Z").arg("osx-rpath-install-name");
+ rustflags.arg("-Zosx-rpath-install-name");
- Some("-Wl,-rpath,@loader_path/../lib")
+ Some("-Wl,-rpath,@loader_path/../lib".to_string())
} else if !target.contains("windows") &&
diff --git a/community/rust/link-musl-dynamically.patch b/community/rust/link-musl-dynamically.patch
index 20a41fe3e7..5ba322cb4b 100644
--- a/community/rust/link-musl-dynamically.patch
+++ b/community/rust/link-musl-dynamically.patch
@@ -1,41 +1,27 @@
-We don't need those, we provide musl ourselves.
---- rustc-1.35.0-src/src/bootstrap/compile.rs
-+++ rustc-1.35.0-src/src/bootstrap/compile.rs
-@@ -114,20 +114,7 @@ impl Step for Std {
- fn copy_third_party_objects(builder: &Builder<'_>, compiler: &Compiler, target: Interned<String>) {
- let libdir = builder.sysroot_libdir(*compiler, target);
+--- rustc-1.38.0-src/vendor/libc/src/lib.rs
++++ rustc-1.38.0-src/vendor/libc/src/lib.rs
+@@ -27,6 +27,7 @@
+ #![deny(missing_copy_implementations, safe_packed_borrows)]
+ #![no_std]
+ #![cfg_attr(feature = "rustc-dep-of-std", no_core)]
++#![cfg_attr(feature = "rustc-dep-of-std", feature(static_nobundle))]
+ #![cfg_attr(target_os = "redox", feature(static_nobundle))]
-- // Copies the crt(1,i,n).o startup objects
-- //
-- // Since musl supports fully static linking, we can cross link for it even
-- // with a glibc-targeting toolchain, given we have the appropriate startup
-- // files. As those shipped with glibc won't work, copy the ones provided by
-- // musl so we have them on linux-gnu hosts.
-- if target.contains("musl") {
-- for &obj in &["crt1.o", "crti.o", "crtn.o"] {
-- builder.copy(
-- &builder.musl_root(target).unwrap().join("lib").join(obj),
-- &libdir.join(obj),
-- );
-- }
-- } else if target.ends_with("-wasi") {
-+ if target.ends_with("-wasi") {
- for &obj in &["crt1.o"] {
- builder.copy(
- &builder.wasi_root(target).unwrap().join("lib/wasm32-wasi").join(obj),
---- rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-+++ rustc-1.35.0-src/vendor/libc/src/unix/mod.rs
-@@ -306,13 +306,6 @@ cfg_if! {
- } else if #[cfg(feature = "use_std")] {
+ #[macro_use]
+--- rustc-1.38.0-src/vendor/libc/src/unix/mod.rs
++++ rustc-1.38.0-src/vendor/libc/src/unix/mod.rs
+@@ -297,11 +297,11 @@ cfg_if! {
// cargo build, don't pull in anything extra as the libstd dep
// already pulls in all libs.
-- } else if #[cfg(target_env = "musl")] {
-- #[cfg_attr(feature = "rustc-dep-of-std",
+ } else if #[cfg(target_env = "musl")] {
++ #[link(name = "c")]
++ extern {}
+ #[cfg_attr(feature = "rustc-dep-of-std",
- link(name = "c", kind = "static",
-- cfg(target_feature = "crt-static")))]
++ link(name = "gcc", kind = "static-nobundle",
+ cfg(target_feature = "crt-static")))]
- #[cfg_attr(feature = "rustc-dep-of-std",
- link(name = "c", cfg(not(target_feature = "crt-static"))))]
-- extern {}
+ extern {}
} else if #[cfg(target_os = "emscripten")] {
#[link(name = "c")]
- extern {}
diff --git a/community/rust/musl-fix-static-linking.patch b/community/rust/musl-fix-static-linking.patch
index 820aa52cb3..74e9e1e1b1 100644
--- a/community/rust/musl-fix-static-linking.patch
+++ b/community/rust/musl-fix-static-linking.patch
@@ -1,29 +1,53 @@
-From: Shiz <hi@shiz.me>
-Date: Fri, 21 Apr 2017 01:04:46 +0200
-Last-Updated: Sat, 19 May 2018 23:54:30 +0200
-Subject: [PATCH] Support fully static linking on *nix targets
+From 10bd267ac2621267e1f537a5a7df34cb87354cd3 Mon Sep 17 00:00:00 2001
+From: Samuel Holland <samuel@sholland.org>
+Date: Fri, 8 Sep 2017 00:05:18 -0500
+Subject: [PATCH 04/16] Require static native libraries when linking static
+ executables
-It adds the proper linker argument for static result objects to `Linker`
-and implements them for `GnuLinker` and `MsvcLinker`.
+On ELF targets like Linux, gcc/ld will create a dynamically-linked
+executable without warning, even when passed `-static`, when asked to
+link to a `.so`. Avoid this confusing and unintended behavior by always
+using the static version of libraries when trying to link static
+executables.
-Finally, if no linking preference is given for native libraries
-(`NativeLibraryKind::NativeUnknown`), they are linked statically if full
-static linking is requested, instead of dynamically as before.
+Fixes #54243
+---
+ src/librustc_codegen_ssa/back/link.rs | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs
+index e3d297e7862..974e8c0239b 100644
--- a/src/librustc_codegen_ssa/back/link.rs
+++ b/src/librustc_codegen_ssa/back/link.rs
-@@ -1218,13 +1218,13 @@ fn add_local_native_libraries(cmd: &mut dyn Linker,
- let search_path = archive_search_paths(sess);
- for lib in relevant_libs {
- let name = match lib.name {
- Some(ref l) => l,
- None => continue,
- };
- match lib.kind {
-- NativeLibraryKind::NativeUnknown => cmd.link_dylib(&name.as_str()),
-+ NativeLibraryKind::NativeUnknown => if sess.crt_static() { cmd.link_staticlib(&name.as_str()) } else { cmd.link_dylib(&name.as_str()) },
- NativeLibraryKind::NativeFramework => cmd.link_framework(&name.as_str()),
- NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&name.as_str()),
- NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&name.as_str(),
- &search_path)
- }
+@@ -1602,9 +1602,7 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
+ }
+ }
+
+-// Link in all of our upstream crates' native dependencies. Remember that
+-// all of these upstream native dependencies are all non-static
+-// dependencies. We've got two cases then:
++// Link in all of our upstream crates' native dependencies. We have two cases:
+ //
+ // 1. The upstream crate is an rlib. In this case we *must* link in the
+ // native dependency because the rlib is just an archive.
+@@ -1647,7 +1645,19 @@ pub fn add_upstream_native_libraries(cmd: &mut dyn Linker,
+ continue
+ }
+ match lib.kind {
+- NativeLibraryKind::NativeUnknown => cmd.link_dylib(name),
++ NativeLibraryKind::NativeUnknown => {
++ // On some targets, like Linux, linking a static executable inhibits using
++ // dylibs at all. Force native libraries to be static, even if for example
++ // an upstream rlib was originally linked against a native shared library.
++ if crate_type == config::CrateType::Executable
++ && sess.crt_static()
++ && !sess.target.target.options.crt_static_allows_dylibs
++ {
++ cmd.link_staticlib(name)
++ } else {
++ cmd.link_dylib(name)
++ }
++ },
+ NativeLibraryKind::NativeFramework => cmd.link_framework(name),
+ NativeLibraryKind::NativeStaticNobundle => {
+ // Link "static-nobundle" native libs only if the crate they originate from