diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-07-25 01:29:02 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2024-10-17 00:58:44 -0500 |
commit | 0f5207bac6c6280ecf6d9910ddfb04f35cec6244 (patch) | |
tree | 099423a1edaf962cc0a6023901a59cdc8234ed63 /bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch | |
parent | 3bb402800fd7e4c05da8348662c5c0a57bbadec6 (diff) | |
download | packages-0f5207bac6c6280ecf6d9910ddfb04f35cec6244.tar.gz packages-0f5207bac6c6280ecf6d9910ddfb04f35cec6244.tar.bz2 packages-0f5207bac6c6280ecf6d9910ddfb04f35cec6244.tar.xz packages-0f5207bac6c6280ecf6d9910ddfb04f35cec6244.zip |
bootstrap/rust-1.62: New package
Diffstat (limited to 'bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch')
-rw-r--r-- | bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch b/bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch new file mode 100644 index 000000000..123e940e3 --- /dev/null +++ b/bootstrap/rust-1.62/0004-Use-static-native-libraries-when-linking-static-exec.patch @@ -0,0 +1,70 @@ +From 53c4a9c8ab26e10d1790b5a85fa26058f4252e2d 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/14] Use static native libraries when linking static + executables + +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. +--- + compiler/rustc_codegen_ssa/src/back/link.rs | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs +index 58e0667d678..93d8a6e8680 100644 +--- a/compiler/rustc_codegen_ssa/src/back/link.rs ++++ b/compiler/rustc_codegen_ssa/src/back/link.rs +@@ -1959,7 +1959,7 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>( + // external build system already has the native dependencies defined, and it + // will provide them to the linker itself. + if sess.opts.debugging_opts.link_native_libraries { +- add_upstream_native_libraries(cmd, sess, codegen_results); ++ add_upstream_native_libraries(cmd, sess, codegen_results, crate_type); + } + + // Library linking above uses some global state for things like `-Bstatic`/`-Bdynamic` to make +@@ -2528,8 +2528,7 @@ fn add_dynamic_crate(cmd: &mut dyn Linker, sess: &Session, cratepath: &Path) { + } + } + +-/// 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. +@@ -2545,6 +2546,7 @@ fn add_upstream_native_libraries( + cmd: &mut dyn Linker, + sess: &Session, + codegen_results: &CodegenResults, ++ crate_type: CrateType, + ) { + let mut last = (None, NativeLibKind::Unspecified, None); + for &cnum in &codegen_results.crate_info.used_crates { +@@ -2570,7 +2570,19 @@ fn add_upstream_native_libraries( + NativeLibKind::Dylib { as_needed } => { + cmd.link_dylib(name, verbatim, as_needed.unwrap_or(true)) + } +- NativeLibKind::Unspecified => cmd.link_dylib(name, verbatim, true), ++ NativeLibKind::Unspecified => { ++ // 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(Some(crate_type)) ++ && !sess.target.options.crt_static_allows_dylibs ++ { ++ cmd.link_staticlib(name, verbatim) ++ } else { ++ cmd.link_dylib(name, verbatim, true) ++ } ++ }, + NativeLibKind::Framework { as_needed } => { + cmd.link_framework(name, as_needed.unwrap_or(true)) + } +-- +2.35.1 + |