Skip to content
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

Cxx interop problem #3093

Open
postmechanical opened this issue Jan 29, 2025 · 4 comments
Open

Cxx interop problem #3093

postmechanical opened this issue Jan 29, 2025 · 4 comments

Comments

@postmechanical
Copy link

Expected behavior

Using swift-nio package in a project with Cxx interop enabled builds, runs, and is debuggable.

Actual behavior

Using swift-nio package in a project with Cxx interop enabled builds and runs but renders debugger unusable with following error:

(lldb) po someVar
error: /Users/some.user/Library/Developer/Xcode/DerivedData/SomeProject-ejsisrcmvvxjfmgjdseiwglvudot/SourcePackages/checkouts/swift-nio/Sources/CNIOLLHTTP/include/c_nio_llhttp.h:3:1: import of C++ module 'std_stdint_h' appears within extern "C" language linkage specification
#include <stdint.h>
^

Locally modifying c_nio_llhttp.h as follows builds, runs, and is debuggable:

13a14
> 
15c16,18
< extern "C" {
---
> #include <cstdint>
> #else
> #include <stdint.h>
18c21,23
< #include <stdint.h>
---
> #ifdef __cplusplus
> extern "C" {
> #endif

Steps to reproduce

I have attempted a standalone repro without success so far. The project in which I've enabled Cxx interop is a sizeable legacy project that is a mix of UIKit and SwiftUI.

At the project level I have added -cxx-interoperability-mode=default -Xcc -std=c++17 to the OTHER_SWIFT_FLAGS build setting. I have one local package that depends on grpc-swift which transitively depends on swift-nio and this local package does not enable Cxx interop. I have another local package that depends on a remote package that requires Cxx interop and is using swiftSettings: [.interoperabilityMode(.Cxx)] on the target definition and cxxLanguageStandard: .cxx17 on the package definition.

If possible, minimal yet complete reproducer code (or URL to code)

No minimal standalone repro yet.

SwiftNIO version/commit hash

2.78.0

System & version information

Please provide at the very least your operating system and Swift version
information.

macOS: 14.7.1
Swift: 5.9
Xcode: 16.2 (16C5032a)

Ideally, run

scripts/nio-diagnose -o nio-diagnose.md PID_OF_YOUR_NIO_PROGRAM

and attach (or paste) the resulting file nio-diagnose.md into this bug report
or send it to the SwiftNIO maintainers privately.

@Lukasa
Copy link
Contributor

Lukasa commented Jan 30, 2025

Thanks for filing this! Is this the only change required to get things to build on your end?

If so, then I think there are two steps. First, ideally you'd file a bug report on llparse, which generates the header file. The include comes from here, and could easily be guarded appropriately.

Secondly, we can apply a patch to the generated code here to get this to work.

@postmechanical
Copy link
Author

It is the only change to get the debugger working again on my end. I will get started on the suggested next steps. Thanks.

@Lukasa
Copy link
Contributor

Lukasa commented Jan 31, 2025

No problem, please let me know if you need any help.

@postmechanical
Copy link
Author

Issue created over at llparse: nodejs/llparse#71

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

No branches or pull requests

2 participants