[Mesa-dev] [PATCH RFC 1/1] configure: Drop LLVM_COMPONENTS

Jan Vesely jan.vesely at rutgers.edu
Thu Oct 23 12:58:12 PDT 2014


Use -Wl,--as-needed instead
This should fix the problem of using llvm split libraries.
Since the component split may change it's safer to list everything and let
linker filter out the unneeded ones.


CC: Tom Stellard <tom at stellard.net>
CC: Emil Velikov <emil.l.velikov at gmail.com>
CC: kai at dev.carbon-project.org
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
---
I'm not sure whether -Wl,--as-needed is supported by all build systems that emsa targets, or I need to add a test for it.

 configure.ac | 40 +++++++---------------------------------
 1 file changed, 7 insertions(+), 33 deletions(-)

diff --git a/configure.ac b/configure.ac
index 03f1bca..39dfd32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1694,7 +1694,7 @@ if test "x$enable_gallium_llvm" = xyes; then
 
     if test "x$LLVM_CONFIG" != xno; then
         LLVM_VERSION=`$LLVM_CONFIG --version | egrep -o '^[[0-9.]]+'`
-        LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
+        LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags -Wl,--as-needed`
         LLVM_BINDIR=`$LLVM_CONFIG --bindir`
         LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"`
         LLVM_CFLAGS=$LLVM_CPPFLAGS   # CPPFLAGS seem to be sufficient
@@ -1724,29 +1724,6 @@ if test "x$enable_gallium_llvm" = xyes; then
             AC_MSG_ERROR([LLVM $LLVM_REQUIRED_VERSION_MAJOR.$LLVM_REQUIRED_VERSION_MINOR or newer is required])
         fi
 
-        LLVM_COMPONENTS="engine bitwriter"
-        if $LLVM_CONFIG --components | grep -qw 'mcjit'; then
-            LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit"
-        fi
-
-        if test "x$enable_opencl" = xyes; then
-            LLVM_COMPONENTS="${LLVM_COMPONENTS} ipo linker instrumentation"
-            # LLVM 3.3 >= 177971 requires IRReader
-            if $LLVM_CONFIG --components | grep -qw 'irreader'; then
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader"
-            fi
-            # LLVM 3.4 requires Option
-            if $LLVM_CONFIG --components | grep -qw 'option'; then
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} option"
-            fi
-            # Current OpenCL/Clover and LLVM 3.5 require ObjCARCOpts and ProfileData
-            if $LLVM_CONFIG --components | grep -qw 'objcarcopts'; then
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} objcarcopts"
-            fi
-            if $LLVM_CONFIG --components | grep -qw 'profiledata'; then
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} profiledata"
-            fi
-        fi
         DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT -DLLVM_VERSION_PATCH=$LLVM_VERSION_PATCH"
         MESA_LLVM=1
 
@@ -1873,7 +1850,6 @@ radeon_llvm_check() {
                       sources with the --enable-experimental-targets=R600
                       configure flag])
     fi
-    LLVM_COMPONENTS="${LLVM_COMPONENTS} r600 bitreader ipo"
     NEED_RADEON_LLVM=yes
     if test "x$have_libelf" != xyes; then
        AC_MSG_ERROR([$1 requires libelf when using llvm])
@@ -1916,14 +1892,10 @@ if test -n "$with_gallium_drivers"; then
             gallium_require_drm_loader
             if test "x$enable_r600_llvm" = xyes -o "x$enable_opencl" = xyes; then
                 radeon_llvm_check "r600g"
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} bitreader asmparser"
             fi
             if test "x$enable_r600_llvm" = xyes; then
                 USE_R600_LLVM_COMPILER=yes;
             fi
-            if test "x$enable_opencl" = xyes; then
-                LLVM_COMPONENTS="${LLVM_COMPONENTS} bitreader asmparser"
-            fi
             ;;
         xradeonsi)
             HAVE_GALLIUM_RADEONSI=yes
@@ -1969,16 +1941,18 @@ if test -n "$with_gallium_drivers"; then
     done
 fi
 
-dnl Set LLVM_LIBS - This is done after the driver configuration so
-dnl that drivers can add additonal components to LLVM_COMPONENTS.
-dnl Previously, gallium drivers were updating LLVM_LIBS directly
+dnl Set LLVM_LIBS - All LLVM shared libs are added to the linking
+dnl stage and -Wl,--as-needed is used to filter out the unnecessary
+dnl ones
+dnl Previously drivers used LLVM_COMPONENTS to setup different components.
+dnl Before that, gallium drivers were updating LLVM_LIBS directly
 dnl by calling llvm-config --libs ${DRIVER_LLVM_COMPONENTS}, but
 dnl this was causing the same libraries to be appear multiple times
 dnl in LLVM_LIBS.
 
 if test "x$MESA_LLVM" != x0; then
 
-    LLVM_LIBS="`$LLVM_CONFIG --libs ${LLVM_COMPONENTS}`"
+    LLVM_LIBS="`$LLVM_CONFIG --libs`"
 
     if test "x$enable_llvm_shared_libs" = xyes; then
         dnl We can't use $LLVM_VERSION because it has 'svn' stripped out,
-- 
1.9.3



More information about the mesa-dev mailing list