aboutsummaryrefslogtreecommitdiffstats
path: root/community/rust/musl-fix-static-linking.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/rust/musl-fix-static-linking.patch')
-rw-r--r--community/rust/musl-fix-static-linking.patch42
1 files changed, 26 insertions, 16 deletions
diff --git a/community/rust/musl-fix-static-linking.patch b/community/rust/musl-fix-static-linking.patch
index 85de05e542..93fe79d15f 100644
--- a/community/rust/musl-fix-static-linking.patch
+++ b/community/rust/musl-fix-static-linking.patch
@@ -100,22 +100,20 @@ static linking is requested, instead of dynamically as before.
// # Telling the linker what we're doing
-@@ -983,11 +983,14 @@
- cmd.link_whole_staticlib(&l.name.as_str(), &search_path);
- }
-
-- cmd.hint_dynamic();
-+ let fully_static = sess.fully_static();
-+ if !fully_static {
-+ cmd.hint_dynamic();
-+ }
-
- for lib in others {
+@@ -983,13 +983,13 @@
+ let relevant_libs = sess.cstore.used_libraries().into_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 fully_static { cmd.link_staticlib(&lib.name.as_str()) } else { cmd.link_dylib(&lib.name.as_str()) },
++ NativeLibraryKind::NativeUnknown => if sess.fully_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::NativeStatic => bug!(),
+ NativeLibraryKind::NativeStaticNobundle => cmd.link_staticlib(&lib.name.as_str()),
+ NativeLibraryKind::NativeStatic => cmd.link_whole_staticlib(&lib.name.as_str(),
+ &search_path)
}
--- a/src/librustc_trans/back/linker.rs
+++ b/src/librustc_trans/back/linker.rs
@@ -127,16 +125,18 @@ static linking is requested, instead of dynamically as before.
fn optimize(&mut self);
fn debuginfo(&mut self);
fn no_default_libraries(&mut self);
-@@ -93,6 +93,8 @@
+@@ -93,8 +93,10 @@
fn no_whole_archives(&mut self);
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType);
fn subsystem(&mut self, subsystem: &str);
+ // Should have been finalize(self), but we don't support self-by-value on trait objects (yet?).
+ fn finalize(&mut self) -> Command;
+ fn start_group(&mut self);
+ fn end_group(&mut self);
}
- pub struct GnuLinker<'a> {
-@@ -116,6 +117,9 @@
+ pub struct GccLinker<'a> {
+@@ -116,6 +117,9 @@
fn output_filename(&mut self, path: &Path) { self.cmd.arg("-o").arg(path); }
fn add_object(&mut self, path: &Path) { self.cmd.arg(path); }
fn position_independent_executable(&mut self) { self.cmd.arg("-pie"); }
@@ -198,3 +198,13 @@ static linking is requested, instead of dynamically as before.
}
}
+--- a/src/librustc_trans/back/linker.rs
++++ b/src/librustc_trans/back/linker.rs
+@@ -158,6 +158,7 @@ impl<'a> GccLinker<'a> {
+ }
+
+ fn hint_dynamic(&mut self) {
++ if self.sess.fully_static() { return }
+ if !self.takes_hints() { return }
+ if self.hinted_static {
+ self.linker_arg("-Bdynamic");