1
Fork 0

Merge pull request #468 from GuillaumeGomez/sync

Sync Rust 2024-03-10
This commit is contained in:
antoyo 2024-03-10 18:57:50 -04:00 committed by GitHub
commit 47207949ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 69 additions and 62 deletions

View file

@ -1,6 +0,0 @@
// TODO: remove this file and deps/libLLVM-18-rust-1.78.0-nightly.so when
// https://github.com/rust-lang/rust/pull/121967 is merged.
fn main() {
println!("cargo:rerun-if-changed=deps/libLLVM-18-rust-1.78.0-nightly.so");
println!("cargo:rustc-link-search=deps");
}

View file

@ -107,6 +107,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests");
}
rustflags.push_str(" -Z force-unstable-if-unmarked");
if config.no_default_features {
rustflags.push_str(" -Csymbol-mangling-version=v0");
}
let mut env = env.clone();
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];

View file

@ -128,6 +128,7 @@ pub struct ConfigInfo {
// just to set the `gcc_path` field to display it.
pub no_download: bool,
pub no_default_features: bool,
pub backend: Option<String>,
}
impl ConfigInfo {
@ -178,6 +179,14 @@ impl ConfigInfo {
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
}
},
"--use-backend" => match args.next() {
Some(backend) if !backend.is_empty() => self.backend = Some(backend),
_ => {
return Err(
"Expected an argument after `--use-backend`, found nothing".into()
)
}
},
"--no-default-features" => self.no_default_features = true,
_ => return Ok(false),
}
@ -377,39 +386,27 @@ impl ConfigInfo {
"debug"
};
let has_builtin_backend = env
.get("BUILTIN_BACKEND")
.map(|backend| !backend.is_empty())
.unwrap_or(false);
let mut rustflags = Vec::new();
if has_builtin_backend {
// It means we're building inside the rustc testsuite, so some options need to be handled
// a bit differently.
self.cg_backend_path = "gcc".to_string();
match env.get("RUSTC_SYSROOT") {
Some(rustc_sysroot) if !rustc_sysroot.is_empty() => {
rustflags.extend_from_slice(&["--sysroot".to_string(), rustc_sysroot.clone()]);
}
_ => {}
}
// This should not be needed, but is necessary for the CI in the rust repository.
// FIXME: Remove when the rust CI switches to the master version of libgccjit.
rustflags.push("-Cpanic=abort".to_string());
self.cg_backend_path = current_dir
.join("target")
.join(channel)
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
.display()
.to_string();
self.sysroot_path = current_dir
.join("build_sysroot/sysroot")
.display()
.to_string();
if let Some(backend) = &self.backend {
// This option is only used in the rust compiler testsuite. The sysroot is handled
// by its build system directly so no need to set it ourselves.
rustflags.push(format!("-Zcodegen-backend={}", backend));
} else {
self.cg_backend_path = current_dir
.join("target")
.join(channel)
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
.display()
.to_string();
self.sysroot_path = current_dir
.join("build_sysroot/sysroot")
.display()
.to_string();
rustflags.extend_from_slice(&["--sysroot".to_string(), self.sysroot_path.clone()]);
};
rustflags.extend_from_slice(&[
"--sysroot".to_string(), self.sysroot_path.clone(),
format!("-Zcodegen-backend={}", self.cg_backend_path),
]);
}
// This environment variable is useful in case we want to change options of rustc commands.
if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") {
@ -427,10 +424,7 @@ impl ConfigInfo {
rustflags.push("-Csymbol-mangling-version=v0".to_string());
}
rustflags.extend_from_slice(&[
"-Cdebuginfo=2".to_string(),
format!("-Zcodegen-backend={}", self.cg_backend_path),
]);
rustflags.push("-Cdebuginfo=2".to_string());
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
// TODO(antoyo): remove when we can handle ThinLTO.
@ -454,9 +448,7 @@ impl ConfigInfo {
));
let ld_library_path = format!(
"{target}:{sysroot}:{gcc_path}",
// FIXME: It's possible to pick another out directory. Would be nice to have a command
// line option to change it.
target = current_dir.join("target/out").display(),
target = self.cargo_target_dir,
sysroot = sysroot.display(),
gcc_path = self.gcc_path,
);
@ -481,7 +473,7 @@ impl ConfigInfo {
self.rustc_command.extend_from_slice(&rustflags);
self.rustc_command.extend_from_slice(&[
"-L".to_string(),
"crate=target/out".to_string(),
format!("crate={}", self.cargo_target_dir),
"--out-dir".to_string(),
self.cargo_target_dir.clone(),
]);
@ -504,7 +496,8 @@ impl ConfigInfo {
--config-file : Location of the config file to be used
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
when ran from another directory)
--no-default-features : Add `--no-default-features` flag to cargo commands"
--no-default-features : Add `--no-default-features` flag to cargo commands
--use-backend : Useful only for rustc testsuite"
);
}
}

