aboutsummaryrefslogtreecommitdiffstats
path: root/community/rust/musl-fix-static-linking.patch
blob: c697785ab8f158120039a19083bde06d4e2cfc23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

It adds the proper linker argument for static result objects to `Linker`
and implements them for `GnuLinker` and `MsvcLinker`.

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.

--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -1151,13 +1151,13 @@
     let relevant_libs = trans.crate_info.used_libraries.iter().filter(|l| {
         relevant_lib(sess, l)
     });
 
     let search_path = archive_search_paths(sess);
     for lib in relevant_libs {
         match lib.kind {
-            NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()),
+            NativeLibraryKind::NativeUnknown => if sess.crt_static() { cmd.link_staticlib(&lib.name.as_str()) } else { cmd.link_dylib(&lib.name.as_str()) },
             NativeLibraryKind::NativeFramework => cmd.link_framework(&lib.name.as_str()),
             NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&lib.name.as_str()),
             NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&lib.name.as_str(),
                                                                         &search_path)
         }