Here's a version of the mesa build patches rolled into one patch,
and driven by a configure argument --enable-static-libstdc++
which defaults to being off.
From 2e967e89fefc2a107c29c6581c9885475a7b7a84 Mon Sep 17 00:00:00 2001
From: vivek <vi...@debian-wheezy-0.carnitas.collabora.co.uk>
Date: Thu, 12 Mar 2015 01:30:19 +0000
Subject: [PATCH 1/2] Allow static libstdc++/libgcc linking if selected

---
 configure.ac                        | 46 +++++++++++++++++++++++++++++++++++++
 src/gallium/Automake.inc            |  1 +
 src/gallium/targets/dri/Makefile.am |  5 ++++
 3 files changed, 52 insertions(+)

diff --git a/configure.ac b/configure.ac
index 90c7737..7aa695a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -705,6 +705,34 @@ AC_ARG_ENABLE([dri],
     [enable_dri="$enableval"],
     [enable_dri=yes])
 
+AC_ARG_ENABLE([static-libstdc++],
+    [AS_HELP_STRING([--enable-static-libstdc++],
+        [Statically link libstdc++/libgcc @<:@default=disabled@:>@])],
+    [enable_static_libstdc__="$enableval"],
+    [enable_static_libstdc__=no])
+
+dnl Strip out unnecessary dynamic linking in of libstdc++ and libgcc_s for
+dnl DRI modules: they cause problems when loaded by games linked against
+dnl a steam runtime with a different libgcc or libstdc++ version:
+if test x$enable_static_libstdc__ != xno;
+then
+    if test x$enable_dri != xno;
+    then
+AC_MSG_NOTICE([Cleanup libtool C++ postdeps: $postdeps_CXX (enable_dri=$enable_dri)])
+        tmppdcxx=;
+        for x in ${postdeps_CXX};
+        do
+            case $x in
+                -lstdc++) true; ;;
+                -lgcc_s) true; ;;
+                *) tmppdcxx=${tmppdcxx}${tmppdcxx:+ }$x; ;;
+            esac;
+        done;
+        postdeps_CXX="${tmppdcxx}";
+AC_MSG_NOTICE([Cleaned libtool C++ postdeps: $postdeps_CXX])
+    fi;
+fi
+
 case "$host_os" in
 linux*)
     dri3_default=yes
@@ -2189,6 +2217,23 @@ if test "x$MESA_LLVM" != x0; then
         if test "x$llvm_have_one_so" = xyes; then
             dnl LLVM was built using auto*, so there is only one shared object.
             LLVM_LIBS="-l$LLVM_SO_NAME"
+            if test x$enable_static_libstdc__ != xno;
+            then
+                if test x$enable_llvm_shared_libs != xno;
+                then
+                    dnl If we want static libstdc++ linking and we asked for llvm shlib
+                    dnl then find a libLLVM-X.Y variant that doesn't need -lstdc++ -lgcc_s
+                    dnl Also: Make sure we don't ask for libstdc++ or libgcc_s explicitly:
+                    llvm_so_otherlibdeps=$($LLVM_CONFIG --ldflags)
+                    llvm_so_otherlibdeps=$(echo $llvm_so_otherlibdeps | sed -re 's@-lstdc\+\+|-lgcc_s@@g')
+                    AC_MSG_CHECKING([for a stdlib-independent lib$LLVM_SO_NAME])
+                    AC_CHECK_LIB([$LLVM_SO_NAME-nostdlib],
+                                 [LLVMInitializeCore],
+                                 [LLVM_LIBS="-l$LLVM_SO_NAME-nostdlib"],
+                                 [AC_MSG_ERROR([No lib$LLVM_SO_NAME with static libstdc++ linkage found])],
+                                 [$llvm_so_otherlibdeps])
+                fi;
+            fi;
         else
             dnl If LLVM was built with CMake, there will be one shared object per
             dnl component.
@@ -2450,6 +2495,7 @@ echo "        prefix:          $prefix"
 echo "        exec_prefix:     $exec_prefix"
 echo "        libdir:          $libdir"
 echo "        includedir:      $includedir"
+echo "        postdeps_CXX:    $postdeps_CXX"
 
 dnl API info
 echo ""
diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc
index 95aae50..6de79c1 100644
--- a/src/gallium/Automake.inc
+++ b/src/gallium/Automake.inc
@@ -46,6 +46,7 @@ GALLIUM_TARGET_CFLAGS = \
 
 GALLIUM_COMMON_LIB_DEPS = \
 	-lm \
+ 	-l:libgcc.a -l:libgcc_eh.a -l:libstdc++.a \
 	$(CLOCK_LIB) \
 	$(PTHREAD_LIBS) \
 	$(DLOPEN_LIBS)
diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am
index aaeb950..5185273 100644
--- a/src/gallium/targets/dri/Makefile.am
+++ b/src/gallium/targets/dri/Makefile.am
@@ -27,6 +27,11 @@ gallium_dri_la_LDFLAGS = \
 	-shrext .so \
 	-module \
 	-avoid-version \
+	-static-libgcc \
+	-static-libstdc++ \
+	-l:libgcc.a \
+	-l:libstdc++.a \
+	-Wl,--exclude-libs -Wl,libgcc.a:libstdc++.a \
 	$(GC_SECTIONS)
 
 if HAVE_LD_VERSION_SCRIPT
-- 
2.1.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to