aboutsummaryrefslogtreecommitdiffstats
path: root/testing/rust/allow-crt-static-on-stable.patch
blob: df4c06bf7934f26df3e715e4023c6ad34e7a80a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 08 Aug 2016 14:49:00 +0200
Subject: [PATCH] Allow to use -C target-feature=+crt-static on stable rustc

Rust links system libraries statically on musl by default, but we want to
link dynamically. At the same time we would like to preserve this behaviour
for consistency with other distros, to not confuse users.

rustc already provides codegen option to change linking, but currently it's
allowed only for nightly builds. This patch just removes this check and so
allows to use it even on stable build.

Build dynamically linked binary with rustc or cargo:

    $ rustc -C target-feature=-crt-static hello_world.rs
    $ RUSTFLAGS="-C target-feature=-crt-static" cargo build

--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -401,9 +401,9 @@
         // If we switched from the default then that's only allowed on nightly, so
         // gate that here.
         if (found_positive || found_negative) && (!is_nightly || !unstable_options) {
-            self.fatal("specifying the `crt-static` target feature is only allowed \
-                on the nightly channel with `-Z unstable-options` passed \
-                as well");
+            //self.fatal("specifying the `crt-static` target feature is only allowed \
+            //    on the nightly channel with `-Z unstable-options` passed \
+            //    as well");
         }
 
         return crt_static;
--- a/src/test/compile-fail/crt-static-gated.rs
+++ b/src/test/compile-fail/crt-static-gated.rs
@@ -10,5 +10,6 @@
 
 // compile-flags:-C target-feature=+crt-static
 // error-pattern: specifying the `crt-static` target feature is only allowed
+// ignore-test we just want this feature and no one will stop us!
 
 fn main() {}