about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-07-17 16:32:55 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2021-07-17 16:32:55 +0200
commit80b9e36709019f98f6bdc33e632641861e470128 (patch)
treeedd315b6c78fbd499203c5e04c34aedabb4216ef
parent60340d44d84dedd7112d2773bf949b606b40cb4a (diff)
downloadrust-80b9e36709019f98f6bdc33e632641861e470128.tar.gz
rust-80b9e36709019f98f6bdc33e632641861e470128.zip
Put all cg_clif specific options behind -Zunstable-features
-rw-r--r--docs/usage.md4
-rw-r--r--scripts/cargo.rs12
-rwxr-xr-xscripts/filter_profile.rs2
-rwxr-xr-xscripts/tests.sh8
-rw-r--r--src/lib.rs3
5 files changed, 20 insertions, 9 deletions
diff --git a/docs/usage.md b/docs/usage.md
index 956d5905a97..87eec0e818b 100644
--- a/docs/usage.md
+++ b/docs/usage.md
@@ -36,7 +36,7 @@ $ $cg_clif_dir/build/cargo jit
 or
 
 ```bash
-$ $cg_clif_dir/build/bin/cg_clif -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs
+$ $cg_clif_dir/build/bin/cg_clif -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs
 ```
 
 There is also an experimental lazy jit mode. In this mode functions are only compiled once they are
@@ -52,7 +52,7 @@ These are a few functions that allow you to easily run rust code from the shell
 
 ```bash
 function jit_naked() {
-    echo "$@" | $cg_clif_dir/build/bin/cg_clif - -Cllvm-args=mode=jit -Cprefer-dynamic
+    echo "$@" | $cg_clif_dir/build/bin/cg_clif - -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic
 }
 
 function jit() {
diff --git a/scripts/cargo.rs b/scripts/cargo.rs
index b7e8dd44974..89ec8da77d3 100644
--- a/scripts/cargo.rs
+++ b/scripts/cargo.rs
@@ -44,7 +44,11 @@ fn main() {
             );
             std::array::IntoIter::new(["rustc".to_string()])
                 .chain(env::args().skip(2))
-                .chain(["--".to_string(), "-Cllvm-args=mode=jit".to_string()])
+                .chain([
+                    "--".to_string(),
+                    "-Zunstable-features".to_string(),
+                    "-Cllvm-args=mode=jit".to_string(),
+                ])
                 .collect()
         }
         Some("lazy-jit") => {
@@ -54,7 +58,11 @@ fn main() {
             );
             std::array::IntoIter::new(["rustc".to_string()])
                 .chain(env::args().skip(2))
-                .chain(["--".to_string(), "-Cllvm-args=mode=jit-lazy".to_string()])
+                .chain([
+                    "--".to_string(),
+                    "-Zunstable-features".to_string(),
+                    "-Cllvm-args=mode=jit-lazy".to_string(),
+                ])
                 .collect()
         }
         _ => env::args().skip(1).collect(),
diff --git a/scripts/filter_profile.rs b/scripts/filter_profile.rs
index 9e196afbe4f..c4801a0a87b 100755
--- a/scripts/filter_profile.rs
+++ b/scripts/filter_profile.rs
@@ -5,7 +5,7 @@ pushd $(dirname "$0")/../
 source scripts/config.sh
 RUSTC="$(pwd)/build/bin/cg_clif"
 popd
-PROFILE=$1 OUTPUT=$2 exec $RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic $0
+PROFILE=$1 OUTPUT=$2 exec $RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic $0
 #*/
 
 //! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse
diff --git a/scripts/tests.sh b/scripts/tests.sh
index 5df04c533a7..08c07dfad42 100755
--- a/scripts/tests.sh
+++ b/scripts/tests.sh
@@ -16,10 +16,10 @@ function no_sysroot_tests() {
 
     if [[ "$JIT_SUPPORTED" = "1" ]]; then
         echo "[JIT] mini_core_hello_world"
-        CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
+        CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
 
         echo "[JIT-lazy] mini_core_hello_world"
-        CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
+        CG_CLIF_JIT_ARGS="abc bcd" $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/mini_core_hello_world.rs --cfg jit --target "$HOST_TRIPLE"
     else
         echo "[JIT] mini_core_hello_world (skipped)"
     fi
@@ -44,10 +44,10 @@ function base_sysroot_tests() {
 
     if [[ "$JIT_SUPPORTED" = "1" ]]; then
         echo "[JIT] std_example"
-        $MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
+        $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
 
         echo "[JIT-lazy] std_example"
-        $MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
+        $MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
     else
         echo "[JIT] std_example (skipped)"
     fi
diff --git a/src/lib.rs b/src/lib.rs
index c7b3ad96048..366b9a7e24c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -184,6 +184,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
         let config = if let Some(config) = self.config.clone() {
             config
         } else {
+            if !tcx.sess.unstable_options() && !tcx.sess.opts.cg.llvm_args.is_empty() {
+                tcx.sess.fatal("`-Z unstable-options` must be passed to allow configuring cg_clif");
+            }
             BackendConfig::from_opts(&tcx.sess.opts.cg.llvm_args)
                 .unwrap_or_else(|err| tcx.sess.fatal(&err))
         };