apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.43k stars 151 forks source link

Add extern C markers #204

Closed brianmichel closed 8 months ago

brianmichel commented 8 months ago

Ensure C linkage for shims to allow for usage in C++ interop environments.

Checklist

If you've made changes to gyb files

Motivation:

This library when consumed from a swift package that has C++ interop enabled fails to successfully link since the symbols seem to get mangled.

Modifications:

I've added conditional extern "C" markers in the shims file if and only iff C++ is detected.

Result:

You should be able to consume and link this library in a target that has C++ interop enabled.

brianmichel commented 8 months ago

I feel uneasy about this. This only impacts the implementation and not the declaration which are consumed by the ClangImporter and thus this can lead to a mismatch in the linkage.

Ah this should likely just be in the header files, right? Sorry, long day of debugging.

Lukasa commented 8 months ago

@swift-server-bot test this please

compnerd commented 8 months ago

@Lukasa can we get this merged please?