diff options
-rw-r--r-- | community/rust/APKBUILD | 21 | ||||
-rw-r--r-- | community/rust/alpine-target.patch | 8 | ||||
-rw-r--r-- | community/rust/fix-build.patch | 92 | ||||
-rw-r--r-- | community/rust/musl-fix-jemalloc.patch | 61 | ||||
-rw-r--r-- | community/rust/musl-fix-linux_musl_base.patch | 8 | ||||
-rw-r--r-- | community/rust/musl-fix-static-linking.patch | 42 | ||||
-rw-r--r-- | community/rust/musl-support-dynamic-linking.patch | 12 |
7 files changed, 147 insertions, 97 deletions
diff --git a/community/rust/APKBUILD b/community/rust/APKBUILD index 48ce4e7ffa..62f9462f9c 100644 --- a/community/rust/APKBUILD +++ b/community/rust/APKBUILD @@ -1,11 +1,12 @@ # Contributor: Jakub Jirutka <jakub@jirutka.cz> # Contributor: Shiz <hi@shiz.me> +# Contributor: Jeizsm <jeizsm@gmail.com> # Maintainer: Jakub Jirutka <jakub@jirutka.cz> pkgname=rust -pkgver=1.17.0 +pkgver=1.18.0 _llvmver=3.9 -_bootver=1.16.0 -pkgrel=3 +_bootver=1.17.0 +pkgrel=1 pkgdesc="The Rust Programming Language (compiler)" url="http://www.rust-lang.org" arch="x86_64" @@ -29,7 +30,6 @@ source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz musl-support-dynamic-linking.patch musl-fix-static-linking.patch musl-fix-linux_musl_base.patch - musl-fix-jemalloc.patch llvm-with-ffi.patch static-pie.patch need-rpath.patch @@ -38,6 +38,7 @@ source="https://static.rust-lang.org/dist/rustc-$pkgver-src.tar.gz alpine-move-py-scripts-to-share.patch alpine-change-rpath-to-rustlib.patch alpine-target.patch + fix-build.patch check-rustc " builddir="$srcdir/rustc-$pkgver-src" @@ -169,11 +170,10 @@ _mv() { mv $@ } -sha512sums="781799b29d83b4f0f433814bd818df034526db8e7f88c2df51d3b814eacafe8098d4bbe47ace951e1943325b3267b244007cf04f1f11083645b25aeacd40ebb6 rustc-1.17.0-src.tar.gz -b0a8883e4469b60edd150c84486ab950396d757220f97bd271529576614c6c3b49456098507503832c20619d4bd74246dbc99c78116634a68a6df994793e9a94 musl-support-dynamic-linking.patch -292c1cb4f751d830f5f1300d7ef94f573f698ac51e18243d7ff0d5a47bb1729bb2cbe8fb456e7a479213df5e5fbf49e360c9439d0f5ad7126cb72d161c91566a musl-fix-static-linking.patch -f436fddf7ab70ca5f1424081f5b75450270b200b3d997231323863e11addf76e1d65831a7ca09e3a5b7904ce828766c1f70b08326a175890298f28e5bc8646ef musl-fix-linux_musl_base.patch -c913d04ef419b2b6d8e453f72894070f263c9292abf97114a51884d475d03ce5b032053f1676ba9364800b4b35e394f707995058530ad5e4122c60f65ddd3db7 musl-fix-jemalloc.patch +sha512sums="eff0460b647dfb3490e28d4dec4f9781d31a942f22de75d9bd1ba31591597226b6862ec5132e8b4fcdbcf6e6ffa085ca5dda7ff8260cd82388fc13e8d3b4a2eb rustc-1.18.0-src.tar.gz +b5db9ed04eac26c6fc62cde3f19d29837a5feea68e79165c23b5b5cade2e1d193f2399d27f7622b230996da9565f78825be154574f1cd59189ded8a03a766cfb musl-support-dynamic-linking.patch +d4d39514eca638852307f470250fd12a21781e1e7944377744b7d50290d3a2ab3776fbdfccb7a9221f5da00ca694ac3a5b8c05f72c5e1a0c8711b684b16b1084 musl-fix-static-linking.patch +9ebfb10abb50d74ff08d257d85257ce70ac3ce834aa95a8901808497b14acf3ea898fb197de64d13554eb5feedabe9fd04fec2cc6a7bea9b1335684bfcdcd88b musl-fix-linux_musl_base.patch dc6432293bd060d5e3a73f25870867654fae61995dcd919e244a2dc686b6107556deed8c59ca6002182bfeff5ebc1ca2b89c4028ab0fbfb79e65defe47c9b4b0 llvm-with-ffi.patch 5aaf6715b27b8b786740a55b91216d47985fbef3ccb0ef7e6a81696a2823671f8306143f7ecf77e66af91ef1500072524b9b4c7569508922ad5268df6080fda1 static-pie.patch ff633f2a46c683ad698d1c09c98c06ce9ee9b8d55fa5593cdd485b439ebca3273794d29b5ff32b887be8666f52913a23af6e133c782bd0c4e2c88e306dd3a494 need-rpath.patch @@ -181,5 +181,6 @@ d352614e7c774e181decae210140e789de7fc090327ff371981ad28a11ce51c8c01b27c1101a24bb b00997c65d1a451fafae8b547893c5cbf03f028d2d70f6971aa670f34c2d6fc82728c740ac4a9909fc1999925ff300e4525cfec745cb9c9521e564eb166872a2 alpine-allow-crt-static.patch 498f4649163974afc4f042c43cd0c15d36784031514201a2962061f288a9336c2bc9749f8d2308b8ce3656f8097b5fc5bef505f61e2a6ed422ef4153f5339d77 alpine-move-py-scripts-to-share.patch 8d6206f8c50856724cf7b4c1854ec82547f040358a1c7d44abeacc27a5c205a963b1fec51e58ec06c68d85bd2f68a9e6e27ebe457f39e8dd043de17758f5063f alpine-change-rpath-to-rustlib.patch -aaf359dbfb8f379bef42647890e99ada4b5326c29f726edb16c51b23a5033b5e00363d2fb6d74a4f11dfbb241b21b22c578e2ec269ecd77a87cf20d3620b29a5 alpine-target.patch +e9935f88f959d37da9e696f2722569bc6da6ed17eddc8d496af4a2ee9a561d8e40bd7644089ee26114bb920e04ff05def18d70a6f2347545500d1a23ee96eefa alpine-target.patch +5c1bcd78d2579e1aeacd4f20d849f75127111fb2f06124531af370c7afdcf9ae78d9e3952911197c02099cdedfeb2335699f98568123bdd83c7acc1ddbae7f54 fix-build.patch 79549055dea81379c890b495c82456ab497a9179ec6702c59e11d0748bc668f47fc3d6a69c27a0545bb87c01318631dffc69260bf2d4badc75f53cbf7fad7528 check-rustc" diff --git a/community/rust/alpine-target.patch b/community/rust/alpine-target.patch index e013a6bc2e..fc79b45b9a 100644 --- a/community/rust/alpine-target.patch +++ b/community/rust/alpine-target.patch @@ -8,7 +8,7 @@ and distribution-specific quirks instead of polluting the main musl target of --- /dev/null +++ b/src/librustc_back/target/i586_alpine_linux_musl.rs -@@ -0,0 +1,32 @@ +@@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. @@ -19,6 +19,7 @@ and distribution-specific quirks instead of polluting the main musl target of +// option. This file may not be copied, modified, or distributed +// except according to those terms. + ++use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { @@ -38,6 +39,7 @@ and distribution-specific quirks instead of polluting the main musl target of + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "alpine".to_string(), ++ linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} @@ -55,7 +57,7 @@ and distribution-specific quirks instead of polluting the main musl target of /// Everything `rustc` knows about how to compile for a specific target. --- /dev/null +++ b/src/librustc_back/target/x86_64_alpine_linux_musl.rs -@@ -0,0 +1,32 @@ +@@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. @@ -66,6 +68,7 @@ and distribution-specific quirks instead of polluting the main musl target of +// option. This file may not be copied, modified, or distributed +// except according to those terms. + ++use LinkerFlavor; +use target::{Target, TargetResult}; + +pub fn target() -> TargetResult { @@ -85,6 +88,7 @@ and distribution-specific quirks instead of polluting the main musl target of + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "alpine".to_string(), ++ linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/community/rust/fix-build.patch b/community/rust/fix-build.patch new file mode 100644 index 0000000000..0a8482d731 --- /dev/null +++ b/community/rust/fix-build.patch @@ -0,0 +1,92 @@ +diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs +index 56cbb4cecf2a..dc9dac736278 100644 +--- a/src/bootstrap/flags.rs ++++ b/src/bootstrap/flags.rs +@@ -242,11 +242,18 @@ Arguments: + let cwd = t!(env::current_dir()); + let paths = matches.free[1..].iter().map(|p| cwd.join(p)).collect::<Vec<_>>(); + ++ let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| { ++ if fs::metadata("config.toml").is_ok() { ++ Some(PathBuf::from("config.toml")) ++ } else { ++ None ++ } ++ }); + + // All subcommands can have an optional "Available paths" section + if matches.opt_present("verbose") { + let flags = Flags::parse(&["build".to_string()]); +- let mut config = Config::default(); ++ let mut config = Config::parse(&flags.build, cfg_file.clone()); + config.build = flags.build.clone(); + let mut build = Build::new(flags, config); + metadata::build(&mut build); +@@ -307,14 +314,6 @@ Arguments: + }; + + +- let cfg_file = matches.opt_str("config").map(PathBuf::from).or_else(|| { +- if fs::metadata("config.toml").is_ok() { +- Some(PathBuf::from("config.toml")) +- } else { +- None +- } +- }); +- + let mut stage = matches.opt_str("stage").map(|j| j.parse().unwrap()); + + if matches.opt_present("incremental") { +diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs +index 5ca5ce1648f2..5ef18b89841f 100644 +--- a/src/bootstrap/bin/main.rs ++++ b/src/bootstrap/bin/main.rs +@@ -26,12 +26,6 @@ use bootstrap::{Flags, Config, Build}; + fn main() { + let args = env::args().skip(1).collect::<Vec<_>>(); + let flags = Flags::parse(&args); +- let mut config = Config::parse(&flags.build, flags.config.clone()); +- +- // compat with `./configure` while we're still using that +- if std::fs::metadata("config.mk").is_ok() { +- config.update_with_config_mk(); +- } +- ++ let config = Config::parse(&flags.build, flags.config.clone()); + Build::new(flags, config).build(); + } +diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs +index fd8aa320fb3d..902cd0997a8e 100644 +--- a/src/bootstrap/config.rs ++++ b/src/bootstrap/config.rs +@@ -15,7 +15,7 @@ + + use std::collections::HashMap; + use std::env; +-use std::fs::File; ++use std::fs::{self, File}; + use std::io::prelude::*; + use std::path::PathBuf; + use std::process; +@@ -410,6 +410,12 @@ impl Config { + set(&mut config.rust_dist_src, t.src_tarball); + } + ++ ++ // compat with `./configure` while we're still using that ++ if fs::metadata("config.mk").is_ok() { ++ config.update_with_config_mk(); ++ } ++ + return config + } + +@@ -418,7 +424,7 @@ impl Config { + /// While we still have `./configure` this implements the ability to decode + /// that configuration into this. This isn't exactly a full-blown makefile + /// parser, but hey it gets the job done! +- pub fn update_with_config_mk(&mut self) { ++ fn update_with_config_mk(&mut self) { + let mut config = String::new(); + File::open("config.mk").unwrap().read_to_string(&mut config).unwrap(); + for line in config.lines() { diff --git a/community/rust/musl-fix-jemalloc.patch b/community/rust/musl-fix-jemalloc.patch deleted file mode 100644 index 345398a301..0000000000 --- a/community/rust/musl-fix-jemalloc.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 536011d929ecbd1170baf34e09580e567c971f95 Mon Sep 17 00:00:00 2001 -From: Shiz <hi@shiz.me> -Date: Sat, 8 Apr 2017 20:36:00 +0200 -Subject: [PATCH] Fix jemalloc support for musl - -Just like DragonFlyBSD, using the same symbols as the system allocator will -result in a segmentation fault at runtime due to allocator mismatches. -As such, prefix the jemalloc symbols instead. - -Upstream-Issue: https://github.com/rust-lang/rust/pull/41168 ---- - src/liballoc_jemalloc/build.rs | 2 +- - src/liballoc_jemalloc/lib.rs | 10 +++++----- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs -index ae040a2..f3a0eeb 100644 ---- a/src/liballoc_jemalloc/build.rs -+++ b/src/liballoc_jemalloc/build.rs -@@ -138,7 +138,7 @@ fn main() { - // should be good to go! - cmd.arg("--with-jemalloc-prefix=je_"); - cmd.arg("--disable-tls"); -- } else if target.contains("dragonfly") { -+ } else if target.contains("dragonfly") || target.contains("musl") { - cmd.arg("--with-jemalloc-prefix=je_"); - } - -diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs -index a7a67ef..83cc1ef 100644 ---- a/src/liballoc_jemalloc/lib.rs -+++ b/src/liballoc_jemalloc/lib.rs -@@ -51,23 +51,23 @@ mod imp { - // request it as unprefixing cause segfaults (mismatches in allocators). - extern "C" { - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", -- target_os = "dragonfly", target_os = "windows"), -+ target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_mallocx")] - fn mallocx(size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", -- target_os = "dragonfly", target_os = "windows"), -+ target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_rallocx")] - fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", -- target_os = "dragonfly", target_os = "windows"), -+ target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_xallocx")] - fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", -- target_os = "dragonfly", target_os = "windows"), -+ target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_sdallocx")] - fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); - #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios", -- target_os = "dragonfly", target_os = "windows"), -+ target_os = "dragonfly", target_os = "windows", target_env = "musl"), - link_name = "je_nallocx")] - fn nallocx(size: size_t, flags: c_int) -> size_t; - } diff --git a/community/rust/musl-fix-linux_musl_base.patch b/community/rust/musl-fix-linux_musl_base.patch index 38194290cb..f2efb065e0 100644 --- a/community/rust/musl-fix-linux_musl_base.patch +++ b/community/rust/musl-fix-linux_musl_base.patch @@ -12,13 +12,13 @@ See https://github.com/rust-lang/rust/pull/40113 - // Make sure that the linker/gcc really don't pull in anything, including - // default objects, libs, etc. -- base.pre_link_args.push("-nostdlib".to_string()); +- base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string()); - // At least when this was tested, the linker would not add the // `GNU_EH_FRAME` program header to executables generated, which is required // when unwinding to locate the unwinding information. I'm not sure why this // argument is *not* necessary for normal builds, but it can't hurt! - base.pre_link_args.push("-Wl,--eh-frame-hdr".to_string()); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string()); - // There's a whole bunch of circular dependencies when dealing with MUSL - // unfortunately. To put this in perspective libc is statically linked to @@ -42,8 +42,8 @@ See https://github.com/rust-lang/rust/pull/40113 - // link everything as a group, not stripping anything out until everything - // is processed. The linker will still perform a pass to strip out object - // files but it won't do so until all objects/archives have been processed. -- base.pre_link_args.push("-Wl,-(".to_string()); -- base.post_link_args.push("-Wl,-)".to_string()); +- base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,-(".to_string()); +- base.post_link_args.insert(LinkerFlavor::Gcc, vec!["-Wl,-)".to_string()]); - - // When generating a statically linked executable there's generally some - // small setup needed which is listed in these files. These are provided by 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"); diff --git a/community/rust/musl-support-dynamic-linking.patch b/community/rust/musl-support-dynamic-linking.patch index 7c4e93681b..efbbd7f0b0 100644 --- a/community/rust/musl-support-dynamic-linking.patch +++ b/community/rust/musl-support-dynamic-linking.patch @@ -303,10 +303,12 @@ index defbb44448..f10c7d5c83 100644 } { -@@ -718,8 +720,10 @@ fn link_natively(sess: &Session, - objects, out_filename, outputs, trans); +@@ -718,12 +720,14 @@ fn link_natively(sess: &Session, + cmd = linker.finalize(); + } + if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) { + cmd.args(args); } - cmd.args(&sess.target.target.options.late_link_args); - for obj in &sess.target.target.options.post_link_objects { - cmd.arg(root.join(obj)); + if sess.crt_static() { @@ -314,7 +316,9 @@ index defbb44448..f10c7d5c83 100644 + cmd.arg(root.join(obj)); + } } - cmd.args(&sess.target.target.options.post_link_args); + if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) { + cmd.args(args); + } diff --git a/src/libstd/build.rs b/src/libstd/build.rs index 9504194393..dd2008c206 100644 |