diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2021-07-17 17:55:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 17:55:57 +0200 |
| commit | bd2f72f398fa6b609a005cea8ebe16e093937936 (patch) | |
| tree | c57b02417e5dba7b425bdaefc41a96c135ccef0d | |
| parent | 60340d44d84dedd7112d2773bf949b606b40cb4a (diff) | |
| parent | c2a9839686c538eb3cf850bb8947ebfe6f28141d (diff) | |
| download | rust-bd2f72f398fa6b609a005cea8ebe16e093937936.tar.gz rust-bd2f72f398fa6b609a005cea8ebe16e093937936.zip | |
Merge pull request #1187 from bjorn3/feature_gating
Preparations for building as part of rustc
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | build_system/build_backend.rs | 2 | ||||
| -rw-r--r-- | docs/usage.md | 4 | ||||
| -rw-r--r-- | scripts/cargo.rs | 12 | ||||
| -rwxr-xr-x | scripts/filter_profile.rs | 2 | ||||
| -rwxr-xr-x | scripts/tests.sh | 8 | ||||
| -rw-r--r-- | src/lib.rs | 3 |
7 files changed, 23 insertions, 11 deletions
diff --git a/Cargo.toml b/Cargo.toml index 2e34717f419..02098b135f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,8 @@ smallvec = "1.6.1" #gimli = { path = "../" } [features] -default = ["jit", "inline_asm"] +# Enable features not ready to be enabled when compiling as part of rustc +unstable-features = ["jit", "inline_asm"] jit = ["cranelift-jit", "libloading"] inline_asm = [] diff --git a/build_system/build_backend.rs b/build_system/build_backend.rs index 1df2bcc4541..150b6d01a6b 100644 --- a/build_system/build_backend.rs +++ b/build_system/build_backend.rs @@ -4,7 +4,7 @@ use std::process::Command; pub(crate) fn build_backend(channel: &str, host_triple: &str) -> PathBuf { let mut cmd = Command::new("cargo"); - cmd.arg("build").arg("--target").arg(host_triple); + cmd.arg("build").arg("--target").arg(host_triple).arg("--features").arg("unstable-features"); match channel { "debug" => {} 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)) }; |
