@@ -543,33 +543,13 @@ impl<'ll> StaticMethods for CodegenCx<'ll, '_> {
543
543
// in the handling of `.init_array` (the static constructor list) in versions of
544
544
// the gold linker (prior to the one released with binutils 2.36).
545
545
//
546
- // However, unconditional use of `llvm.compiler.used` caused a nontrivial amount of
547
- // ecosystem breakage, especially on Mach-O targets. To resolve this, we compile it
548
- // as llvm.compiler.used on ELF targets and llvm.used elsewhere, which should be
549
- // equivalent to how we compiled `#[used]` before LLVM 13, as `llvm.used` and
550
- // `llvm.compiler.used` were treated the same on ELF targets prior in earlier LLVM
551
- // versions (additionally, it seems to be how Clang handles `__attribute__((used))`,
552
- // perhaps for similar compatibility-motivated reasons).
553
- //
554
- // See https://github.com/rust-lang/rust/issues/47384#issuecomment-1019080146 and
555
- // following comments for some discussion of this.
556
- //
557
- // The final wrinkle is it's not really clear how to tell if we're going to output
558
- // ELF, so it's been approximated as "not like wasm, osx, or windows", which is
559
- // not exactly correct, but is pretty close and hopefully handles all the platforms
560
- // platforms where old versions of `ld.gold` are likely to show up.
561
- //
562
- // All this is subject to change in the future. Which is a good thing, because this
563
- // probably should be firmed up somehow!
564
- let seems_like_elf = !( self . tcx . sess . target . is_like_osx
565
- || self . tcx . sess . target . is_like_windows
566
- || self . tcx . sess . target . is_like_wasm ) ;
567
-
568
- if seems_like_elf {
569
- self . add_compiler_used_global ( g) ;
570
- } else {
571
- self . add_used_global ( g) ;
572
- }
546
+ // That said, we only ever emit these when compiling for ELF targets, unless
547
+ // `#[used(compiler)]` is explicitly requested. This is to avoid similar breakage
548
+ // on other targets, in particular MachO targets have *their* static constructor
549
+ // lists broken if `llvm.compiler.used` is emitted rather than llvm.used. However,
550
+ // that check happens when assigning the `CodegenFnAttrFlags` in `rustc_typeck`,
551
+ // so we don't need to take care of it here.
552
+ self . add_compiler_used_global ( g) ;
573
553
}
574
554
if attrs. flags . contains ( CodegenFnAttrFlags :: USED_LINKER ) {
575
555
// `USED` and `USED_LINKER` can't be used together.
0 commit comments