- Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
swiftmodule file added to linker input files when using cmake -DCMAKE_BUILD_TYPE=Debug and 128+ swift files. This is mac specific. The issues is reproducible with Xcode14, but is an error in Xcode15. The issue is that when you specify -DCMAKE_BUILD_TYPE=Debug cmake will add "-g" to the options passed to swiftc (as expected) but when you have more than 128 swift source files in your library the .swiftmodule file will be added to the linker input files. Xcode14 and possibly earlier only considered this a warning but Xcode15 reports it as an error. Removing "-g" from the CMAKE_Swift_FLAGS_DEBUG will allow the library to compile but without debug info. Reducing the number of source files in the library will also avoid the issue.
Steps to reproduce
git clone https://github.com/rimim/swiftc-debug-link-issue
cd swiftc-debug-link-issue
make VERBOSE=1
Building the release target in cmake or removing "-g" from the debug flags will allow the library to link successfully:
make clean && make VERBOSE=1 WORKAROUND=1
Building using Xcode 14 will also successfully link the library (with debug info), but a linker warning is generated:
ld: warning: ignoring file swift/DummyLibrary.swiftmodule, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0xE2 0x9C 0xA8 0x0E 0x01 0x08 0x00 0x00 0x7D 0x0B 0x00 0x00 0x07 0x01 0xB2 0xC0 )
Building using Xcode 15 generates this error:
error: link command failed with exit code 1 (use -v to see invocation)
ld: unknown file type in 'swift/DummyLibrary.swiftmodule'
Expected behavior
Successfully linking the libDummyLibrary.dylib
Environment
- Swift compiler: Reproducible with swiftc 5.8, 5.8.1, and 5.9.
- swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
- Xcode version info Xcode 15.0 Build version 15A240d
- Deployment target: MacOSX