Skip to content

Commit

Permalink
Auto merge of #83890 - Dylan-DPC:rollup-9fqy3fe, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

Successful merges:

 - #83368 (Add `download-rustc = "if-unchanged"`)
 - #83705 (Give a better error when --theme is not a CSS file)
 - #83853 (Disallow the use of high byte registes as operands on x86_64)
 - #83877 (Remove unnecessary exceptions to the platform-specific code check)
 - #83878 (Fix racing file access in tidy)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 5, 2021
2 parents 39eee17 + d856a26 commit 5a7a0ac
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 53 deletions.
2 changes: 0 additions & 2 deletions compiler/rustc_target/src/asm/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ fn frame_pointer_r11(
_arch: InlineAsmArch,
has_feature: impl FnMut(&str) -> bool,
target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
if !frame_pointer_is_r7(has_feature, target) {
Err("the frame pointer (r11) cannot be used as an operand for inline asm")
Expand All @@ -81,7 +80,6 @@ fn frame_pointer_r7(
_arch: InlineAsmArch,
has_feature: impl FnMut(&str) -> bool,
target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
if frame_pointer_is_r7(has_feature, target) {
Err("the frame pointer (r7) cannot be used as an operand for inline asm")
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ macro_rules! def_regs {
match name {
$(
$($alias)|* | $reg_name => {
$($filter(_arch, &mut _has_feature, _target, false)?;)?
$($filter(_arch, &mut _has_feature, _target)?;)?
Ok(Self::$reg)
}
)*
Expand All @@ -114,7 +114,7 @@ macro_rules! def_regs {
#[allow(unused_imports)]
use super::{InlineAsmReg, InlineAsmRegClass};
$(
if $($filter(_arch, &mut _has_feature, _target, true).is_ok() &&)? true {
if $($filter(_arch, &mut _has_feature, _target).is_ok() &&)? true {
if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/asm/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ fn not_e(
_arch: InlineAsmArch,
mut has_feature: impl FnMut(&str) -> bool,
_target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
if has_feature("e") {
Err("register can't be used with the `e` target feature")
Expand Down
7 changes: 1 addition & 6 deletions compiler/rustc_target/src/asm/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ fn x86_64_only(
arch: InlineAsmArch,
_has_feature: impl FnMut(&str) -> bool,
_target: &Target,
_allocating: bool,
) -> Result<(), &'static str> {
match arch {
InlineAsmArch::X86 => Err("register is only available on x86_64"),
Expand All @@ -146,13 +145,9 @@ fn high_byte(
arch: InlineAsmArch,
_has_feature: impl FnMut(&str) -> bool,
_target: &Target,
allocating: bool,
) -> Result<(), &'static str> {
match arch {
InlineAsmArch::X86_64 if allocating => {
// The error message isn't actually used...
Err("high byte registers are not allocated by reg_byte")
}
InlineAsmArch::X86_64 => Err("high byte registers cannot be used as an operand on x86_64"),
_ => Ok(()),
}
}
Expand Down
4 changes: 3 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,9 @@ changelog-seen = 2
# Whether to download the stage 1 and 2 compilers from CI.
# This is mostly useful for tools; if you have changes to `compiler/` they will be ignored.
#
# FIXME: currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
# You can set this to "if-unchanged" to only download if `compiler/` has not been modified.
#
# FIXME(#82739): currently, this also uses the downloaded compiler for stage0, but that causes unnecessary rebuilds.
#download-rustc = false

# Number of codegen units to use for each compiler invocation. A value of 0
Expand Down
8 changes: 7 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,10 @@ def fix_bin_or_dylib(self, fname, rpath_libz=False):
# If `download-rustc` is set, download the most recent commit with CI artifacts
def maybe_download_ci_toolchain(self):
# If `download-rustc` is not set, default to rebuilding.
if self.get_toml("download-rustc", section="rust") != "true":
download_rustc = self.get_toml("download-rustc", section="rust")
if download_rustc is None or download_rustc == "false":
return None
assert download_rustc == "true" or download_rustc == "if-unchanged", download_rustc

# Handle running from a directory other than the top level
rev_parse = ["git", "rev-parse", "--show-toplevel"]
Expand All @@ -660,6 +662,8 @@ def maybe_download_ci_toolchain(self):
# Warn if there were changes to the compiler since the ancestor commit.
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler])
if status != 0:
if download_rustc == "if-unchanged":
return None
print("warning: `download-rustc` is enabled, but there are changes to compiler/")

if self.verbose:
Expand Down Expand Up @@ -1175,6 +1179,8 @@ def bootstrap(help_triggered):
env["RUSTC_BOOTSTRAP"] = '1'
if toml_path:
env["BOOTSTRAP_CONFIG"] = toml_path
if build.rustc_commit is not None:
env["BOOTSTRAP_DOWNLOAD_RUSTC"] = '1'
run(args, env=env, verbose=build.verbose)


Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ struct Rust {
new_symbol_mangling: Option<bool>,
profile_generate: Option<String>,
profile_use: Option<String>,
download_rustc: Option<bool>,
// ignored; this is set from an env var set by bootstrap.py
download_rustc: Option<StringOrBool>,
}

/// TOML representation of how each build target is configured.
Expand Down Expand Up @@ -852,7 +853,7 @@ impl Config {
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
config.download_rustc = rust.download_rustc.unwrap_or(false);
config.download_rustc = env::var("BOOTSTRAP_DOWNLOAD_RUSTC").as_deref() == Ok("1");
} else {
config.rust_profile_use = flags.rust_profile_use;
config.rust_profile_generate = flags.rust_profile_generate;
Expand Down
4 changes: 2 additions & 2 deletions src/doc/unstable-book/src/library-features/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ Here is the list of currently supported register classes:
| x86 | `reg` | `ax`, `bx`, `cx`, `dx`, `si`, `di`, `r[8-15]` (x86-64 only) | `r` |
| x86 | `reg_abcd` | `ax`, `bx`, `cx`, `dx` | `Q` |
| x86-32 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `ah`, `bh`, `ch`, `dh` | `q` |
| x86-64 | `reg_byte` | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `r[8-15]b`, `ah`\*, `bh`\*, `ch`\*, `dh`\* | `q` |
| x86-64 | `reg_byte`\* | `al`, `bl`, `cl`, `dl`, `sil`, `dil`, `r[8-15]b` | `q` |
| x86 | `xmm_reg` | `xmm[0-7]` (x86) `xmm[0-15]` (x86-64) | `x` |
| x86 | `ymm_reg` | `ymm[0-7]` (x86) `ymm[0-15]` (x86-64) | `x` |
| x86 | `zmm_reg` | `zmm[0-7]` (x86) `zmm[0-31]` (x86-64) | `v` |
Expand Down Expand Up @@ -532,7 +532,7 @@ Here is the list of currently supported register classes:

> **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.
>
> Note #2: On x86-64 the high byte registers (e.g. `ah`) are only available when used as an explicit register. Specifying the `reg_byte` register class for an operand will always allocate a low byte register.
> Note #2: On x86-64 the high byte registers (e.g. `ah`) are not available in the `reg_byte` register class.
>
> Note #3: NVPTX doesn't have a fixed register set, so named registers are not supported.
>
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ impl Options {
return Err(1);
}
if theme_file.extension() != Some(OsStr::new("css")) {
diag.struct_err(&format!("invalid argument: \"{}\"", theme_s)).emit();
diag.struct_err(&format!("invalid argument: \"{}\"", theme_s))
.help("arguments to --theme must have a .css extension")
.emit();
return Err(1);
}
let (success, ret) = theme::test_theme_against(&theme_file, &paths, &diag);
Expand Down
9 changes: 5 additions & 4 deletions src/test/assembly/asm/x86-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ check_reg!(eax_f64 f64 "eax" "mov");
// CHECK: #NO_APP
check_reg!(eax_ptr ptr "eax" "mov");

// CHECK-LABEL: ah_byte:
// CHECK: #APP
// CHECK: mov ah, ah
// CHECK: #NO_APP
// i686-LABEL: ah_byte:
// i686: #APP
// i686: mov ah, ah
// i686: #NO_APP
#[cfg(i686)]
check_reg!(ah_byte i8 "ah" "mov");

// CHECK-LABEL: xmm0_i32:
Expand Down
3 changes: 3 additions & 0 deletions src/test/rustdoc-ui/invalid-theme-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// compile-flags:--theme {{src-base}}/invalid-theme-name.rs
// error-pattern: invalid argument
// error-pattern: must have a .css extension
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/invalid-theme-name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
error: invalid argument: "$DIR/invalid-theme-name.rs"
|
= help: arguments to --theme must have a .css extension

2 changes: 2 additions & 0 deletions src/test/ui/asm/bad-reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ fn main() {
//~^ ERROR invalid register `mm0`: MMX registers are not currently supported as operands
asm!("", in("k0") foo);
//~^ ERROR invalid register `k0`: the k0 AVX mask register cannot be used as an operand
asm!("", in("ah") foo);
//~^ ERROR invalid register `ah`: high byte registers cannot be used as an operand

// Explicit register conflicts
// (except in/lateout which don't conflict)
Expand Down
20 changes: 13 additions & 7 deletions src/test/ui/asm/bad-reg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -94,49 +94,55 @@ error: invalid register `k0`: the k0 AVX mask register cannot be used as an oper
LL | asm!("", in("k0") foo);
| ^^^^^^^^^^^^

error: invalid register `ah`: high byte registers cannot be used as an operand on x86_64
--> $DIR/bad-reg.rs:40:18
|
LL | asm!("", in("ah") foo);
| ^^^^^^^^^^^^

error: register `al` conflicts with register `ax`
--> $DIR/bad-reg.rs:44:33
--> $DIR/bad-reg.rs:46:33
|
LL | asm!("", in("eax") foo, in("al") bar);
| ------------- ^^^^^^^^^^^^ register `al`
| |
| register `ax`

error: register `ax` conflicts with register `ax`
--> $DIR/bad-reg.rs:46:33
--> $DIR/bad-reg.rs:48:33
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ------------- ^^^^^^^^^^^^^^ register `ax`
| |
| register `ax`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:46:18
--> $DIR/bad-reg.rs:48:18
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ^^^^^^^^^^^^^

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:49:34
--> $DIR/bad-reg.rs:51:34
|
LL | asm!("", in("xmm0") foo, in("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:51:34
--> $DIR/bad-reg.rs:53:34
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:51:18
--> $DIR/bad-reg.rs:53:18
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| ^^^^^^^^^^^^^^

error: aborting due to 18 previous errors
error: aborting due to 19 previous errors

3 changes: 1 addition & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1909,8 +1909,7 @@ impl<'test> TestCx<'test> {
} else {
Command::new(&self.config.rustdoc_path.clone().expect("no rustdoc built yet"))
};
// FIXME Why is -L here?
rustc.arg(input_file); //.arg("-L").arg(&self.config.build_base);
rustc.arg(input_file);

// Use a single thread for efficiency and a deterministic error message order
rustc.arg("-Zthreads=1");
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub mod unstable_book;

fn filter_dirs(path: &Path) -> bool {
let skip = [
"tidy-test-file",
"compiler/rustc_codegen_cranelift",
"src/llvm-project",
"library/backtrace",
Expand Down
22 changes: 0 additions & 22 deletions src/tools/tidy/src/pal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,20 @@ const EXCEPTION_PATHS: &[&str] = &[
"library/panic_abort",
"library/panic_unwind",
"library/unwind",
// black_box implementation is LLVM-version specific and it uses
// target_os to tell targets with different LLVM-versions apart
// (e.g. `wasm32-unknown-emscripten` vs `wasm32-unknown-unknown`):
"library/core/src/hint.rs",
"library/std/src/sys/", // Platform-specific code for std lives here.
// This has the trailing slash so that sys_common is not excepted.
"library/std/src/os", // Platform-specific public interfaces
"library/rtstartup", // Not sure what to do about this. magic stuff for mingw
// temporary exceptions
"library/std/src/lib.rs",
"library/std/src/path.rs",
"library/std/src/f32.rs",
"library/std/src/f64.rs",
// Integration test for platform-specific run-time feature detection:
"library/std/tests/run-time-detect.rs",
"library/std/src/net/test.rs",
"library/std/src/net/addr",
"library/std/src/net/udp",
"library/std/src/sys_common/mod.rs",
"library/std/src/sys_common/net.rs",
"library/std/src/sys_common/backtrace.rs",
"library/std/src/sys_common/remutex.rs",
"library/std/src/sync/mutex.rs",
"library/std/src/sync/rwlock.rs",
// panic_unwind shims
"library/std/src/panicking.rs",
"library/term", // Not sure how to make this crate portable, but test crate needs it.
"library/test", // Probably should defer to unstable `std::sys` APIs.
"library/std/src/sync/mpsc", // some tests are only run on non-emscripten
// std testing crates, okay for now at least
"library/core/tests",
"library/alloc/tests/lib.rs",
Expand All @@ -79,13 +64,6 @@ const EXCEPTION_PATHS: &[&str] = &[
// we must use `#[cfg(windows)]` to conditionally compile the
// correct `VaList` structure for windows.
"library/core/src/ffi.rs",
// non-std crates
"src/test",
"src/tools",
"src/librustc",
"src/librustdoc",
"src/librustc_ast",
"src/bootstrap",
];

pub fn check(path: &Path, bad: &mut bool) {
Expand Down

0 comments on commit 5a7a0ac

Please sign in to comment.