Skip to content

Commit 2a00629

Browse files
committed
Auto merge of #51459 - kennytm:dist-at-stage-0, r=Mark-Simulacrum
Miscellaneous changes to rustbuild and CI. 1. Don't build LLVM when running rust-installer. 2. If toolstate is unchanged, don't push a commit to the toolstate repo. 3. Allow `./x.py build src/librustc_codegen_llvm` 4. Added log to track #50887.
2 parents 61d8831 + ab5e3e6 commit 2a00629

File tree

5 files changed

+59
-28
lines changed

5 files changed

+59
-28
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ after_failure:
284284
-exec head -750 {} \;
285285
-exec echo travis_fold":"end:crashlog \; || true
286286

287+
# see #50887
288+
- head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
289+
287290
# attempt to debug anything killed by the oom killer on linux, just to see if
288291
# it happened
289292
- dmesg | grep -i kill

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ impl<'a> Builder<'a> {
339339
compile::Std,
340340
compile::Test,
341341
compile::Rustc,
342+
compile::CodegenBackend,
342343
compile::StartupObjects,
343344
tool::BuildManifest,
344345
tool::Rustbook,

src/bootstrap/tool.rs

+28-16
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ pub fn prepare_tool_cargo(
254254
}
255255

256256
macro_rules! tool {
257-
($($name:ident, $path:expr, $tool_name:expr, $mode:expr;)+) => {
257+
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
258258
#[derive(Copy, Clone)]
259259
pub enum Tool {
260260
$(
@@ -269,6 +269,13 @@ macro_rules! tool {
269269
};
270270
mode
271271
}
272+
273+
/// Whether this tool requires LLVM to run
274+
pub fn uses_llvm_tools(&self) -> bool {
275+
match self {
276+
$(Tool::$name => true $(&& $llvm)*,)+
277+
}
278+
}
272279
}
273280

274281
impl<'a> Builder<'a> {
@@ -333,6 +340,9 @@ macro_rules! tool {
333340
}
334341
}
335342

343+
// FIXME(#51459): We have only checked that RustInstaller does not require
344+
// the LLVM binaries when running. We should go through all tools to determine
345+
// if they really need LLVM binaries, and make `llvm_tools` a required argument.
336346
tool!(
337347
Rustbook, "src/tools/rustbook", "rustbook", Mode::ToolRustc;
338348
ErrorIndex, "src/tools/error_index_generator", "error_index_generator", Mode::ToolRustc;
@@ -343,7 +353,7 @@ tool!(
343353
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolTest;
344354
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolStd;
345355
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolStd;
346-
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd;
356+
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolStd, llvm_tools = false;
347357
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolStd;
348358
);
349359

@@ -586,19 +596,19 @@ impl<'a> Builder<'a> {
586596
pub fn tool_cmd(&self, tool: Tool) -> Command {
587597
let mut cmd = Command::new(self.tool_exe(tool));
588598
let compiler = self.compiler(self.tool_default_stage(tool), self.config.build);
589-
self.prepare_tool_cmd(compiler, tool.get_mode(), &mut cmd);
599+
self.prepare_tool_cmd(compiler, tool, &mut cmd);
590600
cmd
591601
}
592602

593603
/// Prepares the `cmd` provided to be able to run the `compiler` provided.
594604
///
595605
/// Notably this munges the dynamic library lookup path to point to the
596606
/// right location to run `compiler`.
597-
fn prepare_tool_cmd(&self, compiler: Compiler, mode: Mode, cmd: &mut Command) {
607+
fn prepare_tool_cmd(&self, compiler: Compiler, tool: Tool, cmd: &mut Command) {
598608
let host = &compiler.host;
599609
let mut lib_paths: Vec<PathBuf> = vec![
600610
PathBuf::from(&self.sysroot_libdir(compiler, compiler.host)),
601-
self.cargo_out(compiler, mode, *host).join("deps"),
611+
self.cargo_out(compiler, tool.get_mode(), *host).join("deps"),
602612
];
603613

604614
// On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make
@@ -621,17 +631,19 @@ impl<'a> Builder<'a> {
621631

622632
// Add the llvm/bin directory to PATH since it contains lots of
623633
// useful, platform-independent tools
624-
if let Some(llvm_bin_path) = self.llvm_bin_path() {
625-
if host.contains("windows") {
626-
// On Windows, PATH and the dynamic library path are the same,
627-
// so we just add the LLVM bin path to lib_path
628-
lib_paths.push(llvm_bin_path);
629-
} else {
630-
let old_path = env::var_os("PATH").unwrap_or_default();
631-
let new_path = env::join_paths(iter::once(llvm_bin_path)
632-
.chain(env::split_paths(&old_path)))
633-
.expect("Could not add LLVM bin path to PATH");
634-
cmd.env("PATH", new_path);
634+
if tool.uses_llvm_tools() {
635+
if let Some(llvm_bin_path) = self.llvm_bin_path() {
636+
if host.contains("windows") {
637+
// On Windows, PATH and the dynamic library path are the same,
638+
// so we just add the LLVM bin path to lib_path
639+
lib_paths.push(llvm_bin_path);
640+
} else {
641+
let old_path = env::var_os("PATH").unwrap_or_default();
642+
let new_path = env::join_paths(iter::once(llvm_bin_path)
643+
.chain(env::split_paths(&old_path)))
644+
.expect("Could not add LLVM bin path to PATH");
645+
cmd.env("PATH", new_path);
646+
}
635647
}
636648
}
637649

src/ci/docker/x86_64-gnu-tools/checkregression.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
os_name = sys.argv[1]
1919
toolstate_file = sys.argv[2]
2020
current_state = sys.argv[3]
21+
verb = sys.argv[4] # 'regressed' or 'changed'
2122

2223
with open(toolstate_file, 'r') as f:
2324
toolstate = json.load(f)
@@ -29,10 +30,17 @@
2930
tool = cur['tool']
3031
state = cur[os_name]
3132
new_state = toolstate.get(tool, '')
32-
if new_state < state:
33+
if verb == 'regressed':
34+
updated = new_state < state
35+
elif verb == 'changed':
36+
updated = new_state != state
37+
else:
38+
print('Unknown verb {}'.format(updated))
39+
sys.exit(2)
40+
if updated:
3341
print(
34-
'Error: The state of "{}" has regressed from "{}" to "{}"'
35-
.format(tool, state, new_state)
42+
'The state of "{}" has {} from "{}" to "{}"'
43+
.format(tool, verb, state, new_state)
3644
)
3745
regressed = True
3846

src/ci/docker/x86_64-gnu-tools/checktools.sh

+16-9
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,26 @@ status_check() {
9191

9292
status_check "submodule_changed"
9393

94-
if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
95-
. "$(dirname $0)/repo.sh"
96-
MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
97-
echo "($OS CI update)" > "$MESSAGE_FILE"
98-
commit_toolstate_change "$MESSAGE_FILE" \
94+
CHECK_NOT="$(dirname $0)/checkregression.py"
95+
change_toolstate() {
96+
# only update the history
97+
if python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" changed; then
98+
echo 'Toolstate is not changed. Not updating.'
99+
else
100+
if [ $SIX_WEEK_CYCLE -eq 5 ]; then
101+
python2.7 "$CHECK_NOT" "$OS" "$TOOLSTATE_FILE" "_data/latest.json" regressed
102+
fi
99103
sed -i "1 a\\
100104
$COMMIT\t$(cat "$TOOLSTATE_FILE")
101105
" "history/$OS.tsv"
102-
# if we are at the last week in the 6-week release cycle, reject any kind of regression.
103-
if [ $SIX_WEEK_CYCLE -eq 5 ]; then
104-
python2.7 "$(dirname $0)/checkregression.py" \
105-
"$OS" "$TOOLSTATE_FILE" "rust-toolstate/_data/latest.json"
106106
fi
107+
}
108+
109+
if [ "$RUST_RELEASE_CHANNEL" = nightly -a -n "${TOOLSTATE_REPO_ACCESS_TOKEN+is_set}" ]; then
110+
. "$(dirname $0)/repo.sh"
111+
MESSAGE_FILE=$(mktemp -t msg.XXXXXX)
112+
echo "($OS CI update)" > "$MESSAGE_FILE"
113+
commit_toolstate_change "$MESSAGE_FILE" change_toolstate
107114
rm -f "$MESSAGE_FILE"
108115
exit 0
109116
fi

0 commit comments

Comments
 (0)