Skip to content

Commit 5bffc26

Browse files
authored
Rollup merge of #80514 - pietroalbini:fix-install, r=Mark-Simulacrum
Fix broken ./x.py install During my tarball refactorings in #79788 I changed the directory layout used by the tarball generation code, and that broke the other parts of rustbuild which hardcoded the paths of those directories. Namely, `./x.py install` relied on the uncompressed copy of the tarball left behind by `fabricate`/`rust-installer`, causing #80494. While the easy fix for #80494 would've been to just update the hardcoded paths to match the new structure, that fix would leave us in the same situation if we were to change the directory layout again in the future. Instead I refactored the code to return a `GeneratedTarball` struct as the output of all the dist steps, and I put all the paths the rest of rustbuild needs to care about in its fields. That way, future changes to `src/bootstrap/tarball.rs` will not break other stuff. This PR is best reviewed commit-by-commit. r? `@Mark-Simulacrum` `@rustbot` modify labels: beta-nominated beta-accepted T-release
2 parents 7d247c9 + 8e0ab0f commit 5bffc26

File tree

4 files changed

+110
-136
lines changed

4 files changed

+110
-136
lines changed

src/bootstrap/dist.rs

+41-41
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step};
1919
use crate::cache::{Interned, INTERNER};
2020
use crate::compile;
2121
use crate::config::TargetSelection;
22-
use crate::tarball::{OverlayKind, Tarball};
22+
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
2323
use crate::tool::{self, Tool};
2424
use crate::util::{exe, is_dylib, timeit};
2525
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
@@ -51,7 +51,7 @@ pub struct Docs {
5151
}
5252

