Skip to content

Conversation

@DougGregor
Copy link
Member

@_extern(c) is meant for referencing C functions defined outside of this Swift file. Instead of using the C function name as the SIL function name, which is prone to collisions across different Swift modules, place make the C function name the "asmname" of the corresponding SIL function. Show that this prevents deserialization errors when there are conflicting Swift-level types for the same @_extern(c)-named symbol across modules.

Part of rdar://137014448.

The asmname attribute allows one to specify the name that will be used
when lowering a given SIL declaration to LLVM IR. It is not currently
exposed in the surface language.

Make sure this attribute round-trips through the parser and
serialization.

Part of rdar://137014448O.
… a SIL function

`@_extern(c)` is meant for referencing C functions defined outside of
this Swift file. Instead of using the C function name as the SIL
function name, which is prone to collisions across different Swift
modules, place make the C function name the "asmname" of the
corresponding SIL function. Show that this prevents deserialization
errors when there are conflicting Swift-level types for the same
`@_extern(c)`-named symbol across modules.

Part of rdar://137014448.
Instead of using the C name as the mangled name of a SIL function
@DougGregor
Copy link
Member Author

Only the last commit is new; this is sitting on top of #84939.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor enabled auto-merge October 16, 2025 20:00
@DougGregor
Copy link
Member Author

@swift-ci please smoke test Windows

@DougGregor DougGregor merged commit 39a36d9 into swiftlang:main Oct 17, 2025
3 checks passed
@DougGregor DougGregor deleted the extern-c-asmname branch October 17, 2025 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant