!lheuhImcToQZYTQTuI:nixos.org

Nix on macOS

1181 Members
“There are still many issues with the Darwin platform but most of it is quite usable.” — http://yves.gnu-darwin.org194 Servers

Load older messages


SenderMessageTime
19 Jan 2026
@reckenrode:matrix.orgRandy EckenrodeThat has the defines.20:48:23
@reckenrode:matrix.orgRandy Eckenrode The Xcode toolchain ships it at /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/swiftToCxx/_SwiftCxxInteroperability.h. 20:49:32
@reckenrode:matrix.orgRandy EckenrodeI can put it in stdlib-dev/include, which should get picked up automatically by the wrapper.20:51:21
@reckenrode:matrix.orgRandy Eckenrode * I can put it in stdlib-dev/include, which should get picked up automatically by the wrapper. 20:51:29
@saiko:knifepoint.netKatalin 🔪 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
@reckenrode:matrix.orgRandy EckenrodeI have a working test that creates a Swift struct from C++ and prints the value.22:46:16
@reckenrode:matrix.orgRandy Eckenrode I added it to the cxx-interop-test package. 22:46:28
@reckenrode:matrix.orgRandy 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
@reckenrode:matrix.orgRandy EckenrodeRevised 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
@reckenrode:matrix.orgRandy EckenrodeIt tests both C++ to Swift and Swift to C++.23:50:33
@reckenrode:matrix.orgRandy Eckenrode I manually copy the swiftToCxx headers to the stdlib^dev output. 23:55:33
20 Jan 2026
@reckenrode:matrix.orgRandy 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
@reckenrode:matrix.orgRandy Eckenrode… the current Swift can’t build on a remote builder for a different platform?00:55:21
@reckenrode:matrix.orgRandy EckenrodeI’m testing now, but I think that along with the GCC 15 PR fixes the Swift build on Linux.01:08:34
@samasaur:matrix.orgsamasaurnice! was just gonna kick off a build to check but it sounds like you've got it01:09:10
@reckenrode:matrix.orgRandy 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
@reckenrode:matrix.orgRandy EckenrodeI’m seeing if it somehow fixes Darwin as well.01:10:12
@reckenrode:matrix.orgRandy Eckenrode * 01:10:19
@samasaur:matrix.orgsamasaurthe swiftc crash?01:10:22
@reckenrode:matrix.orgRandy EckenrodeYeah.01:10:26
@samasaur:matrix.orgsamasaur🤞01:10:27
@reckenrode:matrix.orgRandy Eckenrode I’m currently building mpv to test Swift 6.2, so it’s something to do. 01:11:22
@reckenrode:matrix.orgRandy Eckenrode mpv apparently depends on everything. 01:11:29
@reckenrode:matrix.orgRandy EckenrodeHaskell, Node, Fortran, Ruby, Python, …01:11:50
@reckenrode:matrix.orgRandy 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
@reckenrode:matrix.orgRandy Eckenrode I suspect the issue is in swift-linux-fix-libc-paths.patch. 02:10:09
@reckenrode:matrix.orgRandy Eckenrode Need to use OPT_cxx_isystem instead of OPT_isystem. 02:11:07
@reckenrode:matrix.orgRandy Eckenrode

