Skip to content

Commit 2fecdcd

Browse files
authored
[wasm] Fix debug build of AOT cross compiler (#50418)
For mono AOT cross compiler we use llvm libraries from `runtime.win-x64.microsoft.netcore.runtime.mono.llvm.sdk` package. These are built in Release configuration. On windows we get linker errors when mixing them with obj files compiled with debug flags. To avoid that, build the AOT cross compiler always as in Release configuration. Example of the errors: LLVMSupport.lib(Unicode.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in monosgen-2.0.lib(mini-llvm-cpp.cpp.obj) LLVMSupport.lib(Unicode.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in monosgen-2.0.lib(mini-llvm-cpp.cpp.obj)
1 parent 79f33ed commit 2fecdcd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/mono/mono.proj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@
468468
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(EMSDK_PATH)/upstream/lib/libclang.so</MonoLibClang>
469469
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Windows'))">$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'upstream', 'bin', 'libclang.dll'))</MonoLibClang>
470470
<PythonCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; python</PythonCmd>
471+
<_ForceRelease Condition="$([MSBuild]::IsOSPlatform('Windows')) and '$(TargetArchitecture)' == 'wasm' and '$(Configuration)' == 'Debug'">true</_ForceRelease>
471472
</PropertyGroup>
472473

473474
<!-- Windows specific options -->
@@ -478,8 +479,8 @@
478479
<_MonoAOTCPPFLAGS Include="-DWIN32_LEAN_AND_MEAN" />
479480
<!--<_MonoAOTCPPFLAGS Include="-D_WINDOWS" />--> <!-- set in monow.vcxproj, not sure we really need it -->
480481
<_MonoAOTCPPFLAGS Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'arm64'" Include="-DWIN64" />
481-
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Release'" Include="-DNDEBUG" />
482-
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Debug'" Include="-D_DEBUG" />
482+
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Release' or '$(_ForceRelease)' == 'true'" Include="-DNDEBUG" />
483+
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Debug' and '$(_ForceRelease)' != 'true'" Include="-D_DEBUG" />
483484
<!-- <_MonoAOTCPPFLAGS Include="-D__default_codegen__" /> --> <!-- doesn't seem to be used -->
484485
<_MonoAOTCPPFLAGS Include="-D_CRT_SECURE_NO_WARNINGS" />
485486
<_MonoAOTCPPFLAGS Include="-D_CRT_NONSTDC_NO_DEPRECATE" />
@@ -539,7 +540,8 @@
539540
<MonoAOTCMakeArgs Include="-DAOT_TARGET_TRIPLE=$(MonoAotAbi)"/>
540541
<MonoAOTCMakeArgs Condition="'$(_MonoUseNinja)' == 'true'" Include="-G Ninja"/>
541542
<MonoAOTCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=$([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'out'))"/>
542-
<MonoAOTCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
543+
<MonoAOTCMakeArgs Condition="'$(_ForceRelease)' != 'true'" Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
544+
<MonoAOTCMakeArgs Condition="'$(_ForceRelease)' == 'true'" Include="-DCMAKE_BUILD_TYPE=Release"/>
543545
<!-- FIXME: Disable more -->
544546
<MonoAOTCMakeArgs Include="-DENABLE_MINIMAL=" />
545547
<MonoAOTCMakeArgs Include="-DENABLE_ICALL_SYMBOL_MAP=1" />

0 commit comments

Comments
 (0)