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/llvm
diff options
context:
space:
mode:
authorJohan Lorensson <lateralusx.github@gmail.com>2018-09-07 01:47:58 +0300
committerLudovic Henry <luhenry@microsoft.com>2018-09-07 01:47:58 +0300
commit0f3af38ee431b884abb6767bac2e104f1183f44a (patch)
treebc985e62a5b6219be02e268572fac24e830f87fa /llvm
parent362d1d94e11ff0a44bac7aa6830a4783d9c70610 (diff)
Fix Mono Windows cross compiler using mono LLVM release_60 branch. (#10413)
* Fix Mono Windows cross compiler using mono LLVM release_60 branch. For scenario where llvm-config.exe can't be run (none WSL/CygWin build target) Build will fallback to hard coded libraries not working with mono LLVM release_60 branch. Added an exact mirror of what llvm-config.exe is returning for different components on mono LLVM master and mono LLVM release_60 branch. The selected codegen libraries (passed in as extra_libs) was not handled in any cases so added them into the build script as well. * Split parameter between lvm codegen libs and llvm extra libs. Need to explicit pass -lz in case where configure have detected zlib availability and llvm-config.exe can't be executed. In cases where zlib is not available, default in mingw installs, this check make sure link step won't fail due to missing library. * Fix inversion of aarch64codegen libs. * Enable package-android-cross-{arm,arm64,x86,x86_64}-win builds on CI. * Fix incorrect checks when compiling Windows cross compiler. Windows cross compiler could have a target that is !TARGET_WIN32 but still running on a Windows host, so check needs to look at !HOST_WIN32 to determine if Unix source files can be included or not.
Diffstat (limited to 'llvm')
-rw-r--r--llvm/Makefile.am10
-rwxr-xr-xllvm/build_llvm_config.sh79
2 files changed, 80 insertions, 9 deletions
diff --git a/llvm/Makefile.am b/llvm/Makefile.am
index 5932e921d0c..09c0c4bec0d 100644
--- a/llvm/Makefile.am
+++ b/llvm/Makefile.am
@@ -9,6 +9,12 @@ else
llvm_config=llvm-config
endif
+if HAVE_ZLIB
+llvm_extra_libs=-lz
+else
+llvm_extra_libs=
+endif
+
if INTERNAL_LLVM
all-local: configure-llvm build-llvm install-llvm llvm_config.mk
@@ -16,7 +22,7 @@ all-local: configure-llvm build-llvm install-llvm llvm_config.mk
clean-local: clean-llvm clean-llvm-config
$(mono_build_root)/llvm/llvm_config.mk: install-llvm
- $(top_srcdir)/llvm/build_llvm_config.sh $(top_srcdir)/llvm/usr/bin/$(llvm_config) $(LLVM_CODEGEN_LIBS) > $@
+ $(top_srcdir)/llvm/build_llvm_config.sh "$(top_srcdir)/llvm/usr/bin/$(llvm_config)" "$(LLVM_CODEGEN_LIBS)" "$(llvm_extra_libs)" > $@
else
all-local: llvm_config.mk
@@ -24,7 +30,7 @@ all-local: llvm_config.mk
clean-local: clean-llvm-config
$(mono_build_root)/llvm/llvm_config.mk: $(top_srcdir)/llvm/Makefile.am
- $(top_srcdir)/llvm/build_llvm_config.sh $(EXTERNAL_LLVM_CONFIG) $(LLVM_CODEGEN_LIBS) > $@
+ $(top_srcdir)/llvm/build_llvm_config.sh "$(EXTERNAL_LLVM_CONFIG)" "$(LLVM_CODEGEN_LIBS)" "$(llvm_extra_libs)" > $@
endif
llvm_config.mk: $(mono_build_root)/llvm/llvm_config.mk
diff --git a/llvm/build_llvm_config.sh b/llvm/build_llvm_config.sh
index 8504ef0a7e2..d3c52f2cbd4 100755
--- a/llvm/build_llvm_config.sh
+++ b/llvm/build_llvm_config.sh
@@ -1,7 +1,8 @@
#!/bin/bash
llvm_config=$1
-extra_libs="${@:2}"
+llvm_codegen_libs="$2"
+llvm_extra_libs="${@:3}"
use_llvm_config=1
llvm_host_win32=0
@@ -48,9 +49,16 @@ if [[ $use_llvm_config = 1 ]]; then
llvm_config_cflags=`$llvm_config --cflags`
llvm_system=`$llvm_config --system-libs`
llvm_core_components=`$llvm_config --libs analysis core bitwriter`
- llvm_old_jit=`$llvm_config --libs mcjit jit 2>>/dev/null`
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_old_jit=`$llvm_config --libs mcjit jit 2>>/dev/null`
+ else
+ llvm_old_jit=`$llvm_config --libs mcjit 2>>/dev/null`
+ fi
llvm_new_jit=`$llvm_config --libs orcjit 2>>/dev/null`
- llvm_extra=`$llvm_config --libs $extra_libs`
+
+ if [[ ! -z $llvm_codegen_libs ]]; then
+ llvm_extra=`$llvm_config --libs $llvm_codegen_libs`
+ fi
# When building for Windows subsystem using WSL or CygWin the path returned from llvm-config.exe
# could be a Windows style path, make sure to format it into a path usable for WSL/CygWin.
@@ -67,13 +75,66 @@ if [[ $llvm_host_win32 = 1 ]] && [[ $use_llvm_config = 0 ]]; then
with_llvm="$(dirname $with_llvm)"
llvm_config_path=$with_llvm/include/llvm/Config/llvm-config.h
+ # llvm-config.exe --mono-api-version
llvm_api_version=`awk '/MONO_API_VERSION/ { print $3 }' $llvm_config_path`
+
+ # llvm-config.exe --cflags, returned information currently not used.
llvm_config_cflags=
- llvm_system="-lshell32 -lpsapi -limagehlp"
- llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport"
- llvm_old_jit="-lLLVMJIT -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport"
+
+ # llvm-config.exe --system-libs
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_system="-limagehlp -lpsapi -lshell32"
+ else
+ llvm_system="-lpsapi -lshell32 -lole32 -luuid -ladvapi32"
+ fi
+
+ # llvm-config.exe --libs analysis core bitwriter
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport"
+ else
+ llvm_core_components="-lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle"
+ fi
+
+ # llvm-config.exe --libs mcjit jit
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_old_jit="-lLLVMJIT -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT -lLLVMTarget -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMExecutionEngine -lLLVMMC -lLLVMCore -lLLVMSupport"
+ else
+ # Current build of LLVM 60 for cross Windows builds doesn't support LLVM JIT.
+ llvm_old_jit=
+ fi
+
+ # LLVM 36 doesn't support new JIT and LLVM 60 is build without LLVM JIT support for cross Windows builds.
llvm_new_jit=
- llvm_extra=
+
+ # Check codegen libs and add needed libraries.
+ case "$llvm_codegen_libs" in
+ *x86codegen*)
+ # llvm-config.exe --libs x86codegen
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_extra="-lLLVMX86CodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMObject -lLLVMBitReader -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport"
+ else
+ llvm_extra="-lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMX86Desc -lLLVMX86Info -lLLVMMCDisassembler -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle"
+ fi
+ ;;
+ *armcodegen*)
+ # llvm-config.exe --libs armcodegen
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_extra="-lLLVMARMCodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMMC -lLLVMSupport"
+ else
+ llvm_extra="-lLLVMARMCodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMARMDesc -lLLVMMCDisassembler -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMARMUtils -lLLVMMC -lLLVMSupport -lLLVMDemangle"
+ fi
+ ;;
+ *aarch64codegen*)
+ # llvm-config.exe --libs aarch64codegen
+ if [[ $llvm_api_version -lt 600 ]]; then
+ llvm_extra="-lLLVMAArch64CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport"
+ else
+ llvm_extra="-lLLVMAArch64CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -lLLVMSupport -lLLVMDemangle"
+ fi
+ ;;
+ *)
+ llvm_extra=$llvm_codegen_libs
+ esac
fi
if [[ $llvm_config_cflags = *"stdlib=libc++"* ]]; then
@@ -92,6 +153,10 @@ else
host_cflag_additions=""
fi
+if [[ ! -z $llvm_extra_libs ]]; then
+ llvm_extra="$llvm_extra $llvm_extra_libs"
+fi
+
# llvm-config --clfags adds warning and optimization flags we don't want
cflags_additions="-I$with_llvm/include -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DLLVM_API_VERSION=$llvm_api_version $llvm_libc_c $host_cflag_additions"