Merge from rustc

This commit is contained in:
Ralf Jung 2024-05-16 10:40:15 +02:00
commit 0334bf8520
138 changed files with 2310 additions and 1057 deletions

View file

@ -2478,6 +2478,15 @@ impl<'test> TestCx<'test> {
}
}
let set_mir_dump_dir = |rustc: &mut Command| {
let mir_dump_dir = self.get_mir_dump_dir();
remove_and_create_dir_all(&mir_dump_dir);
let mut dir_opt = "-Zdump-mir-dir=".to_string();
dir_opt.push_str(mir_dump_dir.to_str().unwrap());
debug!("dir_opt: {:?}", dir_opt);
rustc.arg(dir_opt);
};
match self.config.mode {
Incremental => {
// If we are extracting and matching errors in the new
@ -2532,13 +2541,7 @@ impl<'test> TestCx<'test> {
]);
}
let mir_dump_dir = self.get_mir_dump_dir();
remove_and_create_dir_all(&mir_dump_dir);
let mut dir_opt = "-Zdump-mir-dir=".to_string();
dir_opt.push_str(mir_dump_dir.to_str().unwrap());
debug!("dir_opt: {:?}", dir_opt);
rustc.arg(dir_opt);
set_mir_dump_dir(&mut rustc);
}
CoverageMap => {
rustc.arg("-Cinstrument-coverage");
@ -2560,8 +2563,11 @@ impl<'test> TestCx<'test> {
Assembly | Codegen => {
rustc.arg("-Cdebug-assertions=no");
}
Crashes => {
set_mir_dump_dir(&mut rustc);
}
RunPassValgrind | Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake
| CodegenUnits | JsDocTest | Crashes => {
| CodegenUnits | JsDocTest => {
// do not use JSON output
}
}

View file

@ -69,6 +69,10 @@ enum EnvironmentCmd {
#[arg(long, default_value = "opt-artifacts")]
artifact_dir: Utf8PathBuf,
/// Checkout directory of `rustc-perf`, it will be fetched automatically if unspecified.
#[arg(long)]
rustc_perf_checkout_dir: Option<Utf8PathBuf>,
/// Is LLVM for `rustc` built in shared library mode?
#[arg(long, default_value_t = true)]
llvm_shared: bool,
@ -109,6 +113,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
llvm_dir,
python,
artifact_dir,
rustc_perf_checkout_dir,
llvm_shared,
use_bolt,
skipped_tests,
@ -121,6 +126,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
.host_llvm_dir(llvm_dir)
.artifact_dir(artifact_dir)
.build_dir(checkout_dir)
.prebuilt_rustc_perf(rustc_perf_checkout_dir)
.shared_llvm(llvm_shared)
.use_bolt(use_bolt)
.skipped_tests(skipped_tests)

View file

@ -40,12 +40,17 @@ pub fn target() -> String {
/// Check if target is windows-like.
pub fn is_windows() -> bool {
env::var_os("IS_WINDOWS").is_some()
target().contains("windows")
}
/// Check if target uses msvc.
pub fn is_msvc() -> bool {
env::var_os("IS_MSVC").is_some()
target().contains("msvc")
}
/// Check if target uses macOS.
pub fn is_darwin() -> bool {
target().contains("darwin")
}
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
@ -59,6 +64,12 @@ pub fn python_command() -> Command {
Command::new(python_path)
}
pub fn htmldocck() -> Command {
let mut python = python_command();
python.arg(source_path().join("src/etc/htmldocck.py"));
python
}
pub fn source_path() -> PathBuf {
std::env::var("S").expect("S variable does not exist").into()
}
@ -82,9 +93,47 @@ pub fn static_lib_name(name: &str) -> String {
// endif
// endif
// ```
assert!(!name.contains(char::is_whitespace), "name cannot contain whitespace");
assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");
if target().contains("msvc") { format!("{name}.lib") } else { format!("lib{name}.a") }
if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
}
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
pub fn dynamic_lib(name: &str) -> PathBuf {
tmp_dir().join(dynamic_lib_name(name))
}
/// Construct the dynamic library name based on the platform.
pub fn dynamic_lib_name(name: &str) -> String {
// See tools.mk (irrelevant lines omitted):
//
// ```makefile
// ifeq ($(UNAME),Darwin)
// DYLIB = $(TMPDIR)/lib$(1).dylib
// else
// ifdef IS_WINDOWS
// DYLIB = $(TMPDIR)/$(1).dll
// else
// DYLIB = $(TMPDIR)/lib$(1).so
// endif
// endif
// ```
assert!(!name.contains(char::is_whitespace), "dynamic library name cannot contain whitespace");
if is_darwin() {
format!("lib{name}.dylib")
} else if is_windows() {
format!("{name}.dll")
} else {
format!("lib{name}.so")
}
}
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
/// path with `$TMPDIR` joined with the library name.
pub fn rust_lib(name: &str) -> PathBuf {
tmp_dir().join(format!("lib{name}.rlib"))
}
/// Construct the binary name based on platform.

View file

@ -91,7 +91,7 @@ impl Rustc {
self
}
/// Specify path to the output file.
/// Specify path to the output file. Equivalent to `-o`` in rustc.
pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-o");
self.cmd.arg(path.as_ref());
@ -150,6 +150,13 @@ impl Rustc {
self
}
/// Add a directory to the library search path. Equivalent to `-L`` in rustc.
pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg("-L");
self.cmd.arg(path.as_ref());
self
}
/// Specify the edition year.
pub fn edition(&mut self, edition: &str) -> &mut Self {
self.cmd.arg("--edition");

View file

@ -739,8 +739,8 @@ impl<'a> FmtVisitor<'a> {
(_, Const(..)) => Ordering::Greater,
(MacCall(..), _) => Ordering::Less,
(_, MacCall(..)) => Ordering::Greater,
(Delegation(..), _) => Ordering::Less,
(_, Delegation(..)) => Ordering::Greater,
(Delegation(..), _) | (DelegationMac(..), _) => Ordering::Less,
(_, Delegation(..)) | (_, DelegationMac(..)) => Ordering::Greater,
});
let mut prev_kind = None;
for (buf, item) in buffer {

View file

@ -586,7 +586,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
);
self.push_rewrite(item.span, rewrite);
}
ast::ItemKind::Delegation(..) => {
ast::ItemKind::Delegation(..) | ast::ItemKind::DelegationMac(..) => {
// TODO: rewrite delegation items once syntax is established.
// For now, leave the contents of the Span unformatted.
self.push_rewrite(item.span, None)

View file

@ -8,7 +8,6 @@ run-make/branch-protection-check-IBT/Makefile
run-make/c-dynamic-dylib/Makefile
run-make/c-dynamic-rlib/Makefile
run-make/c-link-to-rust-dylib/Makefile
run-make/c-link-to-rust-staticlib/Makefile
run-make/c-static-dylib/Makefile
run-make/c-static-rlib/Makefile
run-make/c-unwind-abi-catch-lib-panic/Makefile
@ -94,8 +93,6 @@ run-make/invalid-staticlib/Makefile
run-make/issue-107094/Makefile
run-make/issue-10971-temps-dir/Makefile
run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-11908/Makefile
run-make/issue-14500/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/Makefile
run-make/issue-18943/Makefile
@ -181,7 +178,6 @@ run-make/native-link-modifier-whole-archive/Makefile
run-make/no-alloc-shim/Makefile
run-make/no-builtins-attribute/Makefile
run-make/no-builtins-lto/Makefile
run-make/no-cdylib-as-rdylib/Makefile
run-make/no-duplicate-libs/Makefile
run-make/no-intermediate-extras/Makefile
run-make/obey-crate-type-flag/Makefile
@ -194,7 +190,6 @@ run-make/output-with-hyphens/Makefile
run-make/override-aliased-flags/Makefile
run-make/overwrite-input/Makefile
run-make/panic-abort-eh_frame/Makefile
run-make/panic-impl-transitive/Makefile
run-make/pass-linker-flags-flavor/Makefile
run-make/pass-linker-flags-from-dep/Makefile
run-make/pass-linker-flags/Makefile
@ -247,9 +242,7 @@ run-make/rustdoc-scrape-examples-multiple/Makefile
run-make/rustdoc-scrape-examples-remap/Makefile
run-make/rustdoc-scrape-examples-test/Makefile
run-make/rustdoc-scrape-examples-whitespace/Makefile
run-make/rustdoc-themes/Makefile
run-make/rustdoc-verify-output-files/Makefile
run-make/rustdoc-with-out-dir-option/Makefile
run-make/rustdoc-with-output-option/Makefile
run-make/rustdoc-with-short-out-dir-option/Makefile
run-make/sanitizer-cdylib-link/Makefile