diff options
-rw-r--r-- | testing/rust/APKBUILD | 7 | ||||
-rw-r--r-- | testing/rust/musl-fix-static-linking.patch | 48 | ||||
-rw-r--r-- | testing/rust/static-pie.patch | 31 |
3 files changed, 75 insertions, 11 deletions
diff --git a/testing/rust/APKBUILD b/testing/rust/APKBUILD index abb8f721c4..a8e6c4f2cf 100644 --- a/testing/rust/APKBUILD +++ b/testing/rust/APKBUILD @@ -185,15 +185,14 @@ e9b10d58ae5b51b09dd31a1dbf7367917bd40a05ecb4ba3e0e7ac229a0352d3ceb77de80f7c0120f 54467213b2824112dec6d5a132ab01d69617a5ccaa9db15e5c8fad55dea5eb31b1b7c9ca07878901d75edd45dc84c726913bf651f3435c480a79703c074b5d90 rust-std-1.16.0-x86_64-unknown-linux-musl.tar.gz 4df33353b6be1af822220ca03f9ec5a3b6421c9b10ec17b864be586ba495c6210bac70d904b0e0b35eff62ef2c9a681ded526e5cbd37e326dc3146742aa659de cargo-6e0c18cccc8b0c06fba8a8d76486f81a792fb420-x86_64-unknown-linux-musl.tar.gz b0a8883e4469b60edd150c84486ab950396d757220f97bd271529576614c6c3b49456098507503832c20619d4bd74246dbc99c78116634a68a6df994793e9a94 musl-support-dynamic-linking.patch -7365da739aa03f8b8b3421311b0d4807a2481d38ed259d92f09dd65c831e3e1d25002c012e1c43363fa53462e240b29217e7d429dfa9ae33390e4f7c7cca6227 musl-fix-static-linking.patch +b99b1576016a0173fa0fd83a7711b0cfbe31d18fbbaf7ed79531b706411b675a2689115727f171e72de1367863552e3cdbc1bef7c0d0250505dcce0ba0a973db musl-fix-static-linking.patch f436fddf7ab70ca5f1424081f5b75450270b200b3d997231323863e11addf76e1d65831a7ca09e3a5b7904ce828766c1f70b08326a175890298f28e5bc8646ef musl-fix-linux_musl_base.patch c913d04ef419b2b6d8e453f72894070f263c9292abf97114a51884d475d03ce5b032053f1676ba9364800b4b35e394f707995058530ad5e4122c60f65ddd3db7 musl-fix-jemalloc.patch -636eb3e1646c362851dccc850a13aa0911df74981a324738be32b333dfb8782da4ad98d164a34564d66983effaeb5b0b447057d0c974563110fa29df6384a023 static-pie.patch +5881cb63c77a566aab80428084297fa278c04aeb5fe4e7a3a32655f2b97cdb5b0712fe859662392393dbbb4b2723be543a0207f6b75961a5fb79351c02c107a9 static-pie.patch dc6432293bd060d5e3a73f25870867654fae61995dcd919e244a2dc686b6107556deed8c59ca6002182bfeff5ebc1ca2b89c4028ab0fbfb79e65defe47c9b4b0 llvm-with-ffi.patch 44f3104f506531778fede64034ff5b86f782744d7fed26b393cd88590c22b7fd1df441e2c14bb44c660c54140a4093686aa35f53357f9cd795af6cfa6df1cec4 alpine-musl-dynamic-linking-by-default.patch b00997c65d1a451fafae8b547893c5cbf03f028d2d70f6971aa670f34c2d6fc82728c740ac4a9909fc1999925ff300e4525cfec745cb9c9521e564eb166872a2 alpine-allow-crt-static.patch -2002faf08cca3be702f25618bc17453c5e76644a6ff6b0739b642c2c0f8536ec7f09c98182aff6b2dcc87c77b0929f2f8f732b8242a8f80d94b3824c8cd0d0fe alpine-dont-require-filecheck.patch -19cc2725d68db3e359e0e3016028374e5818a97fdba24d0103f7d1706601c8b17c4dd95a3152e64f982f98e95ad3e949acddbea8a39ed0ba8dd4f702acc2704d alpine-move-py-scripts-to-share.patch +498f4649163974afc4f042c43cd0c15d36784031514201a2962061f288a9336c2bc9749f8d2308b8ce3656f8097b5fc5bef505f61e2a6ed422ef4153f5339d77 alpine-move-py-scripts-to-share.patch 8d6206f8c50856724cf7b4c1854ec82547f040358a1c7d44abeacc27a5c205a963b1fec51e58ec06c68d85bd2f68a9e6e27ebe457f39e8dd043de17758f5063f alpine-change-rpath-to-rustlib.patch f230239d8de1b69536353e5735d3bf32f42a2715aefe4863622d9ab2b25d010209ed0bb38976eaa9302bce2eca6bd162abc8cefd71f689b65b3800920a50967b alpine-force-rpath-on-prefer-dynamic.patch 79549055dea81379c890b495c82456ab497a9179ec6702c59e11d0748bc668f47fc3d6a69c27a0545bb87c01318631dffc69260bf2d4badc75f53cbf7fad7528 check-rustc" diff --git a/testing/rust/musl-fix-static-linking.patch b/testing/rust/musl-fix-static-linking.patch index a0a7c1bc6f..786b7d3a41 100644 --- a/testing/rust/musl-fix-static-linking.patch +++ b/testing/rust/musl-fix-static-linking.patch @@ -1,3 +1,41 @@ +From: Shiz <hi@shiz.me> +Date: Fri, 21 Apr 2017 01:04:46 +0200 +Subject: [PATCH] Support fully static linking on *nix targets + +This patch adds support for full static linking on *nix targets. + +It adds `Session::fully_static()` to determine whether full static linking +should be utilised. By default, this is the case if the target is not +MSVC-like and the `crt-static` target feature is requested, as for *nix +targets this implies a fully static result. In the future, a target feature +or other compile option could perhaps be added to have the invoker decide +this more flexibly at run-time. + +It also adds the proper linker argument for static result objects to `Linker` +and implements them for `GnuLinker` and `MsvcLinker`. Additionally, when +statically linking, all the objects are linked in a group (-Wl,-( and -Wl,-) +on GNU-compatible linkers) to resolve dependency and order issues that may +normally arise. For `MsvcLinker`, this is a no-op as it already exhibits +this behavior by default. + +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/session/mod.rs ++++ b/src/librustc/session/mod.rs +@@ -409,6 +409,11 @@ + return crt_static; + } + ++ pub fn fully_static(&self) -> bool { ++ // TODO: figure out better semantics for this, possibly a target option? ++ return self.crt_static() && !self.target.target.options.is_like_msvc ++ } ++ + pub fn must_not_eliminate_frame_pointers(&self) -> bool { + self.opts.debuginfo != DebugInfoLevel::NoDebugInfo || + !self.target.target.options.eliminate_frame_pointer --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -239,8 +239,8 @@ @@ -6,7 +44,7 @@ crate_type: config::CrateType) -> bool { - match (sess.target.target.options.dynamic_linking, - sess.target.target.options.executables, crate_type) { -+ let dynamic_linking = sess.target.target.options.dynamic_linking && !sess.crt_static(); ++ let dynamic_linking = sess.target.target.options.dynamic_linking && !sess.fully_static(); + match (dynamic_linking, sess.target.target.options.executables, crate_type) { (false, _, config::CrateTypeCdylib) | (false, _, config::CrateTypeProcMacro) | @@ -15,7 +53,7 @@ let used_link_args = sess.cstore.used_link_args(); -+ if crate_type == config::CrateTypeExecutable && sess.crt_static() { ++ if crate_type == config::CrateTypeExecutable && sess.fully_static() { + cmd.static_executable(); + } + @@ -65,15 +103,15 @@ } - cmd.hint_dynamic(); -+ let crt_static = sess.crt_static(); -+ if !crt_static { ++ let fully_static = sess.fully_static(); ++ if !fully_static { + cmd.hint_dynamic(); + } for lib in others { match lib.kind { - NativeLibraryKind::NativeUnknown => cmd.link_dylib(&lib.name.as_str()), -+ NativeLibraryKind::NativeUnknown => if crt_static { cmd.link_staticlib(&lib.name.as_str()) } else { 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::NativeFramework => cmd.link_framework(&lib.name.as_str()), NativeLibraryKind::NativeStatic => bug!(), } diff --git a/testing/rust/static-pie.patch b/testing/rust/static-pie.patch index 90d8496ecd..babfbfaf7f 100644 --- a/testing/rust/static-pie.patch +++ b/testing/rust/static-pie.patch @@ -72,12 +72,39 @@ library, just like static binaries, but more secure. post_link_objects: Vec::new(), --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs -@@ -854,7 +854,7 @@ +@@ -846,15 +846,12 @@ + + if crate_type == config::CrateTypeExecutable && + t.options.position_independent_executables { +- let empty_vec = Vec::new(); + let empty_str = String::new(); +- let args = sess.opts.cg.link_args.as_ref().unwrap_or(&empty_vec); +- let more_args = &sess.opts.cg.link_arg; +- let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter()); let relocation_model = sess.opts.cg.relocation_model.as_ref() .unwrap_or(&empty_str); ++ let static_pie = t.options.static_position_independent_executables; if (t.options.relocation_model == "pic" || *relocation_model == "pic") - && !args.any(|x| *x == "-static") { -+ && (t.options.static_position_independent_executables || !args.any(|x| *x == "-static")) { ++ && (static_pie || !sess.fully_static()) { cmd.position_independent_executable(); } } +--- a/src/librustc_back/target/mod.rs ++++ b/src/librustc_back/target/mod.rs +@@ -612,6 +612,7 @@ + key!(has_rpath, bool); + key!(no_default_libraries, bool); + key!(position_independent_executables, bool); ++ key!(static_position_independent_executables, bool); + key!(archive_format); + key!(allow_asm, bool); + key!(custom_unwind_resume, bool); +@@ -776,6 +777,7 @@ + target_option_val!(has_rpath); + target_option_val!(no_default_libraries); + target_option_val!(position_independent_executables); ++ target_option_val!(static_position_independent_executables); + target_option_val!(archive_format); + target_option_val!(allow_asm); + target_option_val!(custom_unwind_resume); |