Files
swift-mirror/test/IRGen/ELF-remove-autolink-section.swift
Alastair Houghton 3c029ebd3f [IRGen] Use llvm.used on ELF instead of llvm.compiler.used.
We changed to `llvm.compiler.used` because of the behaviour of `gold`,
which refuses to coalesce sections that have different `SHF_GNU_RETAIN`
flags, which causes problems with metadata.

Originally I thought we were going to have to generate two sections
with distinct names and have the runtime look for both of them, but
it turns out that the runtime only wants to see sections that have
`SHF_GNU_RETAIN` in any case.  It's really the reflection code that
is interested in being able to see non-retained sections.  The upshot
is that we don't need to use `llvm.compiler.used`; it's just fine if
we have duplicate sections, as long as the reflection code looks for
them when it's inspecting an ELF image.

This also means we no longer need to pass `-z nostart-stop-gc` to the
linker if we're using `lld`.

rdar://123504095
2024-04-29 10:48:22 +01:00

19 lines
862 B
Swift

// RUN: %swiftc_driver -emit-ir %s -o - -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import | %FileCheck %s -check-prefix ELF
// Check that the swift auto link section is available in the object file.
// RUN: %swiftc_driver -c %s -o %t -Xfrontend -disable-implicit-concurrency-module-import
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix SECTION
// Checks that the swift auto link section is removed from the final binary.
// RUN: %swiftc_driver -emit-executable %s -o %t -Xfrontend -disable-implicit-concurrency-module-import
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix NOSECTION
// REQUIRES: OS=linux-gnu
print("Hi from Swift!")
// ELF: @llvm.used = {{.*}}ptr @_swift1_autolink_entries
// SECTION: .swift1_autolink_entries
// NOSECTION-NOT: .swift1_autolink_entries