Detect build config mismatch for MSVC Windows LLVM build. (#32868)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Thu, 27 Feb 2020 12:30:27 +0000 (07:30 -0500)
committerGitHub <noreply@github.com>
Thu, 27 Feb 2020 12:30:27 +0000 (13:30 +0100)
commitbf1d573470b51a2fbba9c6096066c92ce8bf2cac
tree673466c4a69b8fb23ef3d4ab4031bdea69f15995
parentae5b558803cdc341dd5298bc62bcad30c040a93f
Detect build config mismatch for MSVC Windows LLVM build. (#32868)

If LLVM build is done using different build configuration, Mono build will fail to static link LLVM libraries due to incompatibility between release and debug C++ runtime library, generating a lot of linker errors like this:

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in mini-llvm-cpp.obj

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in mini-llvm-cpp.obj

This is normally not a problem when doing local builds of LLVM but when using an external provided build, like netcore Mono build, this problem is more likely to occur.

This fix adds an additional check to make sure build configuration reported by llvm-config.exe --build-mode matches current Mono build configuration and if not give a more specific msbuild error:

error : LLVM build Configuration=Release doesn't match current Mono build Configuration=Debug

Co-authored-by: Johan Lorensson <lateralusx.github@gmail.com>
src/mono/msvc/mono.external.targets