2016-08-06 20:41:08 +00:00
|
|
|
From: Jakub Jirutka <jakub@jirutka.cz>
|
|
|
|
Date: Thu, 04 Aug 2016 17:53:00 +0200
|
|
|
|
Subject: [PATCH] Do not link musl statically
|
|
|
|
|
|
|
|
Static linking of rustc on Alpine doesn't work yet.
|
|
|
|
|
|
|
|
This patch is ported from
|
|
|
|
https://gist.github.com/japaric/52b8816a4c86f5a4699bcc50ebc3e020.
|
|
|
|
|
2016-09-30 13:14:41 +00:00
|
|
|
--- a/src/bootstrap/sanity.rs
|
|
|
|
+++ b/src/bootstrap/sanity.rs
|
2016-11-12 17:41:23 +00:00
|
|
|
@@ -115,27 +115,6 @@
|
2016-08-06 20:41:08 +00:00
|
|
|
panic!("the iOS target is only supported on OSX");
|
|
|
|
}
|
2016-11-12 17:41:23 +00:00
|
|
|
|
2016-08-06 20:41:08 +00:00
|
|
|
- // Make sure musl-root is valid if specified
|
2016-09-30 13:14:41 +00:00
|
|
|
- if target.contains("musl") && !target.contains("mips") {
|
2016-11-12 17:41:23 +00:00
|
|
|
- match build.musl_root(target) {
|
|
|
|
- Some(root) => {
|
2016-08-06 20:41:08 +00:00
|
|
|
- if fs::metadata(root.join("lib/libc.a")).is_err() {
|
|
|
|
- panic!("couldn't find libc.a in musl dir: {}",
|
|
|
|
- root.join("lib").display());
|
|
|
|
- }
|
|
|
|
- if fs::metadata(root.join("lib/libunwind.a")).is_err() {
|
|
|
|
- panic!("couldn't find libunwind.a in musl dir: {}",
|
|
|
|
- root.join("lib").display());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- None => {
|
2016-11-12 17:41:23 +00:00
|
|
|
- panic!("when targeting MUSL either the build.musl-root \
|
|
|
|
- option or the target.$TARGET.musl-root one must \
|
|
|
|
- be specified in config.toml")
|
2016-08-06 20:41:08 +00:00
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if target.contains("msvc") {
|
|
|
|
// There are three builds of cmake on windows: MSVC, MinGW, and
|
|
|
|
// Cygwin. The Cygwin build does not have generators for Visual
|
|
|
|
--- a/src/liblibc/src/unix/mod.rs
|
|
|
|
+++ b/src/liblibc/src/unix/mod.rs
|
2016-09-30 13:14:41 +00:00
|
|
|
@@ -197,9 +197,6 @@
|
2016-08-06 20:41:08 +00:00
|
|
|
} else if #[cfg(all(not(stdbuild), feature = "use_std"))] {
|
|
|
|
// cargo build, don't pull in anything extra as the libstd dep
|
|
|
|
// already pulls in all libs.
|
2016-09-30 13:14:41 +00:00
|
|
|
- } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] {
|
2016-08-06 20:41:08 +00:00
|
|
|
- #[link(name = "c", kind = "static")]
|
|
|
|
- extern {}
|
|
|
|
} else if #[cfg(target_os = "emscripten")] {
|
|
|
|
#[link(name = "c")]
|
|
|
|
extern {}
|
|
|
|
--- a/src/librustc_back/target/x86_64_unknown_linux_musl.rs
|
|
|
|
+++ b/src/librustc_back/target/x86_64_unknown_linux_musl.rs
|
|
|
|
@@ -11,7 +11,7 @@
|
2016-09-30 13:14:41 +00:00
|
|
|
use target::{Target, TargetResult};
|
|
|
|
|
|
|
|
pub fn target() -> TargetResult {
|
2016-08-06 20:41:08 +00:00
|
|
|
- let mut base = super::linux_musl_base::opts();
|
|
|
|
+ let mut base = super::linux_base::opts();
|
|
|
|
base.cpu = "x86-64".to_string();
|
|
|
|
base.max_atomic_width = 64;
|
|
|
|
base.pre_link_args.push("-m64".to_string());
|
|
|
|
--- a/src/libunwind/build.rs
|
|
|
|
+++ b/src/libunwind/build.rs
|
|
|
|
@@ -16,9 +16,7 @@
|
|
|
|
let target = env::var("TARGET").unwrap();
|
2016-09-30 13:14:41 +00:00
|
|
|
|
2016-08-06 20:41:08 +00:00
|
|
|
if target.contains("linux") {
|
2016-09-30 13:14:41 +00:00
|
|
|
- if target.contains("musl") && !target.contains("mips") {
|
2016-08-06 20:41:08 +00:00
|
|
|
- println!("cargo:rustc-link-lib=static=unwind");
|
|
|
|
- } else if !target.contains("android") {
|
|
|
|
+ if !target.contains("android") {
|
|
|
|
println!("cargo:rustc-link-lib=gcc_s");
|
|
|
|
}
|
|
|
|
} else if target.contains("freebsd") {
|