From a40b4fd73cf88d35b04ca42aec83f7b3b67022bf Mon Sep 17 00:00:00 2001 From: Alexander Kyte Date: Thu, 21 Jun 2018 22:54:34 +0000 Subject: [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. --- llvm/build_llvm_config.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 llvm/build_llvm_config.sh (limited to 'llvm/build_llvm_config.sh') 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" + + + + + + + + + -- cgit v1.2.3