View file

@ -93,7 +93,6 @@ fn show_usage() {
--features [arg] : Add a new feature [arg]
--use-system-gcc : Use system installed libgccjit
--build-only : Only build rustc_codegen_gcc then exits
--use-backend : Useful only for rustc testsuite
--nb-parts : Used to split rustc_tests (for CI needs)
--current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
);
@ -113,7 +112,6 @@ struct TestArg {
use_system_gcc: bool,
runners: BTreeSet<String>,
flags: Vec<String>,
backend: Option<String>,
nb_parts: Option<usize>,
current_part: Option<usize>,
sysroot_panic_abort: bool,
@ -145,14 +143,6 @@ impl TestArg {
test_arg.use_system_gcc = true;
}
"--build-only" => test_arg.build_only = true,
"--use-backend" => match args.next() {
Some(backend) if !backend.is_empty() => test_arg.backend = Some(backend),
_ => {
return Err(
"Expected an argument after `--use-backend`, found nothing".into()
)
}
},
"--nb-parts" => {
test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?);
}
@ -199,7 +189,7 @@ impl TestArg {
}
fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
if args.backend.is_some() {
if args.config_info.backend.is_some() {
return Ok(());
}
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];

View file

@ -1 +0,0 @@
INPUT(libLLVM.so.18.1-rust-1.78.0-nightly)

View file

@ -472,6 +472,7 @@ pub trait Allocator {
impl Allocator for () {}
#[lang = "global_alloc_ty"]
pub struct Global;
impl Allocator for Global {}

View file

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2024-03-05"
channel = "nightly-2024-03-10"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

View file

@ -114,7 +114,8 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
options: InlineAsmOptions,
span: &[Span],
instance: Instance<'_>,
_dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>,
dest: Option<Self::BasicBlock>,
_dest_catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
) {
if options.contains(InlineAsmOptions::MAY_UNWIND) {
self.sess().dcx().create_err(UnwindingInlineAsm { span: span[0] }).emit();
@ -132,6 +133,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// added to `outputs.len()`
let mut inputs = vec![];
// GCC index of a label equals its position in the array added to
// `outputs.len() + inputs.len()`.
let mut labels = vec![];
// Clobbers collected from `out("explicit register") _` and `inout("expl_reg") var => _`
let mut clobbers = vec![];
@ -283,6 +288,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
constants_len +=
self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name.len();
}
InlineAsmOperandRef::Label { label } => {
labels.push(label);
}
}
}
@ -381,6 +390,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
InlineAsmOperandRef::Const { .. } => {
// processed in the previous pass
}
InlineAsmOperandRef::Label { .. } => {
// processed in the previous pass
}
}
}
@ -470,6 +483,13 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
InlineAsmOperandRef::Const { ref string } => {
template_str.push_str(string);
}
InlineAsmOperandRef::Label { label } => {
let label_gcc_index =
labels.iter().position(|&l| l == label).expect("wrong rust index");
let gcc_index = label_gcc_index + outputs.len() + inputs.len();
push_to_template(Some('l'), gcc_index);
}
}
}
}
@ -482,7 +502,12 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
// 4. Generate Extended Asm block
let block = self.llbb();
let extended_asm = block.add_extended_asm(None, &template_str);
let extended_asm = if let Some(dest) = dest {
assert!(!labels.is_empty());
block.end_with_extended_asm_goto(None, &template_str, &labels, Some(dest))
} else {
block.add_extended_asm(None, &template_str)
};
for op in &outputs {
extended_asm.add_output_operand(None, &op.to_constraint(), op.tmp_var);
@ -510,7 +535,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
if !options.contains(InlineAsmOptions::NOSTACK) {
// TODO(@Commeownist): figure out how to align stack
}
if options.contains(InlineAsmOptions::NORETURN) {
if dest.is_none() && options.contains(InlineAsmOptions::NORETURN) {
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
let builtin_unreachable: RValue<'gcc> =
unsafe { std::mem::transmute(builtin_unreachable) };

View file

@ -74,3 +74,5 @@ tests/ui/simd/repr_packed.rs
tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
tests/ui/consts/try-operator.rs
tests/ui/coroutine/unwind-abort-mix.rs
tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs
tests/ui/impl-trait/equality-in-canonical-query.rs