Skip to content

Commit

Permalink
[wasm] Fix debug build of AOT cross compiler (#50418)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
radekdoulik authored Apr 7, 2021
1 parent 79f33ed commit 2fecdcd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(EMSDK_PATH)/upstream/lib/libclang.so</MonoLibClang>
<MonoLibClang Condition="$([MSBuild]::IsOSPlatform('Windows'))">$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'upstream', 'bin', 'libclang.dll'))</MonoLibClang>
<PythonCmd Condition="'$(OS)' == 'Windows_NT'">call &quot;$([MSBuild]::NormalizePath('$(EMSDK_PATH)', 'emsdk_env.bat'))&quot; &amp;&amp; python</PythonCmd>
<_ForceRelease Condition="$([MSBuild]::IsOSPlatform('Windows')) and '$(TargetArchitecture)' == 'wasm' and '$(Configuration)' == 'Debug'">true</_ForceRelease>
</PropertyGroup>

<!-- Windows specific options -->
Expand All @@ -478,8 +479,8 @@
<_MonoAOTCPPFLAGS Include="-DWIN32_LEAN_AND_MEAN" />
<!--<_MonoAOTCPPFLAGS Include="-D_WINDOWS" />--> <!-- set in monow.vcxproj, not sure we really need it -->
<_MonoAOTCPPFLAGS Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'arm64'" Include="-DWIN64" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Release'" Include="-DNDEBUG" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Debug'" Include="-D_DEBUG" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Release' or '$(_ForceRelease)' == 'true'" Include="-DNDEBUG" />
<_MonoAOTCPPFLAGS Condition="'$(Configuration)' == 'Debug' and '$(_ForceRelease)' != 'true'" Include="-D_DEBUG" />
<!-- <_MonoAOTCPPFLAGS Include="-D__default_codegen__" /> --> <!-- doesn't seem to be used -->
<_MonoAOTCPPFLAGS Include="-D_CRT_SECURE_NO_WARNINGS" />
<_MonoAOTCPPFLAGS Include="-D_CRT_NONSTDC_NO_DEPRECATE" />
Expand Down Expand Up @@ -539,7 +540,8 @@
<MonoAOTCMakeArgs Include="-DAOT_TARGET_TRIPLE=$(MonoAotAbi)"/>
<MonoAOTCMakeArgs Condition="'$(_MonoUseNinja)' == 'true'" Include="-G Ninja"/>
<MonoAOTCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=$([MSBuild]::NormalizePath('$(MonoObjCrossDir)', 'out'))"/>
<MonoAOTCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<MonoAOTCMakeArgs Condition="'$(_ForceRelease)' != 'true'" Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<MonoAOTCMakeArgs Condition="'$(_ForceRelease)' == 'true'" Include="-DCMAKE_BUILD_TYPE=Release"/>
<!-- FIXME: Disable more -->
<MonoAOTCMakeArgs Include="-DENABLE_MINIMAL=" />
<MonoAOTCMakeArgs Include="-DENABLE_ICALL_SYMBOL_MAP=1" />
Expand Down

0 comments on commit 2fecdcd

Please sign in to comment.