Use a C++ library built with MDd_DynamicDebug?

Hello, I'm trying to link my Swift program (Swift 6.0.1) with a C++ library (in my case, Luau) built in debug mode, so with MDd_DynamicDebug.

If I try to do so,I have the following error:

lld-link: error: /failifmismatch: mismatch detected for 'RuntimeLibrary':
>>> C:\Users\natinusala\AppData\Local\Programs\Swift\Platforms\6.0.1\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows\x86_64\swiftrt.obj has value MD_DynamicRelease
>>> Luau.VM.lib(ldo.obj) has value MDd_DynamicDebug

If I rebuild Luau in release mode, it works. However this means that I can't really use a debugger on my program anymore when/if it crashes on the C++ side (which sometimes happen when manipulating the Lua stack).

I understand the reason behind this error however I feel like when my Swift package is compiled in debug mode, it should use a Swift standard library / runtime also in debug mode, shouldn't it?

Is there a way for me to use the library in debug mode? Like a debug version of swiftrt.obj anywhere that could be used instead of the release one when my own Swift code is compiled in debug mode? Maybe use a debug version of the toolchain?

I also had to add -D_ITERATOR_DEBUG_LEVEL=0 when building Luau because there was a mismatch there too (swiftrt.obj has 0, default Luau has 2).

1 Like

Combining /MD and /MDd is not permitted as the STL is ABI incompatible with !NDEBUG. We currently do not have multiple builds of the runtime on Windows, though there is some headway being made towards possibly supporting that in the future. Note that this would be pretty expensive though and would result in extremely poor performance for the code as the runtime relies heavily on the optimizations. It might be that we would need to consider a -O build of Swift and a /MDd build of the runtime, which is very confusing to the user as that is a debug + release build of the standard library.