Cxx Interop Breaks (<5.10) Toolchain Test Targets on Non-Darwin Platforms

Hey there! I seem to be unable to run my Cxx Interop enabled testing target with swift test to successfully compile and run my .testTarget(), macOS has no issues here; however on Linux Ubuntu 22.04 the whole Standard C library goes missing, it's quite strange!

Here is a build log (& project) -- mind you, a very large one; of the Standard C library going missing on Ubuntu for reference.

Basically what is happening is that I receive errors for all C includes like so:

error: 'cstddef' file not found
#include <cstddef>

In addition to this it appears to be incorrectly turning Cxx enabled targets into C ones, giving lots of errors for things like namespace is not a symbol and the usual error junk.

Does anyone much smarter than me know what is going on and how I might be able to fix this?


cc @egor.zhdan

This looks like a Swift Package Manager bug that we fixed very recently: [cxx-interop] Propagate interop flag to the test entry point target by egorzhdan · Pull Request #7428 · apple/swift-package-manager · GitHub

I can see from the log that you are using Swift 5.9. The fix for this issue has landed in 6.0, and we're trying to backport it to 5.10 as well. Would it be possible for you to switch to Swift 5.10 toolchains once the fix lands?


Migrating to the Swift 5.10 toolchain is more than fine, Cxx interop is considered (especially) experimental throughout 5.9 so it seems fair that it'll be missing some cxx interop features such as test target support (and only for non-darwin platforms at that).

It's awesome that this was caught just in time for 5.10, nice catch! Thank you.

1 Like