diff options
author | Alexander Kyte <alkyte@microsoft.com> | 2018-06-22 01:54:34 +0300 |
---|---|---|
committer | Alexander Kyte <alkyte@microsoft.com> | 2018-06-29 05:35:30 +0300 |
commit | a40b4fd73cf88d35b04ca42aec83f7b3b67022bf (patch) | |
tree | 0580eb929f8a10cc7f27e5a01c29eb88c625dbf8 /llvm | |
parent | 3cc00c47ad6ecfb5a637bac65cabd44246a26c05 (diff) |
[runtime] Move llvm-config checks into /llvm subdir
We had a problem with order of operations before. Makefile.am.in is
interpolated twice in the standard build. The first time happens when
autoconf runs. The second time happens when we enter the mono/mini directory
and execute our build. In the refresh, we lose our AM_CONDITIONAL conditionals
defined that aren't also AC_DEFINE variables on linux.
That's what it's vital to define all variables in all namespaces to have maintainable
automake code.
Furthermore, some of the CFLAGS logic we defined is designed for older LLVM copies, as
it includes some flags like O3 and Wall that we don't want.
In order to not get hacky with this, I moved the logic for using llvm-config into
a bash file in /llvm that creates a makefile fragment. The logic says that this fragment
should be null on calling autoconf, and then will be instantiated after we build llvm.
This fixes the build on Linux. We can expect bash behavior to be more consistent between
OSX and Linux than we can with automake too. I think this is a reorg with good long-time
maintainability.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/.gitignore | 1 | ||||
-rw-r--r-- | llvm/Makefile.am | 25 | ||||
-rwxr-xr-x | llvm/build_llvm_config.sh | 47 |
3 files changed, 71 insertions, 2 deletions
diff --git a/llvm/.gitignore b/llvm/.gitignore index b336cc7cec9..32c9cdda7eb 100644 --- a/llvm/.gitignore +++ b/llvm/.gitignore @@ -1,2 +1,3 @@ /Makefile /Makefile.in +/llvm_config.mk diff --git a/llvm/Makefile.am b/llvm/Makefile.am index 0f287070d68..52fcfd8e09d 100644 --- a/llvm/Makefile.am +++ b/llvm/Makefile.am @@ -1,12 +1,33 @@ EXTRA_DIST=SUBMODULES.json build.mk +if ENABLE_LLVM if INTERNAL_LLVM -all-local: configure-llvm build-llvm install-llvm +all-local: configure-llvm build-llvm install-llvm llvm_config.mk -clean-local: clean-llvm +clean-local: clean-llvm clean-llvm-config +llvm_config.mk: install-llvm + ./build_llvm_config.sh $(abspath $(CURDIR))/usr/bin/llvm-config $(LLVM_CODEGEN_LIBS) > llvm_config.mk + +else +all-local: llvm_config.mk + +clean-local: clean-llvm-config + +llvm_config.mk: + ./build_llvm_config.sh `which llvm-config` $(LLVM_CODEGEN_LIBS) > llvm_config.mk endif +else +all-local: + +clean-local: +endif + +clean-llvm-config: + - rm -rf llvm_config.mk + +.PHONY: clean-llvm-config llvm_config.mk include build.mk diff --git a/llvm/build_llvm_config.sh b/llvm/build_llvm_config.sh new file mode 100755 index 00000000000..d6d06f269bd --- /dev/null +++ b/llvm/build_llvm_config.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +llvm_config=$1 +extra_libs="${@:2}" + +llvm_api_version=`$llvm_config --mono-api-version` || "0" +with_llvm=`$llvm_config --prefix` + +llvm_config_cflags=`$llvm_config --cflags` + +if [[ $llvm_config_cflags = *"stdlib=libc++"* ]]; then +llvm_libc_c="-stdlib=libc++" +llvm_libc_link="-lc++" +else +llvm_libc_c="" +llvm_libc_link="-lstdc++" +fi + +# llvm-config --clfags adds warning and optimization flags we don't want +shared_llvm_cflags="-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" +cxxflag_additions="-std=c++11 -fno-rtti -fexceptions" + +ldflags="-L$with_llvm/lib" + +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` +llvm_new_jit=`$llvm_config --libs orcjit 2>>/dev/null` +llvm_extra=`$llvm_config --libs $extra_libs` +llvm_lib_components="$llvm_core_components $llvm_old_jit $llvm_new_jit $llvm_extra" + +echo "LLVM_CFLAGS_INTERNAL=$shared_llvm_cflags" +echo "LLVM_CXXFLAGS_INTERNAL=$shared_llvm_cflags $cxxflag_additions" +echo "LLVM_LDFLAGS_INTERNAL=$ldflags" +echo "LLVM_LIBS_INTERNAL=$llvm_lib_components $ldflags $llvm_system $llvm_libc_link" + + + + + + + + + |