Skip to content

Commit 5d6ee0d

Browse files
committed
Auto merge of #93836 - matthiaskrgr:rollup-d1ssiwl, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #91443 (Better suggestions when user tries to collect into an unsized `[_]`) - #91504 (`#[used(linker)]` attribute) - #93503 (debuginfo: Fix DW_AT_containing_type vtable debuginfo regression) - #93753 (Complete removal of #[main] attribute from compiler) - #93799 (Fix typo in `std::fmt` docs) - #93813 (Make a few cleanup MIR passes public) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e7aca89 + 3238806 commit 5d6ee0d

File tree

30 files changed

+544
-84
lines changed

30 files changed

+544
-84
lines changed

compiler/rustc_codegen_gcc/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
144144
// TODO(antoyo): set link section.
145145
}
146146

147-
if attrs.flags.contains(CodegenFnAttrFlags::USED) {
147+
if attrs.flags.contains(CodegenFnAttrFlags::USED) || attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {
148148
self.add_used_global(global.to_rvalue());
149149
}
150150
}

compiler/rustc_codegen_llvm/src/consts.rs

+9
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
522522
}
523523

524524
if attrs.flags.contains(CodegenFnAttrFlags::USED) {
525+
// `USED` and `USED_LINKER` can't be used together.
526+
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));
527+
525528
// The semantics of #[used] in Rust only require the symbol to make it into the
526529
// object file. It is explicitly allowed for the linker to strip the symbol if it
527530
// is dead. As such, use llvm.compiler.used instead of llvm.used.
@@ -530,6 +533,12 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
530533
// in some versions of the gold linker.
531534
self.add_compiler_used_global(g);
532535
}
536+
if attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {
537+
// `USED` and `USED_LINKER` can't be used together.
538+
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED));
539+
540+
self.add_used_global(g);
541+
}
533542
}
534543
}
535544

0 commit comments

Comments
 (0)