| 19 Jan 2026 |
Randy Eckenrode | It seems to be fine when invoked by SwiftPM but not when called directly. I can use the Xcode clang just fine with that header. | 20:44:47 |
Katalin 🔪 | yeah, that sounds like the same situation then | 20:45:49 |
Katalin 🔪 | iirc that generated header has a bunch of conditional includes at the top with has_include, and these errors look like missing defines, so maybe if you give it just the right include paths it'll get further, but I'd have to start digging | 20:46:51 |
Randy Eckenrode | It needs this header: swiftToCxx/_SwiftCxxInteroperability.h . | 20:48:15 |
Randy Eckenrode | That has the defines. | 20:48:23 |
Randy Eckenrode | The Xcode toolchain ships it at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/swiftToCxx/_SwiftCxxInteroperability.h. | 20:49:32 |
Randy Eckenrode | I can put it in stdlib-dev/include, which should get picked up automatically by the wrapper. | 20:51:21 |
Randy Eckenrode | * I can put it in stdlib-dev/include, which should get picked up automatically by the wrapper. | 20:51:29 |
Katalin 🔪 | well well, the very simple case (empty module) does compile with that and clang++ 19. I'll have to test it with a larger project that actually exports some types | 20:52:43 |
Randy Eckenrode | I have a working test that creates a Swift struct from C++ and prints the value. | 22:46:16 |
Randy Eckenrode | I added it to the cxx-interop-test package. | 22:46:28 |
Randy Eckenrode | $ nix build -f . swiftPackages.cxx-interop-test --log-format multiline -L
swift-cxx-interop-test> Running phase: unpackPhase
swift-cxx-interop-test> unpacking source archive /nix/store/nf6dg34afc7p4mjxxkpgc6gs294a4jyb-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/im17i7wbpqrhfpvyh5czlsvjhp00ij4q-swift-testing-6.2.3-include/lib/swift/macosx/testing -Xswiftc -I -Xswiftc /nix/store/h2bri7l88h31bbjrsv8m38y2y8vqqpck-swift-stdlib-6.2.3-dev/lib/swift/macosx -Xswiftc -I -Xswiftc /nix/store/im17i7wbpqrhfpvyh5czlsvjhp00ij4q-swift-testing-6.2.3-include/lib/swift/macosx/testing -Xswiftc -I -Xswiftc /nix/store/h2bri7l88h31bbjrsv8m38y2y8vqqpck-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--41BD1BF3460DAC2D.txt
swift-cxx-interop-test> [3/5] Compiling CxxInteropTest SwiftStruct.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.18s)
swift-cxx-interop-test> swiftc -parse-as-library -emit-clang-header-path Check-SwiftStruct.h -module-name Check -cxx-interoperability-mode=default Sources/SwiftStruct.swift -c -o SwiftStruct.o
swift-cxx-interop-test> clang++ -c -o main.o main.cpp
swift-cxx-interop-test> clang++ main.o SwiftStruct.o -o SwiftToCxxInteropTest
swift-cxx-interop-test> ld: warning: object file (SwiftStruct.o) was built for newer macOS version (26.0) than being linked (14.0)
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/ncir3cf7mcgcs399189bh8i31w6n7m9j-swift-cxx-interop-test...
swift-cxx-interop-test> patching script interpreter paths in /nix/store/ncir3cf7mcgcs399189bh8i31w6n7m9j-swift-cxx-interop-test
swift-cxx-interop-test> stripping (with command strip and flags -S) in /nix/store/ncir3cf7mcgcs399189bh8i31w6n7m9j-swift-cxx-interop-test/bin
swift-cxx-interop-test> Running phase: installCheckPhase
swift-cxx-interop-test> Hello, Swift!
swift-cxx-interop-test> Hello, C++!
| 23:50:17 |
Randy Eckenrode | Revised test at https://github.com/reckenrode/nixpkgs/tree/swift-update-mk2/pkgs/by-name/sw/swiftPackages/by-name/cx/cxx-interop-test. | 23:50:24 |
Randy Eckenrode | It tests both C++ to Swift and Swift to C++. | 23:50:33 |
Randy Eckenrode | I manually copy the swiftToCxx headers to the stdlib^dev output. | 23:55:33 |
| 20 Jan 2026 |
Randy Eckenrode | Does this patch fix the Linux build of Swift?
diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix
index 5bb32d8496..e83cd984bb 100644
--- a/pkgs/development/compilers/swift/compiler/default.nix
+++ b/pkgs/development/compilers/swift/compiler/default.nix
@@ -148,7 +148,7 @@
-e "s|${clang.cc}/bin/clang|$unwrappedClang|g" \
-e "s|^\(\s*\)\($unwrappedClang\) \"@\\\$responseFile\"|\1argv0=\$0\n\1${bash}/bin/bash -c \"exec -a '\$argv0' \2 '@\$responseFile'\"|" \
${lib.optionalString (clang.libcxx != null) ''
- -e 's|$NIX_CXXSTDLIB_COMPILE_${clang.suffixSalt}|-isystem '$SWIFT_BUILD_ROOT'/libcxx/include/c++/v1|g'
+ -e 's|$NIX_CXXSTDLIB_COMPILE_${clang.suffixSalt}|-cxx-isystem '$SWIFT_BUILD_ROOT'/libcxx/include/c++/v1|g'
''}
chmod a+x "$targetFile"
'';
| 00:38:54 |
Randy Eckenrode | … the current Swift can’t build on a remote builder for a different platform? | 00:55:21 |
Randy Eckenrode | I’m testing now, but I think that along with the GCC 15 PR fixes the Swift build on Linux. | 01:08:34 |
samasaur | nice! was just gonna kick off a build to check but it sounds like you've got it | 01:09:10 |
Randy Eckenrode | I’m around swift> [959/3307] Building CXX object lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/LowerTypeTests.cpp.o, which I believe is farther along than Hydra has gotten. | 01:09:45 |
Randy Eckenrode | I’m seeing if it somehow fixes Darwin as well. | 01:10:12 |
Randy Eckenrode | * | 01:10:19 |
samasaur | the swiftc crash? | 01:10:22 |
Randy Eckenrode | Yeah. | 01:10:26 |
samasaur | 🤞 | 01:10:27 |
Randy Eckenrode | I’m currently building mpv to test Swift 6.2, so it’s something to do. | 01:11:22 |
Randy Eckenrode | mpv apparently depends on everything. | 01:11:29 |
Randy Eckenrode | Haskell, Node, Fortran, Ruby, Python, … | 01:11:50 |
Randy Eckenrode | Nope. Fails.
build/src/llvm-project/llvm/include/llvm/CAS/CASReference.h:12:2: note: in module 'LLVM_Utils' imported from /build/src/llvm-project/llvm/include/llvm/CAS/CASReference.h:12:
#include "llvm/ADT/ArrayRef.h"
^
/build/src/llvm-project/llvm/include/llvm/Support/type_traits.h:35:13: error: missing '#include <type_traits>'; 'is_class' must be defined before it is used
!std::is_class<UnderlyingT>::value && // Filter conversion operators.
^
/build/src/llvm-project/llvm/include/llvm/ADT/Hashing.h:351:36: note: in instantiation of template class 'llvm::is_integral_or_enum<const void *>' requested here
: std::integral_constant<bool, ((is_integral_or_enum<T>::value ||
^
/build/src/llvm-project/llvm/include/llvm/ADT/Hashing.h:368:18: note: in instantiation of template class 'llvm::hashing::detail::is_hashable_data<const void *>' requested here
std::enable_if_t<is_hashable_data<T>::value, T>
^
/build/src/llvm-project/llvm/include/llvm/ADT/Hashing.h:560:63: note: while substituting deduced template arguments into function template 'get_hashable_data' [with T = const void *]
buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg));
^
/build/src/llvm-project/llvm/include/llvm/ADT/Hashing.h:608:17: note: in instantiation of function template specialization 'llvm::hashing::detail::hash_combine_recursive_helper::combine<const void *, const void *>' requested here
return helper.combine(0, helper.buffer, helper.buffer + 64, args...);
^
/build/src/swift/include/swift/Basic/SourceLoc.h:291:12: note: in instantiation of function template specialization 'llvm::hash_combine<const void *, const void *>' requested here
return hash_combine(Val.Start.getOpaquePointerValue(),
^
/nix/store/qarrb8yfby1yyypm32vabzgxgq3w41ma-gcc-15.2.0/include/c++/15.2.0/type_traits:654:12: note: definition here is not reachable
struct is_class
^
/build/src/swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift:13:8: error: could not build C module 'BasicBridging'
import BasicBridging
| 02:00:31 |
Randy Eckenrode | I suspect the issue is in swift-linux-fix-libc-paths.patch. | 02:10:09 |