Skip to content

runtime: add missing SWIFT_CC(swift) for matching function signatures #67644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

MaxDesiatov
Copy link
Contributor

test/stdlib/Runtime.swift.gyb makes a call to this function with Swift calling convention, but the function is declared with C calling convention, which makes the compiled code invalid when targeting Wasm due to caller/callee signature mismatch.

As @_cdecl doesn't support function declaration without a body on the Swift side, the only possible fix right now is to add the calling convention attribute on the C++ side.

`test/stdlib/Runtime.swift.gyb` makes a call to this function with Swift calling convention, but the function is declared with C calling convention, which makes the compiled code invalid when targeting Wasm due to caller/callee signature mismatch.

As `@_cdecl` doesn't support function declaration without a body on the Swift side, the only possible fix right now is to add the calling convention attribute on the C++ side.
@MaxDesiatov MaxDesiatov added standard library Area: Standard library umbrella mangling Area → compiler: Mangling labels Aug 1, 2023
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci build toolchain

@MaxDesiatov
Copy link
Contributor Author

preset=buildbot_incremental_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@MaxDesiatov MaxDesiatov changed the title runtime: add missing SWIFT_CC(swift) on swift_demangle runtime: add missing SWIFT_CC(swift) for matching function signatures Aug 1, 2023
…match

`ContiguousArrayBuffer.swift` calls `swift_COWChecksEnabled` with Swift CC, but the functions is defined with C CC.
These functions are called throughout the codebase with `@_silgen_name`, which uses Swift calling convention, while they are actually defined with C calling convention.
@MaxDesiatov
Copy link
Contributor Author

@swift-ci build toolchain

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

preset=buildbot_incremental_linux_crosscompile_wasm
@swift-ci Please test with preset Linux Platform

@Azoy
Copy link
Contributor

Azoy commented Aug 1, 2023

cc @jckarter these are ABI breaks but not sure what the scope of these functions are

@MaxDesiatov MaxDesiatov requested a review from jckarter August 1, 2023 15:54
@MaxDesiatov
Copy link
Contributor Author

Per a discussion with @al45tair maybe adding support for functions without bodies for @_cdecl to fix calling convention on caller's side is a cleaner solution and would avoid ABI breaks?

@Azoy
Copy link
Contributor

Azoy commented Aug 1, 2023

Yeah, I've been wanting that feature for a while now 🙂 of course I'd love us to actually formalize @_cdecl at some point, but if you need this fixed asap then adding support for a caller to define some external C function in Swift is probably the better short term solution.

@MaxDesiatov
Copy link
Contributor Author

Closing as superseded by #69207

@MaxDesiatov MaxDesiatov deleted the maxd/swiftcc-demangle branch January 29, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mangling Area → compiler: Mangling standard library Area: Standard library umbrella
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants