Skip to content

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented Oct 3, 2025

Previous, we would encounter missing symbol errors like:

      "_subprocess_vm_size()", referenced from:
          closure #1 () -> Swift.Int in variable initialization expression of Subprocess.(_pageSize in _EDE99368FF43462E0C75AF3C9D4D8F2D) : Swift.Int in AsyncBufferSequence.swift.o
       NOTE: found '__subprocess_vm_size' in process_shims.c.o, declaration possibly missing 'extern "C"'

We can reproduce this by running:

    xcrun swift build -Xswiftc -cxx-interoperability-mode=default --build-tests

Adding extern "C" fixes these issues.

rdar://161624906

#else
#define SWIFTSUBPROCESS_EXPORT extern
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would be better served with a:

extern "C" {

block rather than annotating each of the declarations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally had, and then I saw #include <Windows.h> and realized I couldn't just wrap the entire thing with extern "C".

... But on second thought, I could just hoist that up to the top, and do the extern "C" thing you suggest (which is a cleaner patch).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, as long as the includes come outside of the block, it is simpler. That also avoids the pitfall of missing the annotation on a future declaration.

Previous, we would encounter missing symbol errors like:

          "_subprocess_vm_size()", referenced from:
              closure swiftlang#1 () -> Swift.Int in variable initialization expression of Subprocess.(_pageSize in _EDE99368FF43462E0C75AF3C9D4D8F2D) : Swift.Int in AsyncBufferSequence.swift.o
           NOTE: found '__subprocess_vm_size' in process_shims.c.o, declaration possibly missing 'extern "C"'

We can reproduce this by running:

        xcrun swift build -Xswiftc -cxx-interoperability-mode=default --build-tests

Adding `extern "C"` fixes these issues.

rdar://161624906
@iCharlesHu iCharlesHu merged commit d66519d into swiftlang:main Oct 4, 2025
35 checks passed
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.

3 participants