Skip to content

Commit 3964a55

Browse files
committed
Auto merge of #67077 - Aaron1011:build-llvm-in-binary, r=alexcrichton
rustc: Link LLVM directly into rustc again (take two) This is a continuation of PR #65703
2 parents 9409c20 + 47e932b commit 3964a55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+251
-479
lines changed

Cargo.lock

+22
Original file line numberDiff line numberDiff line change
@@ -3435,7 +3435,27 @@ dependencies = [
34353435
name = "rustc_codegen_llvm"
34363436
version = "0.0.0"
34373437
dependencies = [
3438+
"bitflags",
3439+
"flate2",
3440+
"libc",
3441+
"log",
3442+
"rustc",
3443+
"rustc-demangle",
3444+
"rustc_codegen_ssa",
3445+
"rustc_codegen_utils",
3446+
"rustc_data_structures",
3447+
"rustc_errors",
3448+
"rustc_feature",
3449+
"rustc_fs_util",
3450+
"rustc_incremental",
3451+
"rustc_index",
34383452
"rustc_llvm",
3453+
"rustc_session",
3454+
"rustc_target",
3455+
"smallvec 0.6.10",
3456+
"syntax",
3457+
"syntax_expand",
3458+
"syntax_pos",
34393459
]
34403460

34413461
[[package]]
@@ -3597,6 +3617,7 @@ dependencies = [
35973617
"once_cell",
35983618
"rustc",
35993619
"rustc-rayon",
3620+
"rustc_codegen_llvm",
36003621
"rustc_codegen_ssa",
36013622
"rustc_codegen_utils",
36023623
"rustc_data_structures",
@@ -3651,6 +3672,7 @@ version = "0.0.0"
36513672
dependencies = [
36523673
"build_helper",
36533674
"cc",
3675+
"libc",
36543676
]
36553677

36563678
[[package]]

config.toml.example

-3
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,6 @@
379379
# and currently the only standard option supported is `"llvm"`
380380
#codegen-backends = ["llvm"]
381381

382-
# This is the name of the directory in which codegen backends will get installed
383-
#codegen-backends-dir = "codegen-backends"
384-
385382
# Indicates whether LLD will be compiled and made available in the sysroot for
386383
# rustc to execute.
387384
#lld = false

src/bootstrap/builder.rs

-22
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ impl<'a> Builder<'a> {
339339
Kind::Build => describe!(
340340
compile::Std,
341341
compile::Rustc,
342-
compile::CodegenBackend,
343342
compile::StartupObjects,
344343
tool::BuildManifest,
345344
tool::Rustbook,
@@ -364,7 +363,6 @@ impl<'a> Builder<'a> {
364363
Kind::Check | Kind::Clippy | Kind::Fix => describe!(
365364
check::Std,
366365
check::Rustc,
367-
check::CodegenBackend,
368366
check::Rustdoc
369367
),
370368
Kind::Test => describe!(
@@ -632,11 +630,6 @@ impl<'a> Builder<'a> {
632630
self.ensure(Libdir { compiler, target })
633631
}
634632

635-
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
636-
self.sysroot_libdir(compiler, compiler.host)
637-
.with_file_name(self.config.rust_codegen_backends_dir.clone())
638-
}
639-
640633
/// Returns the compiler's libdir where it stores the dynamic libraries that
641634
/// it itself links against.
642635
///
@@ -707,15 +700,6 @@ impl<'a> Builder<'a> {
707700
}
708701
}
709702

710-
/// Gets the paths to all of the compiler's codegen backends.
711-
fn codegen_backends(&self, compiler: Compiler) -> impl Iterator<Item = PathBuf> {
712-
fs::read_dir(self.sysroot_codegen_backends(compiler))
713-
.into_iter()
714-
.flatten()
715-
.filter_map(Result::ok)
716-
.map(|entry| entry.path())
717-
}
718-
719703
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
720704
self.ensure(tool::Rustdoc { compiler })
721705
}
@@ -759,12 +743,6 @@ impl<'a> Builder<'a> {
759743
let mut cargo = Command::new(&self.initial_cargo);
760744
let out_dir = self.stage_out(compiler, mode);
761745

762-
// Codegen backends are not yet tracked by -Zbinary-dep-depinfo,
763-
// so we need to explicitly clear out if they've been updated.
764-
for backend in self.codegen_backends(compiler) {
765-
self.clear_if_dirty(&out_dir, &backend);
766-
}
767-
768746
if cmd == "doc" || cmd == "rustdoc" {
769747
let my_out = match mode {
770748
// This is the intended out directory for compiler documentation.

src/bootstrap/builder/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ fn dist_with_same_targets_and_hosts() {
363363
compiler: Compiler { host: a, stage: 1 },
364364
target: b,
365365
},
366+
compile::Std {
367+
compiler: Compiler { host: a, stage: 2 },
368+
target: b,
369+
},
366370
]
367371
);
368372
assert_eq!(

src/bootstrap/check.rs

+3-63
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
//! Implementation of compiling the compiler and standard library, in "check"-based modes.
22
3-
use crate::compile::{run_cargo, std_cargo, rustc_cargo, rustc_cargo_env,
4-
add_to_sysroot};
3+
use crate::compile::{run_cargo, std_cargo, rustc_cargo, add_to_sysroot};
54
use crate::builder::{RunConfig, Builder, Kind, ShouldRun, Step};
65
use crate::tool::{prepare_tool_cargo, SourceType};
76
use crate::{Compiler, Mode};
8-
use crate::cache::{INTERNER, Interned};
7+
use crate::cache::Interned;
98
use std::path::PathBuf;
109

1110
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -97,7 +96,7 @@ impl Step for Rustc {
9796

9897
let mut cargo = builder.cargo(compiler, Mode::Rustc, target,
9998
cargo_subcommand(builder.kind));
100-
rustc_cargo(builder, &mut cargo);
99+
rustc_cargo(builder, &mut cargo, target);
101100

102101
builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target));
103102
run_cargo(builder,
@@ -113,55 +112,6 @@ impl Step for Rustc {
113112
}
114113
}
115114

116-
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
117-
pub struct CodegenBackend {
118-
pub target: Interned<String>,
119-
pub backend: Interned<String>,
120-
}
121-
122-
impl Step for CodegenBackend {
123-
type Output = ();
124-
const ONLY_HOSTS: bool = true;
125-
const DEFAULT: bool = true;
126-
127-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
128-
run.all_krates("rustc_codegen_llvm")
129-
}
130-
131-
fn make_run(run: RunConfig<'_>) {
132-
let backend = run.builder.config.rust_codegen_backends.get(0);
133-
let backend = backend.cloned().unwrap_or_else(|| {
134-
INTERNER.intern_str("llvm")
135-
});
136-
run.builder.ensure(CodegenBackend {
137-
target: run.target,
138-
backend,
139-
});
140-
}
141-
142-
fn run(self, builder: &Builder<'_>) {
143-
let compiler = builder.compiler(0, builder.config.build);
144-
let target = self.target;
145-
let backend = self.backend;
146-
147-
builder.ensure(Rustc { target });
148-
149-
let mut cargo = builder.cargo(compiler, Mode::Codegen, target,
150-
cargo_subcommand(builder.kind));
151-
cargo.arg("--manifest-path").arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
152-
rustc_cargo_env(builder, &mut cargo);
153-
154-
// We won't build LLVM if it's not available, as it shouldn't affect `check`.
155-
156-
run_cargo(builder,
157-
cargo,
158-
args(builder.kind),
159-
&codegen_backend_stamp(builder, compiler, target, backend),
160-
vec![],
161-
true);
162-
}
163-
}
164-
165115
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
166116
pub struct Rustdoc {
167117
pub target: Interned<String>,
@@ -231,16 +181,6 @@ pub fn librustc_stamp(
231181
builder.cargo_out(compiler, Mode::Rustc, target).join(".librustc-check.stamp")
232182
}
233183

234-
/// Cargo's output path for librustc_codegen_llvm in a given stage, compiled by a particular
235-
/// compiler for the specified target and backend.
236-
fn codegen_backend_stamp(builder: &Builder<'_>,
237-
compiler: Compiler,
238-
target: Interned<String>,
239-
backend: Interned<String>) -> PathBuf {
240-
builder.cargo_out(compiler, Mode::Codegen, target)
241-
.join(format!(".librustc_codegen_llvm-{}-check.stamp", backend))
242-
}
243-
244184
/// Cargo's output path for rustdoc in a given stage, compiled by a particular
245185
/// compiler for the specified target.
246186
pub fn rustdoc_stamp(

0 commit comments

Comments
 (0)