Skip to content

Commit 4720794

Browse files
authored
Merge pull request #468 from GuillaumeGomez/sync
Sync Rust 2024-03-10
2 parents b385428 + ca883bd commit 4720794

File tree

9 files changed

+69
-62
lines changed

9 files changed

+69
-62
lines changed

build.rs

-6
This file was deleted.

build_system/src/build.rs

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ pub fn build_sysroot(env: &HashMap<String, String>, config: &ConfigInfo) -> Resu
107107
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests");
108108
}
109109
rustflags.push_str(" -Z force-unstable-if-unmarked");
110+
if config.no_default_features {
111+
rustflags.push_str(" -Csymbol-mangling-version=v0");
112+
}
110113
let mut env = env.clone();
111114

112115
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"build", &"--target", &config.target];

build_system/src/config.rs

+33-40
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ pub struct ConfigInfo {
128128
// just to set the `gcc_path` field to display it.
129129
pub no_download: bool,
130130
pub no_default_features: bool,
131+
pub backend: Option<String>,
131132
}
132133

133134
impl ConfigInfo {
@@ -178,6 +179,14 @@ impl ConfigInfo {
178179
return Err("Expected a value after `--cg_gcc-path`, found nothing".to_string())
179180
}
180181
},
182+
"--use-backend" => match args.next() {
183+
Some(backend) if !backend.is_empty() => self.backend = Some(backend),
184+
_ => {
185+
return Err(
186+
"Expected an argument after `--use-backend`, found nothing".into()
187+
)
188+
}
189+
},
181190
"--no-default-features" => self.no_default_features = true,
182191
_ => return Ok(false),
183192
}
@@ -377,39 +386,27 @@ impl ConfigInfo {
377386
"debug"
378387
};
379388

380-
let has_builtin_backend = env
381-
.get("BUILTIN_BACKEND")
382-
.map(|backend| !backend.is_empty())
383-
.unwrap_or(false);
384-
385389
let mut rustflags = Vec::new();
386-
if has_builtin_backend {
387-
// It means we're building inside the rustc testsuite, so some options need to be handled
388-
// a bit differently.
389-
self.cg_backend_path = "gcc".to_string();
390-
391-
match env.get("RUSTC_SYSROOT") {
392-
Some(rustc_sysroot) if !rustc_sysroot.is_empty() => {
393-
rustflags.extend_from_slice(&["--sysroot".to_string(), rustc_sysroot.clone()]);
394-
}
395-
_ => {}
396-
}
397-
// This should not be needed, but is necessary for the CI in the rust repository.
398-
// FIXME: Remove when the rust CI switches to the master version of libgccjit.
399-
rustflags.push("-Cpanic=abort".to_string());
390+
self.cg_backend_path = current_dir
391+
.join("target")
392+
.join(channel)
393+
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
394+
.display()
395+
.to_string();
396+
self.sysroot_path = current_dir
397+
.join("build_sysroot/sysroot")
398+
.display()
399+
.to_string();
400+
if let Some(backend) = &self.backend {
401+
// This option is only used in the rust compiler testsuite. The sysroot is handled
402+
// by its build system directly so no need to set it ourselves.
403+
rustflags.push(format!("-Zcodegen-backend={}", backend));
400404
} else {
401-
self.cg_backend_path = current_dir
402-
.join("target")
403-
.join(channel)
404-
.join(&format!("librustc_codegen_gcc.{}", self.dylib_ext))
405-
.display()
406-
.to_string();
407-
self.sysroot_path = current_dir
408-
.join("build_sysroot/sysroot")
409-
.display()
410-
.to_string();
411-
rustflags.extend_from_slice(&["--sysroot".to_string(), self.sysroot_path.clone()]);
412-
};
405+
rustflags.extend_from_slice(&[
406+
"--sysroot".to_string(), self.sysroot_path.clone(),
407+
format!("-Zcodegen-backend={}", self.cg_backend_path),
408+
]);
409+
}
413410

414411
// This environment variable is useful in case we want to change options of rustc commands.
415412
if let Some(cg_rustflags) = env.get("CG_RUSTFLAGS") {
@@ -427,10 +424,7 @@ impl ConfigInfo {
427424
rustflags.push("-Csymbol-mangling-version=v0".to_string());
428425
}
429426

430-
rustflags.extend_from_slice(&[
431-
"-Cdebuginfo=2".to_string(),
432-
format!("-Zcodegen-backend={}", self.cg_backend_path),
433-
]);
427+
rustflags.push("-Cdebuginfo=2".to_string());
434428

435429
// Since we don't support ThinLTO, disable LTO completely when not trying to do LTO.
436430
// TODO(antoyo): remove when we can handle ThinLTO.
@@ -454,9 +448,7 @@ impl ConfigInfo {
454448
));
455449
let ld_library_path = format!(
456450
"{target}:{sysroot}:{gcc_path}",
457-
// FIXME: It's possible to pick another out directory. Would be nice to have a command
458-
// line option to change it.
459-
target = current_dir.join("target/out").display(),
451+
target = self.cargo_target_dir,
460452
sysroot = sysroot.display(),
461453
gcc_path = self.gcc_path,
462454
);
@@ -481,7 +473,7 @@ impl ConfigInfo {
481473
self.rustc_command.extend_from_slice(&rustflags);
482474
self.rustc_command.extend_from_slice(&[
483475
"-L".to_string(),
484-
"crate=target/out".to_string(),
476+
format!("crate={}", self.cargo_target_dir),
485477
"--out-dir".to_string(),
486478
self.cargo_target_dir.clone(),
487479
]);
@@ -504,7 +496,8 @@ impl ConfigInfo {
504496
--config-file : Location of the config file to be used
505497
--cg_gcc-path : Location of the rustc_codegen_gcc root folder (used
506498
when ran from another directory)
507-
--no-default-features : Add `--no-default-features` flag to cargo commands"
499+
--no-default-features : Add `--no-default-features` flag to cargo commands
500+
--use-backend : Useful only for rustc testsuite"
508501
);
509502
}
510503
}

