Skip to content

Commit bd2f72f

Browse files
authored
Merge pull request rust-lang#1187 from bjorn3/feature_gating
Preparations for building as part of rustc
2 parents 60340d4 + c2a9839 commit bd2f72f

File tree

7 files changed

+23
-11
lines changed

7 files changed

+23
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ smallvec = "1.6.1"
3737
#gimli = { path = "../" }
3838

3939
[features]
40-
default = ["jit", "inline_asm"]
40+
# Enable features not ready to be enabled when compiling as part of rustc
41+
unstable-features = ["jit", "inline_asm"]
4142
jit = ["cranelift-jit", "libloading"]
4243
inline_asm = []
4344

build_system/build_backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::process::Command;
44

55
pub(crate) fn build_backend(channel: &str, host_triple: &str) -> PathBuf {
66
let mut cmd = Command::new("cargo");
7-
cmd.arg("build").arg("--target").arg(host_triple);
7+
cmd.arg("build").arg("--target").arg(host_triple).arg("--features").arg("unstable-features");
88

99
match channel {
1010
"debug" => {}

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $ $cg_clif_dir/build/cargo jit
3636
or
3737

3838
```bash
39-
$ $cg_clif_dir/build/bin/cg_clif -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs
39+
$ $cg_clif_dir/build/bin/cg_clif -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic my_crate.rs
4040
```
4141

4242
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
5252

5353
```bash
5454
function jit_naked() {
55-
echo "$@" | $cg_clif_dir/build/bin/cg_clif - -Cllvm-args=mode=jit -Cprefer-dynamic
55+
echo "$@" | $cg_clif_dir/build/bin/cg_clif - -Zunstable-features -Cllvm-args=mode=jit -Cprefer-dynamic
5656
}
5757

5858
function jit() {

scripts/cargo.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ fn main() {
4444
);
4545
std::array::IntoIter::new(["rustc".to_string()])
4646
.chain(env::args().skip(2))
47-
.chain(["--".to_string(), "-Cllvm-args=mode=jit".to_string()])
47+
.chain([
48+
"--".to_string(),
49+
"-Zunstable-features".to_string(),
50+
"-Cllvm-args=mode=jit".to_string(),
51+
])
4852
.collect()
4953
}
5054
Some("lazy-jit") => {
@@ -54,7 +58,11 @@ fn main() {
5458
);
5559
std::array::IntoIter::new(["rustc".to_string()])
5660
.chain(env::args().skip(2))
57-
.chain(["--".to_string(), "-Cllvm-args=mode=jit-lazy".to_string()])
61+
.chain([
62+
"--".to_string(),
63+
"-Zunstable-features".to_string(),
64+
"-Cllvm-args=mode=jit-lazy".to_string(),
65+
])
5866
.collect()
5967
}
6068
_ => env::args().skip(1).collect(),

scripts/filter_profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pushd $(dirname "$0")/../
55
source scripts/config.sh
66
RUSTC="$(pwd)/build/bin/cg_clif"
77
popd
8-
PROFILE=$1 OUTPUT=$2 exec $RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic $0
8+
PROFILE=$1 OUTPUT=$2 exec $RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic $0
99
#*/
1010

1111
//! This program filters away uninteresting samples and trims uninteresting frames for stackcollapse

scripts/tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ function no_sysroot_tests() {
1616

1717
if [[ "$JIT_SUPPORTED" = "1" ]]; then
1818
echo "[JIT] mini_core_hello_world"
19-
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"
19+
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"
2020

2121
echo "[JIT-lazy] mini_core_hello_world"
22-
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"
22+
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"
2323
else
2424
echo "[JIT] mini_core_hello_world (skipped)"
2525
fi
@@ -44,10 +44,10 @@ function base_sysroot_tests() {
4444

4545
if [[ "$JIT_SUPPORTED" = "1" ]]; then
4646
echo "[JIT] std_example"
47-
$MY_RUSTC -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
47+
$MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
4848

4949
echo "[JIT-lazy] std_example"
50-
$MY_RUSTC -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
50+
$MY_RUSTC -Zunstable-options -Cllvm-args=mode=jit-lazy -Cprefer-dynamic example/std_example.rs --target "$HOST_TRIPLE"
5151
else
5252
echo "[JIT] std_example (skipped)"
5353
fi

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
184184
let config = if let Some(config) = self.config.clone() {
185185
config
186186
} else {
187+
if !tcx.sess.unstable_options() && !tcx.sess.opts.cg.llvm_args.is_empty() {
188+
tcx.sess.fatal("`-Z unstable-options` must be passed to allow configuring cg_clif");
189+
}
187190
BackendConfig::from_opts(&tcx.sess.opts.cg.llvm_args)
188191
.unwrap_or_else(|err| tcx.sess.fatal(&err))
189192
};

0 commit comments

Comments
 (0)