Missing symbol with static FoundationEssentials on Linux

Hi,

I haven't had major issues with linking to the resources in swift_static until I started using FoundationEssentials on Linux. IIRC, this wasn't happening with the full Foundation library, but I can be wrong. Maybe I wasn't using Foundation at all.

Context: I'm building a dynamic library (.so), which I link to the static Swift runtime. My final executable depends on the library (ldd confirms it):

libpassepartout.so // The dynamic library embedding the static Swift runtime
passepartout // The executable depending on libpassepartout.so and others

However, this happens when I launch the executable, regardless of dead-code stripping of the .so:

undefined symbol: $s22_FoundationCollections4RopeV7BuilderVMn

I only import FoundationEssentials in my code, and I grant 100%. Okay, let's make it 99.99% to avoid potential shame in the future. Do you have any clue as to how to spot the missing symbol well before launching the executable? I suspect this might be only the first requirement of many.

Thanks in advance.

Can you check the final link command used to produce that shared library, and make sure it includes -l_FoundationCollections to link against that static library too? I believe the way it works is that the static runtime libraries are built with autolink instructions for their dependencies, so the static FoundationEssentials you want should be pulling in that library dependency and that symbol through that autolink instruction.

As usual, you hit the right button. It seems that autolink is not working as expected, at least in my CMake layout. For now, I was able to move forward by enforcing the autolinked dependencies manually, though it may break in the future in case more dependencies are added:

target_link_libraries(passepartout_shared PRIVATE
    _FoundationCollections
    _FoundationCShims
    swiftSynchronization
)

I'll need to inspect the CMake swiftc calls further.

Slightly better, I moved the requirements to my CMake toolchains.

set(CMAKE_Swift_FLAGS "-resource-dir $ENV{SWIFT_RESOURCE_DIR} -ldispatch -lstdc++ -lm -l_FoundationCollections -l_FoundationCShims -lswiftSynchronization")

Still not optimal.