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`
This commit is contained in:
commit
3917644b0e
@ -16,7 +16,7 @@ use crate::config::{SplitDebuginfo, TargetSelection};
|
||||
use crate::doc;
|
||||
use crate::flags::{Color, Subcommand};
|
||||
use crate::install;
|
||||
use crate::native;
|
||||
use crate::llvm;
|
||||
use crate::run;
|
||||
use crate::setup;
|
||||
use crate::test;
|
||||
@ -636,13 +636,13 @@ impl<'a> Builder<'a> {
|
||||
tool::Rustdoc,
|
||||
tool::Clippy,
|
||||
tool::CargoClippy,
|
||||
native::Llvm,
|
||||
native::Sanitizers,
|
||||
llvm::Llvm,
|
||||
llvm::Sanitizers,
|
||||
tool::Rustfmt,
|
||||
tool::Miri,
|
||||
tool::CargoMiri,
|
||||
native::Lld,
|
||||
native::CrtBeginEnd
|
||||
llvm::Lld,
|
||||
llvm::CrtBeginEnd
|
||||
),
|
||||
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
|
||||
check::Std,
|
||||
@ -1101,7 +1101,7 @@ impl<'a> Builder<'a> {
|
||||
/// check build or dry-run, where there's no need to build all of LLVM.
|
||||
fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf> {
|
||||
if self.config.llvm_enabled() && self.kind != Kind::Check && !self.config.dry_run() {
|
||||
let native::LlvmResult { llvm_config, .. } = self.ensure(native::Llvm { target });
|
||||
let llvm::LlvmResult { llvm_config, .. } = self.ensure(llvm::Llvm { target });
|
||||
if llvm_config.is_file() {
|
||||
return Some(llvm_config);
|
||||
}
|
||||
@ -1227,7 +1227,7 @@ impl<'a> Builder<'a> {
|
||||
// rustc_llvm. But if LLVM is stale, that'll be a tiny amount
|
||||
// of work comparatively, and we'd likely need to rebuild it anyway,
|
||||
// so that's okay.
|
||||
if crate::native::prebuilt_llvm_config(self, target).is_err() {
|
||||
if crate::llvm::prebuilt_llvm_config(self, target).is_err() {
|
||||
cargo.env("RUST_CHECK", "1");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
|
||||
use crate::cache::{Interned, INTERNER};
|
||||
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
|
||||
use crate::dist;
|
||||
use crate::native;
|
||||
use crate::llvm;
|
||||
use crate::tool::SourceType;
|
||||
use crate::util::get_clang_cl_resource_dir;
|
||||
use crate::util::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date};
|
||||
@ -191,7 +191,7 @@ fn copy_and_stamp(
|
||||
}
|
||||
|
||||
fn copy_llvm_libunwind(builder: &Builder<'_>, target: TargetSelection, libdir: &Path) -> PathBuf {
|
||||
let libunwind_path = builder.ensure(native::Libunwind { target });
|
||||
let libunwind_path = builder.ensure(llvm::Libunwind { target });
|
||||
let libunwind_source = libunwind_path.join("libunwind.a");
|
||||
let libunwind_target = libdir.join("libunwind.a");
|
||||
builder.copy(&libunwind_source, &libunwind_target);
|
||||
@ -266,7 +266,7 @@ fn copy_self_contained_objects(
|
||||
DependencyType::TargetSelfContained,
|
||||
);
|
||||
}
|
||||
let crt_path = builder.ensure(native::CrtBeginEnd { target });
|
||||
let crt_path = builder.ensure(llvm::CrtBeginEnd { target });
|
||||
for &obj in &["crtbegin.o", "crtbeginS.o", "crtend.o", "crtendS.o"] {
|
||||
let src = crt_path.join(obj);
|
||||
let target = libdir_self_contained.join(obj);
|
||||
@ -474,7 +474,7 @@ fn copy_sanitizers(
|
||||
compiler: &Compiler,
|
||||
target: TargetSelection,
|
||||
) -> Vec<PathBuf> {
|
||||
let runtimes: Vec<native::SanitizerRuntime> = builder.ensure(native::Sanitizers { target });
|
||||
let runtimes: Vec<llvm::SanitizerRuntime> = builder.ensure(llvm::Sanitizers { target });
|
||||
|
||||
if builder.config.dry_run() {
|
||||
return Vec::new();
|
||||
@ -876,12 +876,12 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
|
||||
// busting caches (e.g. like #71152).
|
||||
if builder.config.llvm_enabled()
|
||||
&& (builder.kind != Kind::Check
|
||||
|| crate::native::prebuilt_llvm_config(builder, target).is_ok())
|
||||
|| crate::llvm::prebuilt_llvm_config(builder, target).is_ok())
|
||||
{
|
||||
if builder.is_rust_llvm(target) {
|
||||
cargo.env("LLVM_RUSTLLVM", "1");
|
||||
}
|
||||
let native::LlvmResult { llvm_config, .. } = builder.ensure(native::Llvm { target });
|
||||
let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target });
|
||||
cargo.env("LLVM_CONFIG", &llvm_config);
|
||||
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
|
||||
cargo.env("CFG_LLVM_ROOT", s);
|
||||
@ -1359,7 +1359,7 @@ impl Step for Assemble {
|
||||
}
|
||||
|
||||
let lld_install = if builder.config.lld_enabled {
|
||||
Some(builder.ensure(native::Lld { target: target_compiler.host }))
|
||||
Some(builder.ensure(llvm::Lld { target: target_compiler.host }))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -1423,8 +1423,8 @@ impl Step for Assemble {
|
||||
}
|
||||
|
||||
if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) {
|
||||
let native::LlvmResult { llvm_config, .. } =
|
||||
builder.ensure(native::Llvm { target: target_compiler.host });
|
||||
let llvm::LlvmResult { llvm_config, .. } =
|
||||
builder.ensure(llvm::Llvm { target: target_compiler.host });
|
||||
if !builder.config.dry_run() {
|
||||
let llvm_bin_dir = output(Command::new(llvm_config).arg("--bindir"));
|
||||
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
|
||||
|
@ -1207,11 +1207,11 @@ impl Config {
|
||||
config.llvm_from_ci = match llvm.download_ci_llvm {
|
||||
Some(StringOrBool::String(s)) => {
|
||||
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
|
||||
crate::native::is_ci_llvm_available(&config, asserts)
|
||||
crate::llvm::is_ci_llvm_available(&config, asserts)
|
||||
}
|
||||
Some(StringOrBool::Bool(b)) => b,
|
||||
None => {
|
||||
config.channel == "dev" && crate::native::is_ci_llvm_available(&config, asserts)
|
||||
config.channel == "dev" && crate::llvm::is_ci_llvm_available(&config, asserts)
|
||||
}
|
||||
};
|
||||
|
||||
@ -1254,7 +1254,7 @@ impl Config {
|
||||
}
|
||||
} else {
|
||||
config.llvm_from_ci =
|
||||
config.channel == "dev" && crate::native::is_ci_llvm_available(&config, false);
|
||||
config.channel == "dev" && crate::llvm::is_ci_llvm_available(&config, false);
|
||||
}
|
||||
|
||||
if let Some(t) = toml.target {
|
||||
|
@ -11,7 +11,7 @@ fn parse(config: &str) -> Config {
|
||||
|
||||
#[test]
|
||||
fn download_ci_llvm() {
|
||||
if crate::native::is_ci_llvm_modified(&parse("")) {
|
||||
if crate::llvm::is_ci_llvm_modified(&parse("")) {
|
||||
eprintln!("Detected LLVM as non-available: running in CI and modified LLVM in this change");
|
||||
return;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use crate::channel;
|
||||
use crate::compile;
|
||||
use crate::config::TargetSelection;
|
||||
use crate::doc::DocumentationFormat;
|
||||
use crate::native;
|
||||
use crate::llvm;
|
||||
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
|
||||
use crate::tool::{self, Tool};
|
||||
use crate::util::{exe, is_dylib, output, t, timeit};
|
||||
@ -1965,8 +1965,8 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
|
||||
builder.install(&llvm_dylib_path, dst_libdir, 0o644);
|
||||
}
|
||||
!builder.config.dry_run()
|
||||
} else if let Ok(native::LlvmResult { llvm_config, .. }) =
|
||||
native::prebuilt_llvm_config(builder, target)
|
||||
} else if let Ok(llvm::LlvmResult { llvm_config, .. }) =
|
||||
llvm::prebuilt_llvm_config(builder, target)
|
||||
{
|
||||
let mut cmd = Command::new(llvm_config);
|
||||
cmd.arg("--libfiles");
|
||||
@ -2154,7 +2154,7 @@ impl Step for LlvmTools {
|
||||
}
|
||||
}
|
||||
|
||||
builder.ensure(crate::native::Llvm { target });
|
||||
builder.ensure(crate::llvm::Llvm { target });
|
||||
|
||||
let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
|
||||
tarball.set_overlay(OverlayKind::LLVM);
|
||||
@ -2213,10 +2213,10 @@ impl Step for RustDev {
|
||||
let mut tarball = Tarball::new(builder, "rust-dev", &target.triple);
|
||||
tarball.set_overlay(OverlayKind::LLVM);
|
||||
|
||||
builder.ensure(crate::native::Llvm { target });
|
||||
builder.ensure(crate::llvm::Llvm { target });
|
||||
|
||||
// We want to package `lld` to use it with `download-ci-llvm`.
|
||||
builder.ensure(crate::native::Lld { target });
|
||||
builder.ensure(crate::llvm::Lld { target });
|
||||
|
||||
let src_bindir = builder.llvm_out(target).join("bin");
|
||||
// If updating this list, you likely want to change
|
||||
|
@ -12,7 +12,7 @@ use xz2::bufread::XzDecoder;
|
||||
|
||||
use crate::{
|
||||
config::RustfmtMetadata,
|
||||
native::detect_llvm_sha,
|
||||
llvm::detect_llvm_sha,
|
||||
t,
|
||||
util::{check_run, exe, program_out_of_date, try_run},
|
||||
Config,
|
||||
|
@ -53,8 +53,8 @@ mod download;
|
||||
mod flags;
|
||||
mod format;
|
||||
mod install;
|
||||
mod llvm;
|
||||
mod metadata;
|
||||
mod native;
|
||||
mod render_tests;
|
||||
mod run;
|
||||
mod sanity;
|
||||
|
@ -869,71 +869,6 @@ impl Step for Lld {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TestHelpers {
|
||||
pub target: TargetSelection,
|
||||
}
|
||||
|
||||
impl Step for TestHelpers {
|
||||
type Output = ();
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.path("tests/auxiliary/rust_test_helpers.c")
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(TestHelpers { target: run.target })
|
||||
}
|
||||
|
||||
/// Compiles the `rust_test_helpers.c` library which we used in various
|
||||
/// `run-pass` tests for ABI testing.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
if builder.config.dry_run() {
|
||||
return;
|
||||
}
|
||||
// The x86_64-fortanix-unknown-sgx target doesn't have a working C
|
||||
// toolchain. However, some x86_64 ELF objects can be linked
|
||||
// without issues. Use this hack to compile the test helpers.
|
||||
let target = if self.target == "x86_64-fortanix-unknown-sgx" {
|
||||
TargetSelection::from_user("x86_64-unknown-linux-gnu")
|
||||
} else {
|
||||
self.target
|
||||
};
|
||||
let dst = builder.test_helpers_out(target);
|
||||
let src = builder.src.join("tests/auxiliary/rust_test_helpers.c");
|
||||
if up_to_date(&src, &dst.join("librust_test_helpers.a")) {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.info("Building test helpers");
|
||||
t!(fs::create_dir_all(&dst));
|
||||
let mut cfg = cc::Build::new();
|
||||
// FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
|
||||
if target.contains("emscripten") {
|
||||
cfg.pic(false);
|
||||
}
|
||||
|
||||
// We may have found various cross-compilers a little differently due to our
|
||||
// extra configuration, so inform cc of these compilers. Note, though, that
|
||||
// on MSVC we still need cc's detection of env vars (ugh).
|
||||
if !target.contains("msvc") {
|
||||
if let Some(ar) = builder.ar(target) {
|
||||
cfg.archiver(ar);
|
||||
}
|
||||
cfg.compiler(builder.cc(target));
|
||||
}
|
||||
cfg.cargo_metadata(false)
|
||||
.out_dir(&dst)
|
||||
.target(&target.triple)
|
||||
.host(&builder.config.build.triple)
|
||||
.opt_level(0)
|
||||
.warnings(false)
|
||||
.debug(false)
|
||||
.file(builder.src.join("tests/auxiliary/rust_test_helpers.c"))
|
||||
.compile("rust_test_helpers");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Sanitizers {
|
||||
pub target: TargetSelection,
|
@ -19,11 +19,11 @@ use crate::config::TargetSelection;
|
||||
use crate::dist;
|
||||
use crate::doc::DocumentationFormat;
|
||||
use crate::flags::Subcommand;
|
||||
use crate::native;
|
||||
use crate::llvm;
|
||||
use crate::render_tests::add_flags_and_try_run_tests;
|
||||
use crate::tool::{self, SourceType, Tool};
|
||||
use crate::toolstate::ToolState;
|
||||
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t};
|
||||
use crate::util::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date};
|
||||
use crate::{envify, CLang, DocTests, GitRepo, Mode};
|
||||
|
||||
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
|
||||
builder.ensure(compile::Std::new(compiler, compiler.host));
|
||||
|
||||
// Also provide `rust_test_helpers` for the host.
|
||||
builder.ensure(native::TestHelpers { target: compiler.host });
|
||||
builder.ensure(TestHelpers { target: compiler.host });
|
||||
|
||||
// As well as the target, except for plain wasm32, which can't build it
|
||||
if !target.contains("wasm") || target.contains("emscripten") {
|
||||
builder.ensure(native::TestHelpers { target });
|
||||
builder.ensure(TestHelpers { target });
|
||||
}
|
||||
|
||||
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
|
||||
let mut llvm_components_passed = false;
|
||||
let mut copts_passed = false;
|
||||
if builder.config.llvm_enabled() {
|
||||
let native::LlvmResult { llvm_config, .. } =
|
||||
builder.ensure(native::Llvm { target: builder.config.build });
|
||||
let llvm::LlvmResult { llvm_config, .. } =
|
||||
builder.ensure(llvm::Llvm { target: builder.config.build });
|
||||
if !builder.config.dry_run() {
|
||||
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
|
||||
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
|
||||
// If LLD is available, add it to the PATH
|
||||
if builder.config.lld_enabled {
|
||||
let lld_install_root =
|
||||
builder.ensure(native::Lld { target: builder.config.build });
|
||||
builder.ensure(llvm::Lld { target: builder.config.build });
|
||||
|
||||
let lld_bin_path = lld_install_root.join("bin");
|
||||
|
||||
@ -2747,3 +2747,68 @@ impl Step for RustInstaller {
|
||||
run.builder.ensure(Self);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct TestHelpers {
|
||||
pub target: TargetSelection,
|
||||
}
|
||||
|
||||
impl Step for TestHelpers {
|
||||
type Output = ();
|
||||
|
||||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
|
||||
run.path("tests/auxiliary/rust_test_helpers.c")
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig<'_>) {
|
||||
run.builder.ensure(TestHelpers { target: run.target })
|
||||
}
|
||||
|
||||
/// Compiles the `rust_test_helpers.c` library which we used in various
|
||||
/// `run-pass` tests for ABI testing.
|
||||
fn run(self, builder: &Builder<'_>) {
|
||||
if builder.config.dry_run() {
|
||||
return;
|
||||
}
|
||||
// The x86_64-fortanix-unknown-sgx target doesn't have a working C
|
||||
// toolchain. However, some x86_64 ELF objects can be linked
|
||||
// without issues. Use this hack to compile the test helpers.
|
||||
let target = if self.target == "x86_64-fortanix-unknown-sgx" {
|
||||
TargetSelection::from_user("x86_64-unknown-linux-gnu")
|
||||
} else {
|
||||
self.target
|
||||
};
|
||||
let dst = builder.test_helpers_out(target);
|
||||
let src = builder.src.join("tests/auxiliary/rust_test_helpers.c");
|
||||
if up_to_date(&src, &dst.join("librust_test_helpers.a")) {
|
||||
return;
|
||||
}
|
||||
|
||||
builder.info("Building test helpers");
|
||||
t!(fs::create_dir_all(&dst));
|
||||
let mut cfg = cc::Build::new();
|
||||
// FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013
|
||||
if target.contains("emscripten") {
|
||||
cfg.pic(false);
|
||||
}
|
||||
|
||||
// We may have found various cross-compilers a little differently due to our
|
||||
// extra configuration, so inform cc of these compilers. Note, though, that
|
||||
// on MSVC we still need cc's detection of env vars (ugh).
|
||||
if !target.contains("msvc") {
|
||||
if let Some(ar) = builder.ar(target) {
|
||||
cfg.archiver(ar);
|
||||
}
|
||||
cfg.compiler(builder.cc(target));
|
||||
}
|
||||
cfg.cargo_metadata(false)
|
||||
.out_dir(&dst)
|
||||
.target(&target.triple)
|
||||
.host(&builder.config.build.triple)
|
||||
.opt_level(0)
|
||||
.warnings(false)
|
||||
.debug(false)
|
||||
.file(builder.src.join("tests/auxiliary/rust_test_helpers.c"))
|
||||
.compile("rust_test_helpers");
|
||||
}
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ def record_metrics(pipeline: Pipeline, timer: Timer):
|
||||
metrics = load_last_metrics(pipeline.metrics_path())
|
||||
if metrics is None:
|
||||
return
|
||||
llvm_steps = tuple(metrics.find_all_by_type("bootstrap::native::Llvm"))
|
||||
llvm_steps = tuple(metrics.find_all_by_type("bootstrap::llvm::Llvm"))
|
||||
assert len(llvm_steps) > 0
|
||||
llvm_duration = sum(step.duration for step in llvm_steps)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user