From 13a53c4f5cdd664fd155c9e78fb46a4387af006c Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 5 Oct 2017 11:19:05 +0100 Subject: [PATCH] configure.ac: rework llvm libs handling for 3.9+ MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Earlier versions need different quirks, but as of LLVM 3.9 llvm-config provides --link-shared/link-static toggles. The output of which seems to be reliable - looking at LLVM 3.9, 4.0 and 5.0. Note that there are earlier code will be used for pre LLVM 3.9 and is unchanged. This effectively fixes LLVM static linking, while providing a clearer and more robust solution for future versions. Mildly interesting side notes: - build-mode (introduced with 3.8) was buggy with 3.8 It shows "static" when build with -DLLVM_LINK_LLVM_DYLIB=ON, yet it was consistent with --libs. The latter shows the static libraries. - libnames and libfiles are broken with LVM 3.9 The library prefix and extension is printed twice liblibLLVM-3.9.so.so v2: Invoke llvm-config twice, instead of using sed, to combine the two lines into one (Tobias) Cc: mesa-stable@lists.freedesktop.org Cc: Dieter Nützel Cc: Michel Dänzer Signed-off-by: Emil Velikov Reviewed-by: Tobias Droste --- configure.ac | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index c25b4e20b7c..751f70a02ab 100644 --- a/configure.ac +++ b/configure.ac @@ -2692,18 +2692,28 @@ if test "x$enable_llvm" = xyes; then dnl this was causing the same libraries to be appear multiple times dnl in LLVM_LIBS. - LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`" - - if test "x$enable_llvm_shared_libs" = xyes; then - if test $LLVM_VERSION_MAJOR -lt 4 -o "`$LLVM_CONFIG --shared-mode ${LLVM_COMPONENTS}`" = static; then - detect_old_buggy_llvm + if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 9; then + if test "x$enable_llvm_shared_libs" = xyes; then + LLVM_LIBS="`$LLVM_CONFIG --link-shared --libs ${LLVM_COMPONENTS}`" + else + dnl Invoking llvm-config with both -libs and --system-libs produces the + dnl two separate lines - each for the set of libraries. + dnl Call the program twice, effectively folding them into a single line. + LLVM_LIBS="`$LLVM_CONFIG --link-static --libs ${LLVM_COMPONENTS}`" + dnl We need to link to llvm system libs when using static libs + LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --link-static --system-libs`" fi else - AC_MSG_WARN([Building mesa with statically linked LLVM may cause compilation issues]) - dnl We need to link to llvm system libs when using static libs - dnl However, only llvm 3.5+ provides --system-libs - if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then - LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`" + LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`" + if test "x$enable_llvm_shared_libs" = xyes; then + detect_old_buggy_llvm + else + AC_MSG_WARN([Building mesa with statically linked LLVM may cause compilation issues]) + dnl We need to link to llvm system libs when using static libs + dnl However, only llvm 3.5+ provides --system-libs + if test $LLVM_VERSION_MAJOR -ge 4 -o $LLVM_VERSION_MAJOR -eq 3 -a $LLVM_VERSION_MINOR -ge 5; then + LLVM_LIBS="$LLVM_LIBS `$LLVM_CONFIG --system-libs`" + fi fi fi fi -- 2.30.2