Skip to content

Commit

Permalink
Auto merge of rust-lang#93836 - matthiaskrgr:rollup-d1ssiwl, r=matthi…
Browse files Browse the repository at this point in the history
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#91443 (Better suggestions when user tries to collect into an unsized `[_]`)
 - rust-lang#91504 (`#[used(linker)]` attribute)
 - rust-lang#93503 (debuginfo: Fix DW_AT_containing_type vtable debuginfo regression)
 - rust-lang#93753 (Complete removal of #[main] attribute from compiler)
 - rust-lang#93799 (Fix typo in `std::fmt` docs)
 - rust-lang#93813 (Make a few cleanup MIR passes public)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Feb 10, 2022
2 parents e7aca89 + 3238806 commit 5d6ee0d
Show file tree
Hide file tree
Showing 30 changed files with 544 additions and 84 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<'gcc, 'tcx> StaticMethods for CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): set link section.
}

if attrs.flags.contains(CodegenFnAttrFlags::USED) {
if attrs.flags.contains(CodegenFnAttrFlags::USED) || attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {
self.add_used_global(global.to_rvalue());
}
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
}

if attrs.flags.contains(CodegenFnAttrFlags::USED) {
// `USED` and `USED_LINKER` can't be used together.
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER));

// The semantics of #[used] in Rust only require the symbol to make it into the
// object file. It is explicitly allowed for the linker to strip the symbol if it
// is dead. As such, use llvm.compiler.used instead of llvm.used.
Expand All @@ -530,6 +533,12 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
// in some versions of the gold linker.
self.add_compiler_used_global(g);
}
if attrs.flags.contains(CodegenFnAttrFlags::USED_LINKER) {
// `USED` and `USED_LINKER` can't be used together.
assert!(!attrs.flags.contains(CodegenFnAttrFlags::USED));

self.add_used_global(g);
}
}
}

Expand Down
Loading

0 comments on commit 5d6ee0d

Please sign in to comment.