5353
impl Step for Docs {
54-
type Output = Option<PathBuf>;
54+
type Output = Option<GeneratedTarball>;
5555
const DEFAULT: bool = true;
5656

5757
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -63,7 +63,7 @@ impl Step for Docs {
6363
}
6464

6565
/// Builds the `rust-docs` installer component.
66-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
66+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
6767
let host = self.host;
6868
if !builder.config.docs {
6969
return None;
@@ -86,7 +86,7 @@ pub struct RustcDocs {
8686
}
8787

8888
impl Step for RustcDocs {
89-
type Output = Option<PathBuf>;
89+
type Output = Option<GeneratedTarball>;
9090
const DEFAULT: bool = true;
9191

9292
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -98,7 +98,7 @@ impl Step for RustcDocs {
9898
}
9999

100100
/// Builds the `rustc-docs` installer component.
101-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
101+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
102102
let host = self.host;
103103
if !builder.config.compiler_docs {
104104
return None;
@@ -267,7 +267,7 @@ pub struct Mingw {
267267
}
268268

269269
impl Step for Mingw {
270-
type Output = Option<PathBuf>;
270+
type Output = Option<GeneratedTarball>;
271271
const DEFAULT: bool = true;
272272

273273
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -282,7 +282,7 @@ impl Step for Mingw {
282282
///
283283
/// This contains all the bits and pieces to run the MinGW Windows targets
284284
/// without any extra installed software (e.g., we bundle gcc, libraries, etc).
285-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
285+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
286286
let host = self.host;
287287
if !host.contains("pc-windows-gnu") {
288288
return None;
@@ -307,7 +307,7 @@ pub struct Rustc {
307307
}
308308

309309
impl Step for Rustc {
310-
type Output = PathBuf;
310+
type Output = GeneratedTarball;
311311
const DEFAULT: bool = true;
312312
const ONLY_HOSTS: bool = true;
313313

@@ -321,7 +321,7 @@ impl Step for Rustc {
321321
}
322322

323323
/// Creates the `rustc` installer component.
324-
fn run(self, builder: &Builder<'_>) -> PathBuf {
324+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
325325
let compiler = self.compiler;
326326
let host = self.compiler.host;
327327

@@ -555,7 +555,7 @@ pub struct Std {
555555
}
556556

557557
impl Step for Std {
558-
type Output = Option<PathBuf>;
558+
type Output = Option<GeneratedTarball>;
559559
const DEFAULT: bool = true;
560560

561561
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -573,7 +573,7 @@ impl Step for Std {
573573
});
574574
}
575575

576-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
576+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
577577
let compiler = self.compiler;
578578
let target = self.target;
579579

@@ -601,7 +601,7 @@ pub struct RustcDev {
601601
}
602602

603603
impl Step for RustcDev {
604-
type Output = Option<PathBuf>;
604+
type Output = Option<GeneratedTarball>;
605605
const DEFAULT: bool = true;
606606
const ONLY_HOSTS: bool = true;
607607

@@ -620,7 +620,7 @@ impl Step for RustcDev {
620620
});
621621
}
622622

623-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
623+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
624624
let compiler = self.compiler;
625625
let target = self.target;
626626
if skip_host_target_lib(builder, compiler) {
@@ -660,7 +660,7 @@ pub struct Analysis {
660660
}
661661

662662
impl Step for Analysis {
663-
type Output = Option<PathBuf>;
663+
type Output = Option<GeneratedTarball>;
664664
const DEFAULT: bool = true;
665665

666666
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -683,7 +683,7 @@ impl Step for Analysis {
683683
}
684684

685685
/// Creates a tarball of save-analysis metadata, if available.
686-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
686+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
687687
let compiler = self.compiler;
688688
let target = self.target;
689689
assert!(builder.config.extended);
@@ -796,7 +796,7 @@ pub struct Src;
796796

797797
impl Step for Src {
798798
/// The output path of the src installer tarball
799-
type Output = PathBuf;
799+
type Output = GeneratedTarball;
800800
const DEFAULT: bool = true;
801801
const ONLY_HOSTS: bool = true;
802802

@@ -809,7 +809,7 @@ impl Step for Src {
809809
}
810810

811811
/// Creates the `rust-src` installer component
812-
fn run(self, builder: &Builder<'_>) -> PathBuf {
812+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
813813
let tarball = Tarball::new_targetless(builder, "rust-src");
814814

815815
// A lot of tools expect the rust-src component to be entirely in this directory, so if you
@@ -848,7 +848,7 @@ pub struct PlainSourceTarball;
848848

849849
impl Step for PlainSourceTarball {
850850
/// Produces the location of the tarball generated
851-
type Output = PathBuf;
851+
type Output = GeneratedTarball;
852852
const DEFAULT: bool = true;
853853
const ONLY_HOSTS: bool = true;
854854

@@ -862,7 +862,7 @@ impl Step for PlainSourceTarball {
862862
}
863863

864864
/// Creates the plain source tarball
865-
fn run(self, builder: &Builder<'_>) -> PathBuf {
865+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
866866
let tarball = Tarball::new(builder, "rustc", "src");
867867
let plain_dst_src = tarball.image_dir();
868868

@@ -941,7 +941,7 @@ pub struct Cargo {
941941
}
942942

943943
impl Step for Cargo {
944-
type Output = PathBuf;
944+
type Output = GeneratedTarball;
945945
const ONLY_HOSTS: bool = true;
946946

947947
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -959,7 +959,7 @@ impl Step for Cargo {
959959
});
960960
}
961961

962-
fn run(self, builder: &Builder<'_>) -> PathBuf {
962+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
963963
let compiler = self.compiler;
964964
let target = self.target;
965965

@@ -995,7 +995,7 @@ pub struct Rls {
995995
}
996996

997997
impl Step for Rls {
998-
type Output = Option<PathBuf>;
998+
type Output = Option<GeneratedTarball>;
999999
const ONLY_HOSTS: bool = true;
10001000

10011001
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1013,7 +1013,7 @@ impl Step for Rls {
10131013
});
10141014
}
10151015

1016-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1016+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
10171017
let compiler = self.compiler;
10181018
let target = self.target;
10191019
assert!(builder.config.extended);
@@ -1041,7 +1041,7 @@ pub struct RustAnalyzer {
10411041
}
10421042

10431043
impl Step for RustAnalyzer {
1044-
type Output = Option<PathBuf>;
1044+
type Output = Option<GeneratedTarball>;
10451045
const ONLY_HOSTS: bool = true;
10461046

10471047
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1059,7 +1059,7 @@ impl Step for RustAnalyzer {
10591059
});
10601060
}
10611061

1062-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1062+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
10631063
let compiler = self.compiler;
10641064
let target = self.target;
10651065
assert!(builder.config.extended);
@@ -1090,7 +1090,7 @@ pub struct Clippy {
10901090
}
10911091

10921092
impl Step for Clippy {
1093-
type Output = PathBuf;
1093+
type Output = GeneratedTarball;
10941094
const ONLY_HOSTS: bool = true;
10951095

10961096
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1108,7 +1108,7 @@ impl Step for Clippy {
11081108
});
11091109
}
11101110

1111-
fn run(self, builder: &Builder<'_>) -> PathBuf {
1111+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
11121112
let compiler = self.compiler;
11131113
let target = self.target;
11141114
assert!(builder.config.extended);
@@ -1140,7 +1140,7 @@ pub struct Miri {
11401140
}
11411141

11421142
impl Step for Miri {
1143-
type Output = Option<PathBuf>;
1143+
type Output = Option<GeneratedTarball>;
11441144
const ONLY_HOSTS: bool = true;
11451145

11461146
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1158,7 +1158,7 @@ impl Step for Miri {
11581158
});
11591159
}
11601160

1161-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1161+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
11621162
let compiler = self.compiler;
11631163
let target = self.target;
11641164
assert!(builder.config.extended);
@@ -1193,7 +1193,7 @@ pub struct Rustfmt {
11931193
}
11941194

11951195
impl Step for Rustfmt {
1196-
type Output = Option<PathBuf>;
1196+
type Output = Option<GeneratedTarball>;
11971197
const ONLY_HOSTS: bool = true;
11981198

11991199
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1211,7 +1211,7 @@ impl Step for Rustfmt {
12111211
});
12121212
}
12131213

1214-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1214+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
12151215
let compiler = self.compiler;
12161216
let target = self.target;
12171217

@@ -1316,11 +1316,11 @@ impl Step for Extended {
13161316
tarballs.push(mingw_installer.unwrap());
13171317
}
13181318

1319-
let mut tarball = Tarball::new(builder, "rust", &target.triple);
1320-
let work = tarball.persist_work_dir();
1321-
tarball.combine(&tarballs);
1319+
let tarball = Tarball::new(builder, "rust", &target.triple);
1320+
let generated = tarball.combine(&tarballs);
13221321

13231322
let tmp = tmpdir(builder).join("combined-tarball");
1323+
let work = generated.work_dir();
13241324

13251325
let mut license = String::new();
13261326
license += &builder.read(&builder.src.join("COPYRIGHT"));
@@ -1870,7 +1870,7 @@ pub struct LlvmTools {
18701870
}
18711871

18721872
impl Step for LlvmTools {
1873-
type Output = Option<PathBuf>;
1873+
type Output = Option<GeneratedTarball>;
18741874
const ONLY_HOSTS: bool = true;
18751875

18761876
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -1881,7 +1881,7 @@ impl Step for LlvmTools {
18811881
run.builder.ensure(LlvmTools { target: run.target });
18821882
}
18831883

1884-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1884+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
18851885
let target = self.target;
18861886
assert!(builder.config.extended);
18871887

@@ -1924,7 +1924,7 @@ pub struct RustDev {
19241924
}
19251925

19261926
impl Step for RustDev {
1927-
type Output = Option<PathBuf>;
1927+
type Output = Option<GeneratedTarball>;
19281928
const DEFAULT: bool = true;
19291929
const ONLY_HOSTS: bool = true;
19301930

@@ -1936,7 +1936,7 @@ impl Step for RustDev {
19361936
run.builder.ensure(RustDev { target: run.target });
19371937
}
19381938

1939-
fn run(self, builder: &Builder<'_>) -> Option<PathBuf> {
1939+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
19401940
let target = self.target;
19411941

19421942
/* run only if llvm-config isn't used */
@@ -1989,7 +1989,7 @@ pub struct BuildManifest {
19891989
}
19901990

19911991
impl Step for BuildManifest {
1992-
type Output = PathBuf;
1992+
type Output = GeneratedTarball;
19931993
const DEFAULT: bool = false;
19941994
const ONLY_HOSTS: bool = true;
19951995

@@ -2001,7 +2001,7 @@ impl Step for BuildManifest {
20012001
run.builder.ensure(BuildManifest { target: run.target });
20022002
}
20032003

2004-
fn run(self, builder: &Builder<'_>) -> PathBuf {
2004+
fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
20052005
let build_manifest = builder.tool_exe(Tool::BuildManifest);
20062006

20072007
let tarball = Tarball::new(builder, "build-manifest", &self.target.triple);
@@ -2021,7 +2021,7 @@ pub struct ReproducibleArtifacts {
20212021
}
20222022

20232023
impl Step for ReproducibleArtifacts {
2024-
type Output = Option<PathBuf>;
2024+
type Output = Option<GeneratedTarball>;
20252025
const DEFAULT: bool = true;
20262026
const ONLY_HOSTS: bool = true;
20272027

0 commit comments

Comments
 (0)