| 19 Jan 2026 |
Randy Eckenrode | I could also make Swift propagate Clang and support regular stdenvs. Iβm not super thrilled about that, but it would avoid misuse. | 20:21:02 |
Katalin πͺ | yeah, and for bidirectional interop you do need clang anyway | 20:21:06 |
Katalin πͺ | or swift clang, even | 20:21:19 |
Randy Eckenrode | You lose some features, but it works with regular Clang. | 20:21:37 |
Randy Eckenrode | Anyway, after fighting with sqlite, Iβm finally back at a Swift environment based on staging from Sunday. Now I just need to figure out a way to hack in prebuilts. | 20:22:15 |
Katalin πͺ | oh cool, is that new? last time I tried it errored on some part of the generated header | 20:22:25 |
Katalin πͺ | with c++ interop, that is | 20:23:09 |
Randy Eckenrode | Do you have an example I can test? | 20:24:00 |
Katalin πͺ | oof, not a ready one | 20:25:26 |
Katalin πͺ | I'd have to strip down The Project | 20:25:33 |
samasaur | there is a cxx-interop example in nixpkgs i think? | 20:25:38 |
samasaur | if that is what you're looking for | 20:25:44 |
samasaur | though a simplistic one | 20:25:47 |
Randy Eckenrode | Simple is fine. I just want to confirm it works. | 20:27:46 |
Katalin πͺ | actually, of course I have something | 20:28:33 |
Katalin πͺ | hold on | 20:28:37 |
Katalin πͺ | I literally test for this in Meson | 20:28:43 |
samasaur | the nixpkgs one is at pkgs/development/compilers/swift/cxx-interop-test/default.nix, exposed at swift.tests.cxx-interop-test though that second fact probably isn't helpful to you anymore | 20:29:13 |
Katalin πͺ | https://github.com/dblsaiko/meson/blob/d4d45660ca56631f7c628810e2c3579e3adf0497/mesonbuild/interpreter/interpreter.py#L1560 | 20:29:36 |
Katalin πͺ | oh that's not too useful without the actual arg list | 20:30:01 |
Katalin πͺ | hold on | 20:30:03 |
Katalin πͺ | swiftc -parse -emit-objc-header -emit-objc-header-path swift-export.h -parse-as-library -module-name Check -cxx-interoperability-mode=default - < /dev/null | 20:31:59 |
Katalin πͺ | include swift-export.h in whatever C++ compiler | 20:32:13 |
Randy Eckenrode | Iβve moved it into the package set for now, but I may want to find another place for it if we donβt want it available outside of swift.tests. | 20:32:15 |
Katalin πͺ |  Download image.png | 20:33:54 |
Katalin πͺ | here, with normal clang, I get something like this | 20:33:55 |
Randy Eckenrode | $ nix build -f . swiftPackages.cxx-interop-test -L
swift-cxx-interop-test> Running phase: unpackPhase
swift-cxx-interop-test> unpacking source archive /nix/store/m30j9w6nrkaddslrfwyhbkq28jcs2bqw-src
swift-cxx-interop-test> source root is src
swift-cxx-interop-test> Unpacking SwiftPM dependencies
swift-cxx-interop-test> Running phase: patchPhase
swift-cxx-interop-test> Running phase: updateAutotoolsGnuConfigScriptsPhase
swift-cxx-interop-test> Running phase: configurePhase
swift-cxx-interop-test> no configure script, doing nothing
swift-cxx-interop-test> Running phase: buildPhase
swift-cxx-interop-test> SwiftPM flags: -j 16 -c release -Xswiftc -module-cache-path -Xswiftc /nix/var/nix/builds/nix-build-swift-cxx-interop-test.drv-0/b/module-cache -Xswiftc -I -Xswiftc /nix/store/9gz91ivdymjlk4dhnfs2wri3h3z7y3vv-swift-testing-6.2.3-include/lib/swift/macosx/testing -Xswiftc -I -Xswiftc /nix/store/y3w9x0ywz7d6ya9d95i9i5apbwq6dwmf-swift-stdlib-6.2.3-dev/lib/swift/macosx -Xswiftc -I -Xswiftc /nix/store/9gz91ivdymjlk4dhnfs2wri3h3z7y3vv-swift-testing-6.2.3-include/lib/swift/macosx/testing -Xswiftc -I -Xswiftc /nix/store/y3w9x0ywz7d6ya9d95i9i5apbwq6dwmf-swift-stdlib-6.2.3-dev/lib/swift/macosx
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/configuration is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/security is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> warning: 'src': Warning: supplying the --target arm64-apple-macosx14.0 != arm64-apple-darwin argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead.
swift-cxx-interop-test> Building for production...
swift-cxx-interop-test> [0/4] Write sources
swift-cxx-interop-test> [1/4] Write swift-version-2FDF012AFD0A72F3.txt
swift-cxx-interop-test> [3/5] Compiling CxxInteropTest main.swift
swift-cxx-interop-test> [3/5] Write Objects.LinkFileList
swift-cxx-interop-test> Warning: supplying the --target arm64-apple-macosx10.13 != arm64-apple-darwin argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead.
swift-cxx-interop-test> clang: warning: overriding '-mmacos-version-min=14.0' option with '--target=arm64-apple-macosx10.13' [-Woverriding-option]
swift-cxx-interop-test> [4/5] Linking CxxInteropTest
swift-cxx-interop-test> Build complete! (2.32s)
swift-cxx-interop-test> Running phase: installPhase
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/configuration is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/security is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> warning: 'src': Warning: supplying the --target arm64-apple-macosx14.0 != arm64-apple-darwin argument to a nix-wrapped compiler may not work correctly - cc-wrapper is currently not designed with multi-target compilers in mind. You may want to use an un-wrapped compiler instead.
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/configuration is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> warning: /var/empty/Library/org.swift.swiftpm/security is not accessible or not writable, disabling user-level cache features.
swift-cxx-interop-test> Running phase: fixupPhase
swift-cxx-interop-test> checking for references to /nix/var/nix/builds/nix-build-swift-cxx-interop-test.drv-0/b/ in /nix/store/jrw7fkjigg64ika9w5dxv2w1m3b4gms9-swift-cxx-interop-test...
swift-cxx-interop-test> patching script interpreter paths in /nix/store/jrw7fkjigg64ika9w5dxv2w1m3b4gms9-swift-cxx-interop-test
swift-cxx-interop-test> stripping (with command strip and flags -S) in /nix/store/jrw7fkjigg64ika9w5dxv2w1m3b4gms9-swift-cxx-interop-test/bin
swift-cxx-interop-test> Running phase: installCheckPhase
swift-cxx-interop-test> Hello, world!
| 20:36:04 |
Randy Eckenrode | I did make one tweak to add a product to Package.swift. The new SwiftPM hook supports installing products automatically if theyβre defined in Package.swift. | 20:36:36 |
samasaur | oh that's really nice | 20:36:46 |
Randy Eckenrode | $ nix develop -f . swiftPackages.cxx-interop-test -L
$ command -v clang
/nix/store/3fbjimjwwxk682a9gkbr2nss0yf232mf-clang-wrapper-21.1.8/bin/clang
| 20:37:13 |