swift icon indicating copy to clipboard operation
swift copied to clipboard

Unable to build in debug mode with hosttools on Windows

Open egorzhdan opened this issue 1 year ago • 6 comments

I'm trying to build Swift on ARM64 Windows with HOSTTOOLS bootstrapping mode. I have a recent trunk toolchain from swift.org installed on this machine.

The build seems to fail because we're trying to link swift-frontend against swiftrt from the host toolchain, which was built in release mode.

[21/81] Linking CXX executable bin\swift-frontend.exe
FAILED: bin/swift-frontend.exe 
...
LINK: command "C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1437~1.328\bin\HOSTAR~1\arm64\link.exe /nologo @CMakeFiles\swift-frontend.rsp /out:bin\swift-frontend.exe /implib:lib\swift-frontend.lib /pdb:bin\swift-frontend.pdb /version:0.0 /INCREMENTAL:NO /STACK:10000000 /debug /subsystem:console /MANIFEST:EMBED,ID=1" failed (exit code 1319) with the following output:
swiftrt.obj : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in driver.cpp.obj
swiftrt.obj : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in driver.cpp.obj
LINK : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
bin\swift-frontend.exe : fatal error LNK1319: 2 mismatches detected
ninja: build stopped: subcommand failed.

egorzhdan avatar Jul 11 '24 14:07 egorzhdan

cc @compnerd @eeckstein

egorzhdan avatar Jul 11 '24 14:07 egorzhdan

Yes, that's not too surprising. In general, we do not support installing the swift toolchain on a development environment. I would suggest, you uninstall swift, reboot, then do a clean build. That should hopefully resolve the issue.

compnerd avatar Jul 11 '24 14:07 compnerd

Yeap, building without bootstrapping (=OFF) works fine. This only seems to be an issue when bootstrapping.

egorzhdan avatar Jul 11 '24 14:07 egorzhdan

Also, the debug mode builds don't really work. There's a good deal of UB in the swift compiler code base which prevents the compiler from working.

compnerd avatar Jul 11 '24 14:07 compnerd

Oh, interesting. I've been doing debug builds on Windows for a few years and most of the time they worked well for me. But I guess I haven't tried digging deep enough to see the issues underneath.

egorzhdan avatar Jul 11 '24 15:07 egorzhdan

Interesting! I'd love to be able to build in debug mode. I've not managed to get a successful build in debug mode in ages - its just a constant battle and I eventually decided that it can be unsupported until we have a UBSAN enabled build for the toolchain. It does make things a lot more complicated to have to debug in release mode :(

compnerd avatar Jul 11 '24 15:07 compnerd