Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/msvc
diff options
context:
space:
mode:
authorJohan Lorensson <lateralusx.github@gmail.com>2018-12-14 23:45:33 +0300
committerLudovic Henry <luhenry@microsoft.com>2018-12-14 23:45:33 +0300
commitd42d675b81dfb035f1617fa76f1d4bdde71f9359 (patch)
treeb65601abd27be3525828c4bfa2108a35cb1ad9ce /msvc
parent1503ca49525e0846bd21e454dae1c5ae2e3afcb0 (diff)
Windows x64 LLVM assert support + MSVC only for none cross compiler build. (#11946)
* Add support for LLVM asserts in internal LLVM build on Windows. * Only build LLVM using MSVC if not cross compiling. If not cross compiling, building runtime where host/target is Windows, only build and use LLVM as part of msvc build (only supported configuration), disabled on gcc build. Enforce 64-bit LLVM support when building using Visual Studio solution file. * Disable Windows LLVM Visual Studio build on unsupported configurations. Automatically disable Windows LLVM build in Visual Studio. This enables the option to configure using --enable-llvm but still build all runtime configurations from within Visual Studio. A warning will be issued into build logs when LLVM support is disabled for a specific build configuration. * Fix so build-init always have cygconf.h available when needed.
Diffstat (limited to 'msvc')
-rw-r--r--msvc/build-external-llvm.bat19
-rw-r--r--msvc/build-external-llvm.vcxproj5
-rw-r--r--msvc/build-init.vcxproj19
-rw-r--r--msvc/mono.external.targets17
-rw-r--r--msvc/mono.props2
-rwxr-xr-xmsvc/winsetup.bat4
6 files changed, 54 insertions, 12 deletions
diff --git a/msvc/build-external-llvm.bat b/msvc/build-external-llvm.bat
index e65bef93a6a..4982a64c42d 100644
--- a/msvc/build-external-llvm.bat
+++ b/msvc/build-external-llvm.bat
@@ -9,10 +9,11 @@
:: %3 LLVM install root directory.
:: %4 Mono distribution root directory.
:: %5 VS CFLAGS.
-:: %6 VS platform (Win32/x64)
-:: %7 VS configuration (Debug/Release)
-:: %8 VS target
-:: %9 MsBuild bin path, if used.
+:: %6 Additional CMake arguments.
+:: %7 VS platform (Win32/x64).
+:: %8 VS configuration (Debug/Release).
+:: %9 VS target.
+:: %10 MsBuild bin path, if used.
:: --------------------------------------------------
@echo off
@@ -33,10 +34,11 @@ set LLVM_BUILD_DIR=%~2
set LLVM_INSTALL_DIR=%~3
set MONO_DIST_DIR=%~4
set VS_CFLAGS=%~5
-set VS_PLATFORM=%~6
-set VS_CONFIGURATION=%~7
-set VS_TARGET=%~8
-set MSBUILD_BIN_PATH=%~9
+set LLVM_ADDITIONAL_CMAKE_ARGS=%~6
+set VS_PLATFORM=%~7
+set VS_CONFIGURATION=%~8
+set VS_TARGET=%~9
+set MSBUILD_BIN_PATH=%~10
:: Setup toolchain.
:: set GIT=
@@ -211,6 +213,7 @@ if /i "%CMAKE_GENERATOR%" == "ninja" (
-DLLVM_TOOLS_TO_BUILD="opt;llc;llvm-config;llvm-dis;llvm-mc;llvm-as" ^
-DLLVM_ENABLE_LIBXML2=Off ^
-DCMAKE_SYSTEM_PROCESSOR="%LLVM_ARCH%" ^
+%LLVM_ADDITIONAL_CMAKE_ARGS% ^
%CMAKE_GENERATOR_ARGS% ^
-G "%CMAKE_GENERATOR%" ^
"%LLVM_DIR%"
diff --git a/msvc/build-external-llvm.vcxproj b/msvc/build-external-llvm.vcxproj
index 6ab7a02a671..e74168261aa 100644
--- a/msvc/build-external-llvm.vcxproj
+++ b/msvc/build-external-llvm.vcxproj
@@ -152,7 +152,10 @@
<_LLVMCFlags Condition="'$(MONO_PREPROCESSOR_DEFINITIONS)' != ''">$(MONO_PREPROCESSOR_DEFINITIONS.Replace(";"," "))</_LLVMCFlags>
<_LLVMCFlags>$(_LLVMCFlags.Trim())</_LLVMCFlags>
<_LLVMCFlags Condition="'$(_LLVMCFlags)' != ''">-D$(_LLVMCFlags.Replace(" "," -D"))</_LLVMCFlags>
- <_LLVMBuildCommand>build-external-llvm.bat &quot;$(_LLVMSourceDir)&quot; &quot;$(_LLVMBuildDir)&quot; &quot;$(_LLVMInstallDir)&quot; &quot;$(_MonoOutputDir)&quot; &quot;$(_LLVMCFlags)&quot; &quot;$(Platform)&quot; &quot;$(Configuration)&quot;</_LLVMBuildCommand>
+ <_LLVMEnableAsserts>-DLLVM_ENABLE_ASSERTIONS=Off</_LLVMEnableAsserts>
+ <_LLVMEnableAsserts Condition="'$(MONO_ENABLE_LLVM_ASSERTS)' == 'true'" >-DLLVM_ENABLE_ASSERTIONS=On</_LLVMEnableAsserts>
+ <_LLVMAdditionalCMakeArgs>$(_LLVMEnableAsserts)</_LLVMAdditionalCMakeArgs>
+ <_LLVMBuildCommand>build-external-llvm.bat &quot;$(_LLVMSourceDir)&quot; &quot;$(_LLVMBuildDir)&quot; &quot;$(_LLVMInstallDir)&quot; &quot;$(_MonoOutputDir)&quot; &quot;$(_LLVMCFlags)&quot; &quot;$(_LLVMAdditionalCMakeArgs)&quot; &quot;$(Platform)&quot; &quot;$(Configuration)&quot;</_LLVMBuildCommand>
</PropertyGroup>
<Target Name="_AfterBuildExternalLLVM" Condition="'$(MONO_ENABLE_LLVM)' == 'true' and '$(_MonoEnableInternalLLVM)' == 'true'">
<Exec Command="$(_LLVMBuildCommand) &quot;Build&quot; &quot;$(MSBuildBinPath)\&quot;">
diff --git a/msvc/build-init.vcxproj b/msvc/build-init.vcxproj
index 57c90df4c56..2a6ba7c6df2 100644
--- a/msvc/build-init.vcxproj
+++ b/msvc/build-init.vcxproj
@@ -166,4 +166,23 @@
</Target>
<Target Name="AfterBuild" DependsOnTargets="AfterBuildWinSetup" />
+
+ <Target Name="_BackupConfigFile" Condition="'$(_MonoConfigFileBackupExists)' != 'true'">
+ <Copy SourceFiles="$(MONO_DIR)/config.h" DestinationFiles="$(MONO_DIR)/cygconfig.h" />
+ </Target>
+
+ <Target Name="_CheckConfigFile">
+ <_CheckConfigurationProperty ConfFile="$(MONO_DIR)/config.h" ConfRegEx="#include.*cygconfig.h.*">
+ <Output TaskParameter="ConfPropertyFoundMatch" PropertyName="_MonoConfigFileBackupExists" />
+ </_CheckConfigurationProperty>
+ </Target>
+
+ <PropertyGroup>
+ <PrepareForBuildDependsOn>
+ _CheckConfigFile;
+ _BackupConfigFile;
+ $(PrepareForBuildDependsOn);
+ </PrepareForBuildDependsOn>
+ </PropertyGroup>
+
</Project> \ No newline at end of file
diff --git a/msvc/mono.external.targets b/msvc/mono.external.targets
index 70682389c89..e6c998118a4 100644
--- a/msvc/mono.external.targets
+++ b/msvc/mono.external.targets
@@ -113,6 +113,7 @@
<_LLVMSourceDir Condition="'$(_LLVMSourceDir)' == ''">$(_MonoSourceDir)\external\llvm</_LLVMSourceDir>
<_LLVMBuildDir>$([System.IO.Path]::GetFullPath('$(MONO_BUILD_DIR_PREFIX)$(Platform)\obj\external\llvm-build\$(Configuration)'))</_LLVMBuildDir>
<_LLVMInstallDir>$(_LLVMBuildDir)\install</_LLVMInstallDir>
+ <_MonoLLVMConfig>$(_LLVMInstallDir)\bin\llvm-config.exe</_MonoLLVMConfig>
</PropertyGroup>
<PropertyGroup>
@@ -159,11 +160,21 @@
<PropertyGroup Condition="'$(MONO_EXTERNAL_LLVM_CONFIG)' == ''">
<_MonoEnableExternalLLVM>false</_MonoEnableExternalLLVM>
<_MonoEnableInternalLLVM>true</_MonoEnableInternalLLVM>
- <_MonoLLVMConfig>$(_LLVMInstallDir)\bin\llvm-config.exe</_MonoLLVMConfig>
</PropertyGroup>
</Target>
- <Target Name="_SetupMonoLLVMBuildProperties" Condition="$(MONO_ENABLE_LLVM)=='true'">
+ <Target Name="_CheckLLVMPlatformSupport" Condition="'$(MONO_ENABLE_LLVM)' == 'true'">
+ <warning Text="LLVM only supported on x64 builds, disabling LLVM support." Condition="'$(Platform)' != 'x64'" />
+ <PropertyGroup Condition="'$(Platform)' != 'x64'">
+ <MONO_ENABLE_LLVM>false</MONO_ENABLE_LLVM>
+ </PropertyGroup>
+ </Target>
+
+ <Target Name="_SetupMonoLLVMBuildProperties" Condition="$(MONO_ENABLE_LLVM) == 'true'">
+
+ <_CheckConfigurationProperty ConfFile="$(MONO_DIR)/cygconfig.h" ConfRegEx=".*#define.*INTERNAL_LLVM_ASSERTS.*1" Condition="'$(MONO_ENABLE_LLVM_ASSERTS)' != 'true'">
+ <Output TaskParameter="ConfPropertyFoundMatch" PropertyName="MONO_ENABLE_LLVM_ASSERTS" />
+ </_CheckConfigurationProperty>
<Error Text="LLVM config executable $(_MonoLLVMConfig) not found." Condition="!Exists($(_MonoLLVMConfig))" />
@@ -216,7 +227,7 @@
</Target>
- <Target Name="_ConfigureExternalMonoLLVMBuildEnvironment" DependsOnTargets="_SetDefaultLLVMProperties;_CheckEnableLLVM;_CheckInternalLLVM;_CheckExternalLLVM" />
+ <Target Name="_ConfigureExternalMonoLLVMBuildEnvironment" DependsOnTargets="_SetDefaultLLVMProperties;_CheckEnableLLVM;_CheckInternalLLVM;_CheckExternalLLVM;_CheckLLVMPlatformSupport" />
<Target Name="_ConfigureExternalMonoBTLSBuildEnvironment" DependsOnTargets="_CheckEnableBtls" />
<Target Name="_ConfigureExternalMonoBuildEnvironment" DependsOnTargets="_ConfigureExternalMonoLLVMBuildEnvironment;_ConfigureExternalMonoBTLSBuildEnvironment" />
diff --git a/msvc/mono.props b/msvc/mono.props
index 26ae7abcde1..bee40b1dda6 100644
--- a/msvc/mono.props
+++ b/msvc/mono.props
@@ -17,6 +17,8 @@
<MONO_USE_STATIC_LIBMONO>false</MONO_USE_STATIC_LIBMONO>
<!-- When true, mono binaries will link and include llvm. When false, mono binaries will not link and include llvm. -->
<MONO_ENABLE_LLVM>false</MONO_ENABLE_LLVM>
+ <!-- When true, enable LLVM asserts for internal LLVM build. When false, disable LLVM asserts for internal LLVM build. -->
+ <MONO_ENABLE_LLVM_ASSERTS>false</MONO_ENABLE_LLVM_ASSERTS>
<!-- When set, use an alternative LLVM source location for internal LLVM build. -->
<MONO_INTERNAL_LLVM_SOURCE_DIR></MONO_INTERNAL_LLVM_SOURCE_DIR>
<!-- When set, use an external pre-build LLVM library instead of internal one. -->
diff --git a/msvc/winsetup.bat b/msvc/winsetup.bat
index aff095a122c..a7b1c6290a7 100755
--- a/msvc/winsetup.bat
+++ b/msvc/winsetup.bat
@@ -73,6 +73,10 @@ for %%a in (%OPTIONAL_DEFINES%) do (
echo #endif >> %CONFIG_H_TEMP%
+echo #if defined(ENABLE_LLVM) ^&^& defined(HOST_WIN32) ^&^& defined(TARGET_WIN32) ^&^& (!defined(TARGET_AMD64) ^|^| !defined(_MSC_VER)) >> %CONFIG_H_TEMP%
+echo #error LLVM for host=Windows and target=Windows is only supported on x64 MSVC build. >> %CONFIG_H_TEMP%
+echo #endif >> %CONFIG_H_TEMP%
+
:: If the file is different, replace it.
fc %CONFIG_H_TEMP% %CONFIG_H% >nul 2>&1 || move /y %CONFIG_H_TEMP% %CONFIG_H%
del %CONFIG_H_TEMP% 2>nul