Skip to content

Commit 3917644

Browse files
authored
Rollup merge of #109418 - rohaquinlop:108240-rename-native.rs-to-llvm.rs, r=Mark-Simulacrum
Rename 'src/bootstrap/native.rs' to llvm.rs Fixed #108240 Renamed 'native.rs' to 'llvm.rs', also moved `TestHelpers` to `test.rs`. Replaced all the `native.rs` occurrences at `src/bootstrap` files to `llvm.rs`
2 parents 84a7540 + 291ddb8 commit 3917644

File tree

10 files changed

+101
-101
lines changed

10 files changed

+101
-101
lines changed

src/bootstrap/builder.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::config::{SplitDebuginfo, TargetSelection};
1616
use crate::doc;
1717
use crate::flags::{Color, Subcommand};
1818
use crate::install;
19-
use crate::native;
19+
use crate::llvm;
2020
use crate::run;
2121
use crate::setup;
2222
use crate::test;
@@ -636,13 +636,13 @@ impl<'a> Builder<'a> {
636636
tool::Rustdoc,
637637
tool::Clippy,
638638
tool::CargoClippy,
639-
native::Llvm,
640-
native::Sanitizers,
639+
llvm::Llvm,
640+
llvm::Sanitizers,
641641
tool::Rustfmt,
642642
tool::Miri,
643643
tool::CargoMiri,
644-
native::Lld,
645-
native::CrtBeginEnd
644+
llvm::Lld,
645+
llvm::CrtBeginEnd
646646
),
647647
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
648648
check::Std,
@@ -1101,7 +1101,7 @@ impl<'a> Builder<'a> {
11011101
/// check build or dry-run, where there's no need to build all of LLVM.
11021102
fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf> {
11031103
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run() {
1104-
let native::LlvmResult { llvm_config, .. } = self.ensure(native::Llvm { target });
1104+
let llvm::LlvmResult { llvm_config, .. } = self.ensure(llvm::Llvm { target });
11051105
if llvm_config.is_file() {
11061106
return Some(llvm_config);
11071107
}
@@ -1227,7 +1227,7 @@ impl<'a> Builder<'a> {
12271227
// rustc_llvm. But if LLVM is stale, that'll be a tiny amount
12281228
// of work comparatively, and we'd likely need to rebuild it anyway,
12291229
// so that's okay.
1230-
if crate::native::prebuilt_llvm_config(self, target).is_err() {
1230+
if crate::llvm::prebuilt_llvm_config(self, target).is_err() {
12311231
cargo.env("RUST_CHECK", "1");
12321232
}
12331233
}

src/bootstrap/compile.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2424
use crate::cache::{Interned, INTERNER};
2525
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
2626
use crate::dist;
27-
use crate::native;
27+
use crate::llvm;
2828
use crate::tool::SourceType;
2929
use crate::util::get_clang_cl_resource_dir;
3030
use crate::util::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date};
@@ -191,7 +191,7 @@ fn copy_and_stamp(
191191
}
192192

193193
fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &Path) -> PathBuf {
194-
let libunwind_path = builder.ensure(native::Libunwind { target });
194+
let libunwind_path = builder.ensure(llvm::Libunwind { target });
195195
let libunwind_source = libunwind_path.join("libunwind.a");
196196
let libunwind_target = libdir.join("libunwind.a");
197197
builder.copy(&libunwind_source, &libunwind_target);
@@ -266,7 +266,7 @@ fn copy_self_contained_objects(
266266
DependencyType::TargetSelfContained,
267267
);
268268
}
269-
let crt_path = builder.ensure(native::CrtBeginEnd { target });
269+
let crt_path = builder.ensure(llvm::CrtBeginEnd { target });
270270
for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] {
271271
let src = crt_path.join(obj);
272272
let target = libdir_self_contained.join(obj);
@@ -474,7 +474,7 @@ fn copy_sanitizers(
474474
compiler: &Compiler,
475475
target: TargetSelection,
476476
) -> Vec<PathBuf> {
477-
let runtimes: Vec<native::SanitizerRuntime> = builder.ensure(native::Sanitizers { target });
477+
let runtimes: Vec<llvm::SanitizerRuntime> = builder.ensure(llvm::Sanitizers { target });
478478

479479
if builder.config.dry_run() {
480480
return Vec::new();
@@ -876,12 +876,12 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
876876
// busting caches (e.g. like #71152).
877877
if builder.config.llvm_enabled()
878878
&& (builder.kind != Kind::Check
879-
|| crate::native::prebuilt_llvm_config(builder, target).is_ok())
879+
|| crate::llvm::prebuilt_llvm_config(builder, target).is_ok())
880880
{
881881
if builder.is_rust_llvm(target) {
882882
cargo.env("LLVM_RUSTLLVM", "1");
883883
}
884-
let native::LlvmResult { llvm_config, .. } = builder.ensure(native::Llvm { target });
884+
let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target });
885885
cargo.env("LLVM_CONFIG", &llvm_config);
886886
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
887887
cargo.env("CFG_LLVM_ROOT", s);
@@ -1359,7 +1359,7 @@ impl Step for Assemble {
13591359
}
13601360

13611361
let lld_install = if builder.config.lld_enabled {
1362-
Some(builder.ensure(native::Lld { target: target_compiler.host }))
1362+
Some(builder.ensure(llvm::Lld { target: target_compiler.host }))
13631363
} else {
13641364
None
13651365
};
@@ -1423,8 +1423,8 @@ impl Step for Assemble {
14231423
}
14241424

14251425
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
1426-
let native::LlvmResult { llvm_config, .. } =
1427-
builder.ensure(native::Llvm { target: target_compiler.host });
1426+
let llvm::LlvmResult { llvm_config, .. } =
1427+
builder.ensure(llvm::Llvm { target: target_compiler.host });
14281428
if !builder.config.dry_run() {
14291429
let llvm_bin_dir = output(Command::new(llvm_config).arg("--bindir"));
14301430
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());

src/bootstrap/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1207,11 +1207,11 @@ impl Config {
12071207
config.llvm_from_ci = match llvm.download_ci_llvm {
12081208
Some(StringOrBool::String(s)) => {
12091209
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
1210-
crate::native::is_ci_llvm_available(&config, asserts)
1210+
crate::llvm::is_ci_llvm_available(&config, asserts)
12111211
}
12121212
Some(StringOrBool::Bool(b)) => b,
12131213
None => {
1214-
config.channel == "dev" && crate::native::is_ci_llvm_available(&config, asserts)
1214+
config.channel == "dev" && crate::llvm::is_ci_llvm_available(&config, asserts)
12151215
}
12161216
};
12171217

@@ -1254,7 +1254,7 @@ impl Config {
12541254
}
12551255
} else {
12561256
config.llvm_from_ci =
1257-
config.channel == "dev" && crate::native::is_ci_llvm_available(&config, false);
1257+
config.channel == "dev" && crate::llvm::is_ci_llvm_available(&config, false);
12581258
}
12591259

12601260
if let Some(t) = toml.target {

src/bootstrap/config/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn parse(config: &str) -> Config {
1111

1212
#[test]
1313
fn download_ci_llvm() {
14-
if crate::native::is_ci_llvm_modified(&parse("")) {
14+
if crate::llvm::is_ci_llvm_modified(&parse("")) {
1515
eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change");
1616
return;
1717
}

src/bootstrap/dist.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::channel;
2727
use crate::compile;
2828
use crate::config::TargetSelection;
2929
use crate::doc::DocumentationFormat;
30-
use crate::native;
30+
use crate::llvm;
3131
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
3232
use crate::tool::{self, Tool};
3333
use crate::util::{exe, is_dylib, output, t, timeit};
@@ -1965,8 +1965,8 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
19651965
builder.install(&llvm_dylib_path, dst_libdir, 0o644);
19661966
}
19671967
!builder.config.dry_run()
1968-
} else if let Ok(native::LlvmResult { llvm_config, .. }) =
1969-
native::prebuilt_llvm_config(builder, target)
1968+
} else if let Ok(llvm::LlvmResult { llvm_config, .. }) =
1969+
llvm::prebuilt_llvm_config(builder, target)
19701970
{
19711971
let mut cmd = Command::new(llvm_config);
19721972
cmd.arg("--libfiles");
@@ -2154,7 +2154,7 @@ impl Step for LlvmTools {
21542154
}
21552155
}
21562156

2157-
builder.ensure(crate::native::Llvm { target });
2157+
builder.ensure(crate::llvm::Llvm { target });
21582158

21592159
let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
21602160
tarball.set_overlay(OverlayKind::LLVM);
@@ -2213,10 +2213,10 @@ impl Step for RustDev {
22132213
let mut tarball = Tarball::new(builder, "rust-dev", &target.triple);
22142214
tarball.set_overlay(OverlayKind::LLVM);
22152215

2216-
builder.ensure(crate::native::Llvm { target });
2216+
builder.ensure(crate::llvm::Llvm { target });
22172217

22182218
// We want to package `lld` to use it with `download-ci-llvm`.
2219-
builder.ensure(crate::native::Lld { target });
2219+
builder.ensure(crate::llvm::Lld { target });
22202220

22212221
let src_bindir = builder.llvm_out(target).join("bin");
22222222
// If updating this list, you likely want to change

src/bootstrap/download.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use xz2::bufread::XzDecoder;
1212

1313
use crate::{
1414
config::RustfmtMetadata,
15-
native::detect_llvm_sha,
15+
llvm::detect_llvm_sha,
1616
t,
1717
util::{check_run, exe, program_out_of_date, try_run},
1818
Config,

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ mod download;
5353
mod flags;
5454
mod format;
5555
mod install;
56+
mod llvm;
5657
mod metadata;
57-
mod native;
5858
mod render_tests;
5959
mod run;
6060
mod sanity;

src/bootstrap/native.rs renamed to src/bootstrap/llvm.rs

-65
Original file line numberDiff line numberDiff line change
@@ -869,71 +869,6 @@ impl Step for Lld {
869869
}
870870
}
871871

872-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
873-
pub struct TestHelpers {
874-
pub target: TargetSelection,
875-
}
876-
877-
impl Step for TestHelpers {
878-
type Output = ();
879-
880-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
881-
run.path("tests/auxiliary/rust_test_helpers.c")
882-
}
883-
884-
fn make_run(run: RunConfig<'_>) {
885-
run.builder.ensure(TestHelpers { target: run.target })
886-
}
887-
888-
/// Compiles the `rust_test_helpers.c` library which we used in various
889-
/// `run-pass` tests for ABI testing.
890-
fn run(self, builder: &Builder<'_>) {
891-
if builder.config.dry_run() {
892-
return;
893-
}
894-
// The x86_64-fortanix-unknown-sgx target doesn't have a working C
895-
// toolchain. However, some x86_64 ELF objects can be linked
896-
// without issues. Use this hack to compile the test helpers.
897-
let target = if self.target == "x86_64-fortanix-unknown-sgx" {
898-
TargetSelection::from_user("x86_64-unknown-linux-gnu")
899-
} else {
900-
self.target
901-
};
902-
let dst = builder.test_helpers_out(target);
903-
let src = builder.src.join("tests/auxiliary/rust_test_helpers.c");
904-
if up_to_date(&src, &dst.join("librust_test_helpers.a")) {
905-
return;
906-
}
907-
908-
builder.info("Building test helpers");
909-
t!(fs::create_dir_all(&dst));
910-
let mut cfg = cc::Build::new();
911-
// FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
912-
if target.contains("emscripten") {
913-
cfg.pic(false);
914-
}
915-
916-
// We may have found various cross-compilers a little differently due to our
917-
// extra configuration, so inform cc of these compilers. Note, though, that
918-
// on MSVC we still need cc's detection of env vars (ugh).
919-
if !target.contains("msvc") {
920-
if let Some(ar) = builder.ar(target) {
921-
cfg.archiver(ar);
922-
}
923-
cfg.compiler(builder.cc(target));
924-
}
925-
cfg.cargo_metadata(false)
926-
.out_dir(&dst)
927-
.target(&target.triple)
928-
.host(&builder.config.build.triple)
929-
.opt_level(0)
930-
.warnings(false)
931-
.debug(false)
932-
.file(builder.src.join("tests/auxiliary/rust_test_helpers.c"))
933-
.compile("rust_test_helpers");
934-
}
935-
}
936-
937872
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
938873
pub struct Sanitizers {
939874
pub target: TargetSelection,

src/bootstrap/test.rs

+72-7
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ use crate::config::TargetSelection;
1919
use crate::dist;
2020
use crate::doc::DocumentationFormat;
2121
use crate::flags::Subcommand;
22-
use crate::native;
22+
use crate::llvm;
2323
use crate::render_tests::add_flags_and_try_run_tests;
2424
use crate::tool::{self, SourceType, Tool};
2525
use crate::toolstate::ToolState;
26-
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
26+
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date};
2727
use crate::{envify, CLang, DocTests, GitRepo, Mode};
2828

2929
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
@@ -1434,11 +1434,11 @@ note: if you're sure you want to do this, please open an issue as to why. In the
14341434
builder.ensure(compile::Std::new(compiler, compiler.host));
14351435

14361436
// Also provide `rust_test_helpers` for the host.
1437-
builder.ensure(native::TestHelpers { target: compiler.host });
1437+
builder.ensure(TestHelpers { target: compiler.host });
14381438

14391439
// As well as the target, except for plain wasm32, which can't build it
14401440
if !target.contains("wasm") || target.contains("emscripten") {
1441-
builder.ensure(native::TestHelpers { target });
1441+
builder.ensure(TestHelpers { target });
14421442
}
14431443

14441444
builder.ensure(RemoteCopyLibs { compiler, target });
@@ -1625,8 +1625,8 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16251625
let mut llvm_components_passed = false;
16261626
let mut copts_passed = false;
16271627
if builder.config.llvm_enabled() {
1628-
let native::LlvmResult { llvm_config, .. } =
1629-
builder.ensure(native::Llvm { target: builder.config.build });
1628+
let llvm::LlvmResult { llvm_config, .. } =
1629+
builder.ensure(llvm::Llvm { target: builder.config.build });
16301630
if !builder.config.dry_run() {
16311631
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
16321632
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
@@ -1664,7 +1664,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16641664
// If LLD is available, add it to the PATH
16651665
if builder.config.lld_enabled {
16661666
let lld_install_root =
1667-
builder.ensure(native::Lld { target: builder.config.build });
1667+
builder.ensure(llvm::Lld { target: builder.config.build });
16681668

16691669
let lld_bin_path = lld_install_root.join("bin");
16701670

@@ -2747,3 +2747,68 @@ impl Step for RustInstaller {
27472747
run.builder.ensure(Self);
27482748
}
27492749
}
2750+
2751+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
2752+
pub struct TestHelpers {
2753+
pub target: TargetSelection,
2754+
}
2755+
2756+
impl Step for TestHelpers {
2757+
type Output = ();
2758+
2759+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2760+
run.path("tests/auxiliary/rust_test_helpers.c")
2761+
}
2762+
2763+
fn make_run(run: RunConfig<'_>) {
2764+
run.builder.ensure(TestHelpers { target: run.target })
2765+
}
2766+
2767+
/// Compiles the `rust_test_helpers.c` library which we used in various
2768+
/// `run-pass` tests for ABI testing.
2769+
fn run(self, builder: &Builder<'_>) {
2770+
if builder.config.dry_run() {
2771+
return;
2772+
}
2773+
// The x86_64-fortanix-unknown-sgx target doesn't have a working C
2774+
// toolchain. However, some x86_64 ELF objects can be linked
2775+
// without issues. Use this hack to compile the test helpers.
2776+
let target = if self.target == "x86_64-fortanix-unknown-sgx" {
2777+
TargetSelection::from_user("x86_64-unknown-linux-gnu")
2778+
} else {
2779+
self.target
2780+
};
2781+
let dst = builder.test_helpers_out(target);
2782+
let src = builder.src.join("tests/auxiliary/rust_test_helpers.c");
2783+
if up_to_date(&src, &dst.join("librust_test_helpers.a")) {
2784+
return;
2785+
}
2786+
2787+
builder.info("Building test helpers");
2788+
t!(fs::create_dir_all(&dst));
2789+
let mut cfg = cc::Build::new();
2790+
// FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
2791+
if target.contains("emscripten") {
2792+
cfg.pic(false);
2793+
}
2794+
2795+
// We may have found various cross-compilers a little differently due to our
2796+
// extra configuration, so inform cc of these compilers. Note, though, that
2797+
// on MSVC we still need cc's detection of env vars (ugh).
2798+
if !target.contains("msvc") {
2799+
if let Some(ar) = builder.ar(target) {
2800+
cfg.archiver(ar);
2801+
}
2802+
cfg.compiler(builder.cc(target));
2803+
}
2804+
cfg.cargo_metadata(false)
2805+
.out_dir(&dst)
2806+
.target(&target.triple)
2807+
.host(&builder.config.build.triple)
2808+
.opt_level(0)
2809+
.warnings(false)
2810+
.debug(false)
2811+
.file(builder.src.join("tests/auxiliary/rust_test_helpers.c"))
2812+
.compile("rust_test_helpers");
2813+
}
2814+
}

0 commit comments

Comments
 (0)