[Mesa-dev] [PATCH] Allow static libstdc++/libgcc linking if selected

Vivek Das Mohapatra vivek at collabora.com
Fri Mar 13 15:39:17 PDT 2015


As requested - The previous patch to enable static libstdc++/libgcc
linking but now controlled by a configure option:

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

diff --git a/configure.ac b/configure.ac
index 90c7737..10ff070 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
@@ -2450,6 +2478,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
-- 
1.7.10.4



More information about the mesa-dev mailing list