Files
swift-mirror/test/embedded/specialize-opt-none.swift
Doug Gregor 9a20ebac5b [Embedded] Emit weak definitions for imported symbols
When Embedded Swift emits a symbol that was imported from another
module, ensure that the symbol is emitted as a weak definition. This
way, importing the same module (and using its symbol) into several
different modules doesn't cause duplicate-symbol errors at link time.
Rather, the linker will merge the different symbol definitions. This
makes Embedded Swift libraries work without resorting to
`-mergeable-symbols` or `-emit-empty-object-file`.
2025-08-17 15:26:08 -07:00

23 lines
672 B
Swift

// RUN: %target-swift-emit-sil %s -parse-stdlib -O | %FileCheck %s
// RUN: %target-swift-emit-sil %s -parse-stdlib -O -enable-experimental-feature Embedded | %FileCheck %s --check-prefix EMBEDDED
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded
struct X {}
struct MyStruct<T> {
@_optimize(none)
public func foo() {}
}
public func test() {
MyStruct<X>().foo()
}
// CHECK: MyStruct.foo()
// CHECK: sil hidden [Onone] @$s4main8MyStructV3fooyyF : $@convention(method) <T> (MyStruct<T>) -> () {
// EMBEDDED: // specialized MyStruct.foo()
// EMBEDDED: sil shared [Onone] @$e4main8MyStructV3fooyyFAA1XV_Tg5 : $@convention(method) (MyStruct<X>) -> () {