mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When building complex projects, there may cases of static libraries which expose `@inlinable` functions which reference functions from dynamically linked dependencies. In such a case, we need to consider the provenance of the `function_ref` when determining the DLL storage for linkage. We would previously use the deserialised metadata on the `SILFunction` as there are entities where the `DeclContext` may not be deserialised. However, this leaves us in a state where we are unable to determine the actual provenance correctly in some cases. By simply accessing the parent module directly from the `SILFunction` we ensure that we properly identify the origin of the function allowing us to query the DLL storage property. This further allows us to remove the extra storage required for whether the `SILFunction` is statically linked.
24 lines
708 B
Swift
24 lines
708 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file --leading-lines %s %t
|
|
|
|
// REQUIRES: OS=windows-msvc
|
|
|
|
// RUN: %target-swiftc_driver -emit-module -emit-module-path %t/swift/dynamic.swiftmodule -I %t/swift %t/dynamic.swift
|
|
// RUN: %target-swiftc_driver -static -emit-module -emit-module-path %t/swift/static.swiftmodule -I %t/swift %t/static.swift
|
|
// RUN: %target-swiftc_driver -O -emit-ir -I %t/swift %t/library.swift | %FileCheck %s
|
|
|
|
// CHECK: declare dllimport swiftcc i{{[0-9]+}} @"$s7dynamic1fSiyF"()
|
|
|
|
//--- dynamic.swift
|
|
public func f() -> Int { 32 }
|
|
|
|
//--- static.swift
|
|
import dynamic
|
|
|
|
@inlinable
|
|
public func g() -> Int { f() + 1 }
|
|
|
|
//--- library.swift
|
|
import `static`
|
|
public func h() -> Int { g() + 1 }
|