1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Implementation of compiling the compiler and standard library, in "check" mode.
13 use compile
::{run_cargo, std_cargo, test_cargo, rustc_cargo, add_to_sysroot}
;
14 use builder
::{RunConfig, Builder, ShouldRun, Step}
;
15 use {Build, Compiler, Mode}
;
17 use std
::path
::PathBuf
;
19 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
21 pub target
: Interned
<String
>,
26 const DEFAULT
: bool
= true;
28 fn should_run(run
: ShouldRun
) -> ShouldRun
{
32 fn make_run(run
: RunConfig
) {
33 run
.builder
.ensure(Std
{
38 fn run(self, builder
: &Builder
) {
39 let build
= builder
.build
;
40 let target
= self.target
;
41 let compiler
= builder
.compiler(0, build
.build
);
43 let out_dir
= build
.stage_out(compiler
, Mode
::Libstd
);
44 build
.clear_if_dirty(&out_dir
, &builder
.rustc(compiler
));
45 let mut cargo
= builder
.cargo(compiler
, Mode
::Libstd
, target
, "check");
46 std_cargo(builder
, &compiler
, target
, &mut cargo
);
48 let _folder
= build
.fold_output(|| format
!("stage{}-std", compiler
.stage
));
49 println
!("Checking std artifacts ({} -> {})", &compiler
.host
, target
);
52 &libstd_stamp(build
, compiler
, target
),
55 let libdir
= builder
.sysroot_libdir(compiler
, target
);
56 add_to_sysroot(&libdir
, &libstd_stamp(build
, compiler
, target
));
60 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
62 pub target
: Interned
<String
>,
67 const ONLY_HOSTS
: bool
= true;
68 const DEFAULT
: bool
= true;
70 fn should_run(run
: ShouldRun
) -> ShouldRun
{
71 run
.all_krates("rustc-main")
74 fn make_run(run
: RunConfig
) {
75 run
.builder
.ensure(Rustc
{
80 /// Build the compiler.
82 /// This will build the compiler for a particular stage of the build using
83 /// the `compiler` targeting the `target` architecture. The artifacts
84 /// created will also be linked into the sysroot directory.
85 fn run(self, builder
: &Builder
) {
86 let build
= builder
.build
;
87 let compiler
= builder
.compiler(0, build
.build
);
88 let target
= self.target
;
90 let stage_out
= builder
.stage_out(compiler
, Mode
::Librustc
);
91 build
.clear_if_dirty(&stage_out
, &libstd_stamp(build
, compiler
, target
));
92 build
.clear_if_dirty(&stage_out
, &libtest_stamp(build
, compiler
, target
));
94 let mut cargo
= builder
.cargo(compiler
, Mode
::Librustc
, target
, "check");
95 rustc_cargo(build
, &mut cargo
);
97 let _folder
= build
.fold_output(|| format
!("stage{}-rustc", compiler
.stage
));
98 println
!("Checking compiler artifacts ({} -> {})", &compiler
.host
, target
);
101 &librustc_stamp(build
, compiler
, target
),
104 let libdir
= builder
.sysroot_libdir(compiler
, target
);
105 add_to_sysroot(&libdir
, &librustc_stamp(build
, compiler
, target
));
109 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
111 pub target
: Interned
<String
>,
116 const DEFAULT
: bool
= true;
118 fn should_run(run
: ShouldRun
) -> ShouldRun
{
119 run
.all_krates("test")
122 fn make_run(run
: RunConfig
) {
123 run
.builder
.ensure(Test
{
128 fn run(self, builder
: &Builder
) {
129 let build
= builder
.build
;
130 let target
= self.target
;
131 let compiler
= builder
.compiler(0, build
.build
);
133 let out_dir
= build
.stage_out(compiler
, Mode
::Libtest
);
134 build
.clear_if_dirty(&out_dir
, &libstd_stamp(build
, compiler
, target
));
135 let mut cargo
= builder
.cargo(compiler
, Mode
::Libtest
, target
, "check");
136 test_cargo(build
, &compiler
, target
, &mut cargo
);
138 let _folder
= build
.fold_output(|| format
!("stage{}-test", compiler
.stage
));
139 println
!("Checking test artifacts ({} -> {})", &compiler
.host
, target
);
142 &libtest_stamp(build
, compiler
, target
),
145 let libdir
= builder
.sysroot_libdir(compiler
, target
);
146 add_to_sysroot(&libdir
, &libtest_stamp(build
, compiler
, target
));
150 /// Cargo's output path for the standard library in a given stage, compiled
151 /// by a particular compiler for the specified target.
152 pub fn libstd_stamp(build
: &Build
, compiler
: Compiler
, target
: Interned
<String
>) -> PathBuf
{
153 build
.cargo_out(compiler
, Mode
::Libstd
, target
).join(".libstd-check.stamp")
156 /// Cargo's output path for libtest in a given stage, compiled by a particular
157 /// compiler for the specified target.
158 pub fn libtest_stamp(build
: &Build
, compiler
: Compiler
, target
: Interned
<String
>) -> PathBuf
{
159 build
.cargo_out(compiler
, Mode
::Libtest
, target
).join(".libtest-check.stamp")
162 /// Cargo's output path for librustc in a given stage, compiled by a particular
163 /// compiler for the specified target.
164 pub fn librustc_stamp(build
: &Build
, compiler
: Compiler
, target
: Interned
<String
>) -> PathBuf
{
165 build
.cargo_out(compiler
, Mode
::Librustc
, target
).join(".librustc-check.stamp")