Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1a9afa0

Browse files
committed
Misc changes
1 parent b609ca5 commit 1a9afa0

File tree

8 files changed

+39
-59
lines changed

8 files changed

+39
-59
lines changed

config.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ change-id = 115898
626626
# and currently the only standard options supported are `"llvm"`, `"cranelift"`
627627
# and `"gcc"`. The first backend in this list will be used as default by rustc
628628
# when no explicit backend is specified.
629-
#codegen-backends = ["llvm", "cranelift"]
629+
#codegen-backends = ["llvm"]
630630

631631
# Indicates whether LLD will be compiled and made available in the sysroot for
632632
# rustc to execute.

src/bootstrap/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def apply_args(known_args, option_checking, config):
375375
elif option.name == 'target':
376376
set('build.target', value.split(','), config)
377377
elif option.name == 'full-tools':
378-
set('rust.codegen-backends', ['llvm', 'cranelift'], config)
378+
set('rust.codegen-backends', ['llvm'], config)
379379
set('rust.lld', True, config)
380380
set('rust.llvm-tools', True, config)
381381
set('build.extended', True, config)

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,12 +1190,13 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
11901190
impl Step for CodegenBackend {
11911191
type Output = ();
11921192
const ONLY_HOSTS: bool = true;
1193+
// Only the backends specified in the `codegen-backends` entry of `config.toml` are built.
1194+
const DEFAULT: bool = true;
11931195

11941196
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
11951197
run.paths(&["compiler/rustc_codegen_cranelift", "compiler/rustc_codegen_gcc"])
11961198
}
11971199