Crash report for the Darwin crash:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Process:             swift-frontend-unwrapped [53009]
Path:                /Volumes/VOLUME/*/swift-frontend-unwrapped
Identifier:          swift-frontend-unwrapped
Version:             ???
Code Type:           ARM-64 (Native)
Role:                Unspecified
Parent Process:      ninja [56432]
Coalition:           org.nixos.nix-daemon [4898]
Responsible Process: nix [5696]
User ID:             362

Date/Time:           2026-01-19 21:14:34.1170 -0500
Launch Time:         2026-01-19 21:14:32.8801 -0500
Hardware Model:      Mac15,9
OS Version:          macOS 26.2 (25C56)
Release Type:        User

Crash Reporter Key:  8A4D7F20-D75B-4FA7-A8E5-8288BDD004AC
Incident Identifier: 2888A29C-8C89-4C13-AD2A-9102232598E7

Sleep/Wake UUID:       5A0E0820-1FE3-4283-95D4-CD2404EB3F19

Time Awake Since Boot: 110000 seconds
Time Since Wake:       7712 seconds

System Integrity Protection: enabled

Triggered by Thread: 0, Dispatch Queue: com.apple.main-thread

Exception Type:    EXC_BREAKPOINT (SIGTRAP)
Exception Codes:   0x0000000000000001, 0x0000000100942d24

Termination Reason:  Namespace SIGNAL, Code 5, Trace/BPT trap: 5
Terminating Process: exc handler [53009]


Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   swift-frontend-unwrapped      	       0x100942d24 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4356
1   swift-frontend-unwrapped      	       0x1008e1db4 swift::mainEntry(int, char const**) + 3624
2   dyld                          	       0x180bf5d54 start + 7184


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000108113510   x1: 0x0000000107f243c0   x2: 0x0000000000000000   x3: 0x0000000000000000
    x4: 0x0000000000000000   x5: 0x000000016f53951f   x6: 0x0000000000000073   x7: 0x000000016f5391df
    x8: 0x0000000000000020   x9: 0x0000000000000103  x10: 0xc77d0d0d182f7fe0  x11: 0xc77d0d0d182d7fe0
   x12: 0x0000000108114ee0  x13: 0x000000000000004c  x14: 0x0000000000000000  x15: 0x00000000ffffffb3
   x16: 0x92b10001080f8020  x17: 0x0000000000001cee  x18: 0x0000000000000000  x19: 0x000000016f539d40
   x20: 0x000000016f53adf8  x21: 0x0000000000000001  x22: 0x0000000000000000  x23: 0x000000016f539df8
   x24: 0x0000000000000000  x25: 0x000000016f539d78  x26: 0x000000016f539d78  x27: 0x000000016f53b598
   x28: 0x000000016f53e4e3   fp: 0x000000016f53b7b0   lr: 0x0000000100941edc
    sp: 0x000000016f539b30   pc: 0x0000000100942d24 cpsr: 0x80001000
   far: 0x0000000000000000  esr: 0xf2000001 (Breakpoint) brk 1

Binary Images:
       0x1008b4000 -        0x105a1bfff swift-frontend-unwrapped (*) <a7bd94ef-6b37-31cc-b3d3-aab563932e1f> /Volumes/VOLUME/*/swift-frontend-unwrapped
       0x180bed000 -        0x180c8bfc3 dyld (*) <0975afba-c46b-364c-bd84-a75daa9e455a> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
02:19:29
@reckenrode:matrix.orgRandy Eckenrode

Using OPT_cxx_isystem got the build farther, but it’s now failing at:


FAILED: source/Utility/CMakeFiles/lldbUtility.dir/AddressableBits.cpp.o
/nix/store/351bpjcf2l1n4vm06nwpq3cdhl6vbhx1-clang-wrapper-21.1.7/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLLDB_ENABLE_SWIFT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/build/build/lldb/source/Utility -I/bui>
In file included from /build/src/llvm-project/lldb/source/Utility/AddressableBits.cpp:9:
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:25:27: error: unknown type name 'uint32_t'
   25 |   void SetAddressableBits(uint32_t addressing_bits);
      |                           ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:29:27: error: unknown type name 'uint32_t'
   29 |   void SetAddressableBits(uint32_t lowmem_addressing_bits,
      |                           ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:30:27: error: unknown type name 'uint32_t'
   30 |                           uint32_t highmem_addressing_bits);
      |                           ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:32:33: error: unknown type name 'uint32_t'
   32 |   void SetLowmemAddressableBits(uint32_t lowmem_addressing_bits);
      |                                 ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:34:34: error: unknown type name 'uint32_t'
   34 |   void SetHighmemAddressableBits(uint32_t highmem_addressing_bits);
      |                                  ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:39:3: error: unknown type name 'uint32_t'
   39 |   uint32_t m_low_memory_addr_bits;
      |   ^
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:40:3: error: unknown type name 'uint32_t'
   40 |   uint32_t m_high_memory_addr_bits;
      |   ^
/build/src/llvm-project/lldb/source/Utility/AddressableBits.cpp:16:23: error: out-of-line definition of 'SetAddressableBits' does not match any declaration in 'lldb_private::AddressableBits'
   16 | void AddressableBits::SetAddressableBits(uint32_t addressing_bits) {
      |                       ^~~~~~~~~~~~~~~~~~
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:20:7: note: AddressableBits defined here
   20 | class AddressableBits {
      |       ^~~~~~~~~~~~~~~
/build/src/llvm-project/lldb/source/Utility/AddressableBits.cpp:20:23: error: out-of-line definition of 'SetAddressableBits' does not match any declaration in 'lldb_private::AddressableBits'
   20 | void AddressableBits::SetAddressableBits(uint32_t lowmem_addressing_bits,
      |                       ^~~~~~~~~~~~~~~~~~
/build/src/llvm-project/lldb/include/lldb/Utility/AddressableBits.h:20:7: note: AddressableBits defined here
04:37:12
@reckenrode:matrix.orgRandy Eckenrode

mpv built. I’m going to need to fix this to avoid pulling in the whole Swift closure instead of just the stdlib.

Load command 73
          cmd LC_RPATH
      cmdsize 88
         path /nix/store/c9f0k73y1m0a7zglncaraa0sfaz77z6l-swift-6.2.3/lib/swift/macosx (offset 12)
Load command 74
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
04:39:36

Show newer messages


Back to Room ListRoom Version: 6