aboutsummaryrefslogtreecommitdiffstats
path: root/community/rust/musl-fix-static-linking.patch
diff options
context:
space:
mode:
authorRasmus Thomsen <oss@cogitri.dev>2019-11-23 14:32:01 +0100
committerRasmus Thomsen <oss@cogitri.dev>2019-11-24 00:18:10 +0100
commit04ce325809f0ccdb7207868f42253c55a47b921c (patch)
tree09bc66658e1d9bb67c37992a06019b37cac5f2b6 /community/rust/musl-fix-static-linking.patch
parent5186561bb8442f65021d73102981dc822a11c4e9 (diff)
downloadaports-04ce325809f0ccdb7207868f42253c55a47b921c.tar.bz2
aports-04ce325809f0ccdb7207868f42253c55a47b921c.tar.xz
community/rust: upgrade to 1.39.0
Diffstat (limited to 'community/rust/musl-fix-static-linking.patch')
-rw-r--r--community/rust/musl-fix-static-linking.patch72
1 files changed, 48 insertions, 24 deletions
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