swift-nio icon indicating copy to clipboard operation
swift-nio copied to clipboard

Swift 6.1 build time error: redefinition of module 'CNIO...'

Open MahdiBM opened this issue 9 months ago • 9 comments

Expected behavior

No errors.

Actual behavior

Errors on project that builds fine with Swift 6.0 compiler:

/__w/my-app/my-app/.build/x86_64-unknown-linux-gnu/debug/CNIOWASI-tool.build/module.modulemap:1:8: error: redefinition of module 'CNIOWASI'
1 | module CNIOWASI {
  |        `- error: redefinition of module 'CNIOWASI'
2 |     umbrella header "/__w/my-app/my-app/.build/checkouts/swift-nio/Sources/CNIOWASI/include/CNIOWASI.h"
3 |     export *

I have noticed other module names as well. These are the ones I could quickly catch: CNIOAtomics, CNIOLinux, CNIODarwin, CNIOWASI, CNIOBoringSSLShims

Steps to reproduce

None. The project is private.

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

None. The project is private. Haven't tried to minimally reproduce.

SwiftNIO version/commit hash

2.81.0 tag.

System & version information

swift:6.1-noble Docker image.

MahdiBM avatar Apr 14 '25 18:04 MahdiBM

Thanks for filing this. Can you provide a complete build log? If necessary, feel free to provide it privately.

Lukasa avatar Apr 15 '25 07:04 Lukasa

where can I contact you privately? an email should be good enough, but anything else you have should also do it.

MahdiBM avatar Apr 15 '25 07:04 MahdiBM

You can use the OSS Swift Slack DM, or you can email me. My work email address is on any of my git commits.

Lukasa avatar Apr 15 '25 09:04 Lukasa

Emailed with title Logs for https://github.com/apple/swift-nio/issues/3204. Thanks for looking into this 🙂.

MahdiBM avatar Apr 15 '25 10:04 MahdiBM

Hrm, this looks like a SwiftPM bug, where it's generating duplicate modulemaps for the -tool case and the product case. https://github.com/swiftlang/swift-package-manager/pull/8498 might be a fix? cc @dschaefer2

Lukasa avatar Apr 15 '25 16:04 Lukasa

Without a reproducing package, it's hard to say whether this fixed it but the error does look familiar.

dschaefer2 avatar Apr 15 '25 17:04 dschaefer2

@dschaefer2 when can I expect that fix? Swift 6.1.1?

MahdiBM avatar Apr 16 '25 17:04 MahdiBM

Actually, it'll be in the next release off of release/6.1, which shouldn't be much later than 6.1.1 (which is Windows and Linux fixes only).

dschaefer2 avatar Apr 21 '25 14:04 dschaefer2

I'm not sure if this is expected anyway and the changes haven't made it to these images, but wanted to mention that the same issue is still present in the latest nightly Swift 6.1 Docker image: swiftlang/swift:nightly-6.1-jammy@sha256:81527a2bfd0819ae50b91b7334276690fdaa6534b5a89d7006059f55cbb3a8a7

MahdiBM avatar May 28 '25 13:05 MahdiBM

I can confirm the project now compiles again on Swift 6.2 nightlies (the one bundled with Xcode 26 beta 2). I had to fix some new macro-related errors but that's unrelated to this.

MahdiBM avatar Jun 30 '25 11:06 MahdiBM

Our project is doing well on Swift 6.2 so I think we can close this issue? Although I hear some more folks are bumping into something similar to this even on 6.2.

MahdiBM avatar Nov 07 '25 07:11 MahdiBM

Let's close this for now, we can always reopen.

Lukasa avatar Nov 07 '25 13:11 Lukasa