1198-
// Only the backends specified in the `codegen-backends` entry of `config.toml` are built.
11991200
fn make_run(run: RunConfig<'_>) {
12001201
if needs_codegen_config(&run) {
12011202
return;

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2727
use crate::core::config::TargetSelection;
2828
use crate::utils::cache::{Interned, INTERNER};
2929
use crate::utils::channel;
30-
use crate::utils::helpers::{exe, is_dylib, output, t, timeit};
30+
use crate::utils::helpers::{exe, is_dylib, output, t, target_supports_cranelift_backend, timeit};
3131
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
3232
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
3333

@@ -1304,6 +1304,21 @@ impl Step for CodegenBackend {
13041304
if !builder.build.unstable_features() {
13051305
return None;
13061306
}
1307+
1308+
if self.backend == "cranelift" {
1309+
if !target_supports_cranelift_backend(self.compiler.host) {
1310+
builder.info("target not supported by rustc_codegen_cranelift. skipping");
1311+
return None;
1312+
}
1313+
1314+
if self.compiler.host.contains("windows") {
1315+
builder.info(
1316+
"dist currently disabled for windows by rustc_codegen_cranelift. skipping",
1317+
);
1318+
return None;
1319+
}
1320+
}
1321+
13071322
let compiler = self.compiler;
13081323
let backend = self.backend;
13091324

@@ -1639,7 +1654,6 @@ impl Step for Extended {
16391654

16401655
let prepare = |name: &str| {
16411656
builder.create_dir(&exe.join(name));
1642-
dbg!(name);
16431657
let dir = if name == "rust-std" || name == "rust-analysis" {
16441658
format!("{}-{}", name, target.triple)
16451659
} else if name == "rust-analyzer" {
@@ -1651,29 +1665,12 @@ impl Step for Extended {
16511665
} else if name == "miri" {
16521666
"miri-preview".to_string()
16531667
} else if name == "rustc-codegen-cranelift" {
1654-
"rustc-codegen-cranelift-preview".to_string()
1668+
// FIXME add installer support for cg_clif once it is ready to be distributed on
1669+
// windows.
1670+
unreachable!("cg_clif shouldn't be built for windows");
16551671
} else {
16561672
name.to_string()
16571673
};
1658-
fn visit_dirs(dir: &Path) -> std::io::Result<()> {
1659-
if dir.is_dir() {
1660-
for entry in fs::read_dir(dir)? {
1661-
let entry = entry?;
1662-
let path = entry.path();
1663-
eprintln!("{:?}", path);
1664-
if path.is_dir() {
1665-
if let Err(err) = visit_dirs(&path) {
1666-
dbg!(err);
1667-
}
1668-
}
1669-
}
1670-
}
1671-
Ok(())
1672-
}
1673-
let _ = visit_dirs(
1674-
"\\\\?\\D:\\a\\rust\\rust\\build\\tmp\\tarball\\rust\\x86_64-pc-windows-msvc"
1675-
.as_ref(),
1676-
);
16771674
builder.cp_r(
16781675
&work.join(&format!("{}-{}", pkgname(builder, name), target.triple)).join(dir),
16791676
&exe.join(name),
@@ -1689,7 +1686,6 @@ impl Step for Extended {
16891686
prepare(tool);
16901687
}
16911688
}
1692-
prepare("rustc-codegen-cranelift");
16931689
if target.ends_with("windows-gnu") {
16941690
prepare("rust-mingw");
16951691
}
@@ -1864,23 +1860,6 @@ impl Step for Extended {
18641860
.arg("-t")
18651861
.arg(etc.join("msi/remove-duplicates.xsl")),
18661862
);
1867-
builder.run(
1868-
Command::new(&heat)
1869-
.current_dir(&exe)
1870-
.arg("dir")
1871-
.arg("rustc-codegen-cranelift")
1872-
.args(&heat_flags)
1873-
.arg("-cg")
1874-
.arg("RustcCodegenCraneliftGroup")
1875-
.arg("-dr")
1876-
.arg("RustcCodegenCranelift")
1877-
.arg("-var")
1878-
.arg("var.RustcCodegenCraneliftDir")
1879-
.arg("-out")
1880-
.arg(exe.join("RustcCodegenCraneliftGroup.wxs"))
1881-
.arg("-t")
1882-
.arg(etc.join("msi/remove-duplicates.xsl")),
1883-
);
18841863
if target.ends_with("windows-gnu") {
18851864
builder.run(
18861865
Command::new(&heat)
@@ -1909,7 +1888,6 @@ impl Step for Extended {
19091888
.arg("-dCargoDir=cargo")
19101889
.arg("-dStdDir=rust-std")
19111890
.arg("-dAnalysisDir=rust-analysis")
1912-
.arg("-dRustcCodegenCraneliftDir=rustc-codegen-cranelift")
19131891
.arg("-arch")
19141892
.arg(&arch)
19151893
.arg("-out")
@@ -1955,7 +1933,6 @@ impl Step for Extended {
19551933
if built_tools.contains("rust-demangler") {
19561934
candle("RustDemanglerGroup.wxs".as_ref());
19571935
}
1958-
candle("RustcCodegenCraneliftGroup.wxs".as_ref());
19591936
if built_tools.contains("rust-analyzer") {
19601937
candle("RustAnalyzerGroup.wxs".as_ref());
19611938
}
@@ -1986,7 +1963,6 @@ impl Step for Extended {
19861963
.arg("CargoGroup.wixobj")
19871964
.arg("StdGroup.wixobj")
19881965
.arg("AnalysisGroup.wixobj")
1989-
.arg("RustcCodegenCraneliftGroup.wixobj")
19901966
.current_dir(&exe);
19911967

19921968
if built_tools.contains("clippy") {

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ use crate::core::config::TargetSelection;
2828
use crate::utils;
2929
use crate::utils::cache::{Interned, INTERNER};
3030
use crate::utils::helpers::{
31-
self, add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date,
31+
self, add_link_lib_path, dylib_path, dylib_path_var, output, t,
32+
target_supports_cranelift_backend, up_to_date,
3233
};
3334
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
3435
use crate::{envify, CLang, DocTests, GitRepo, Mode};
@@ -2997,15 +2998,7 @@ impl Step for CodegenCranelift {
29972998
return;
29982999
}
29993000

3000-
let triple = run.target.triple;
3001-
let target_supported = if triple.contains("linux") {
3002-
triple.contains("x86_64") || triple.contains("aarch64") || triple.contains("s390x")
3003-
} else if triple.contains("darwin") || triple.contains("windows") {
3004-
triple.contains("x86_64")
3005-
} else {
3006-
false
3007-
};
3008-
if !target_supported {
3001+
if !target_supports_cranelift_backend(run.target) {
30093002
builder.info("target not supported by rustc_codegen_cranelift. skipping");
30103003
return;
30113004
}

src/bootstrap/src/core/config/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,7 @@ impl Config {
10681068
config.channel = "dev".to_string();
10691069
config.codegen_tests = true;
10701070
config.rust_dist_src = true;
1071-
config.rust_codegen_backends =
1072-
vec![INTERNER.intern_str("llvm"), INTERNER.intern_str("cranelift")];
1071+
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
10731072
config.deny_warnings = true;
10741073
config.bindir = "bin".into();
10751074
config.dist_include_mingw_linker = true;

src/bootstrap/src/utils/helpers.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ pub fn use_host_linker(target: TargetSelection) -> bool {
183183
|| target.contains("switch"))
184184
}
185185

186+
pub fn target_supports_cranelift_backend(target: TargetSelection) -> bool {
187+
if target.contains("linux") {
188+
target.contains("x86_64") || target.contains("aarch64") || target.contains("s390x")
189+
} else if target.contains("darwin") || target.contains("windows") {
190+
target.contains("x86_64")
191+
} else {
192+
false
193+
}
194+
}
195+
186196
pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
187197
path: &'a Path,
188198
suite_path: P,

src/ci/run.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
104104
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
105105
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
106106
fi
107+
108+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift"
107109
else
108110
# We almost always want debug assertions enabled, but sometimes this takes too
109111
# long for too little benefit, so we just turn them off.
@@ -124,7 +126,6 @@ else
124126

125127
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
126128

127-
# Test the Cranelift backend in on CI, but don't ship it.
128129
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=llvm,cranelift"
129130

130131
# We enable this for non-dist builders, since those aren't trying to produce

0 commit comments

Comments
 (0)