build_system/src/test.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ fn show_usage() {
9393
--features [arg] : Add a new feature [arg]
9494
--use-system-gcc : Use system installed libgccjit
9595
--build-only : Only build rustc_codegen_gcc then exits
96-
--use-backend : Useful only for rustc testsuite
9796
--nb-parts : Used to split rustc_tests (for CI needs)
9897
--current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
9998
);
@@ -113,7 +112,6 @@ struct TestArg {
113112
use_system_gcc: bool,
114113
runners: BTreeSet<String>,
115114
flags: Vec<String>,
116-
backend: Option<String>,
117115
nb_parts: Option<usize>,
118116
current_part: Option<usize>,
119117
sysroot_panic_abort: bool,
@@ -145,14 +143,6 @@ impl TestArg {
145143
test_arg.use_system_gcc = true;
146144
}
147145
"--build-only" => test_arg.build_only = true,
148-
"--use-backend" => match args.next() {
149-
Some(backend) if !backend.is_empty() => test_arg.backend = Some(backend),
150-
_ => {
151-
return Err(
152-
"Expected an argument after `--use-backend`, found nothing".into()
153-
)
154-
}
155-
},
156146
"--nb-parts" => {
157147
test_arg.nb_parts = Some(get_number_after_arg(&mut args, "--nb-parts")?);
158148
}
@@ -199,7 +189,7 @@ impl TestArg {
199189
}
200190

201191
fn build_if_no_backend(env: &Env, args: &TestArg) -> Result<(), String> {
202-
if args.backend.is_some() {
192+
if args.config_info.backend.is_some() {
203193
return Ok(());
204194
}
205195
let mut command: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"rustc"];

deps/libLLVM-18-rust-1.78.0-nightly.so

-1
This file was deleted.

example/mini_core.rs

+1
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ pub trait Allocator {
472472

473473
impl Allocator for () {}
474474

475+
#[lang = "global_alloc_ty"]
475476
pub struct Global;
476477

477478
impl Allocator for Global {}

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2024-03-05"
2+
channel = "nightly-2024-03-10"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/asm.rs

+28-3
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
114114
options: InlineAsmOptions,
115115
span: &[Span],
116116
instance: Instance<'_>,
117-
_dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>,
117+
dest: Option<Self::BasicBlock>,
118+
_dest_catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
118119
) {
119120
if options.contains(InlineAsmOptions::MAY_UNWIND) {
120121
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> {
132133
// added to `outputs.len()`
133134
let mut inputs = vec![];
134135

136+
// GCC index of a label equals its position in the array added to
137+
// `outputs.len() + inputs.len()`.
138+
let mut labels = vec![];
139+
135140
// Clobbers collected from `out("explicit register") _` and `inout("expl_reg") var => _`
136141
let mut clobbers = vec![];
137142

@@ -283,6 +288,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
283288
constants_len +=
284289
self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name.len();
285290
}
291+
292+
InlineAsmOperandRef::Label { label } => {
293+
labels.push(label);
294+
}
286295
}
287296
}
288297

@@ -381,6 +390,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
381390
InlineAsmOperandRef::Const { .. } => {
382391
// processed in the previous pass
383392
}
393+
394+
InlineAsmOperandRef::Label { .. } => {
395+
// processed in the previous pass
396+
}
384397
}
385398
}
386399

@@ -470,6 +483,13 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
470483
InlineAsmOperandRef::Const { ref string } => {
471484
template_str.push_str(string);
472485
}
486+
487+
InlineAsmOperandRef::Label { label } => {
488+
let label_gcc_index =
489+
labels.iter().position(|&l| l == label).expect("wrong rust index");
490+
let gcc_index = label_gcc_index + outputs.len() + inputs.len();
491+
push_to_template(Some('l'), gcc_index);
492+
}
473493
}
474494
}
475495
}
@@ -482,7 +502,12 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
482502
// 4. Generate Extended Asm block
483503

484504
let block = self.llbb();
485-
let extended_asm = block.add_extended_asm(None, &template_str);
505+
let extended_asm = if let Some(dest) = dest {
506+
assert!(!labels.is_empty());
507+
block.end_with_extended_asm_goto(None, &template_str, &labels, Some(dest))
508+
} else {
509+
block.add_extended_asm(None, &template_str)
510+
};
486511

487512
for op in &outputs {
488513
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> {
510535
if !options.contains(InlineAsmOptions::NOSTACK) {
511536
// TODO(@Commeownist): figure out how to align stack
512537
}
513-
if options.contains(InlineAsmOptions::NORETURN) {
538+
if dest.is_none() && options.contains(InlineAsmOptions::NORETURN) {
514539
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
515540
let builtin_unreachable: RValue<'gcc> =
516541
unsafe { std::mem::transmute(builtin_unreachable) };

tests/failing-ui-tests.txt

+2
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,5 @@ tests/ui/simd/repr_packed.rs
7474
tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
7575
tests/ui/consts/try-operator.rs
7676
tests/ui/coroutine/unwind-abort-mix.rs
77+
tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs
78+
tests/ui/impl-trait/equality-in-canonical-query.rs

0 commit comments

Comments
 (0)