[Mesa-dev] [PATCH] gallium/targets: use c++ compiler for linking

Marcin Slusarz marcin.slusarz at gmail.com
Sun Oct 16 05:54:56 PDT 2011


On Sun, Oct 16, 2011 at 02:03:16PM +0200, Marcin Slusarz wrote:
> On Fri, Oct 14, 2011 at 08:22:35AM +0200, Michel Dänzer wrote:
> > On Don, 2011-10-13 at 15:11 -0500, Patrick Baggett wrote:
> > > Well, trivial answer is that Win32 uses some C/C++ runtime provided by
> > > Microsoft, usually something like MSVCR90.DLL (v9.0) etc. Solaris uses
> > > libC.so, for example. As far as I know, only systems where the GNU C/C
> > > ++ compiler is main system compiler (and generally therefore the GNU C
> > > ++ runtime) uses anything named "libstdc++". So I'd expect
> > > Free/Net/OpenBSD + Linux use that naming and probably not much else.
> > > On other commercial UNIXes, if it does exist, it is just
> > > for compatibility with C++ programs compiled using g++.
> > 
> > gcc -lsdtdc++ doesn't even work on all Linux architectures, as libdstdc
> > ++ may require other stuff which is only pulled in implicitly by g++. 
> 
> Thanks.
> 
> > BTW, why does st/xorg need libstdc++ at all without LLVM?
> 
> Good question. I assumed it's needed by some mesa/gallium core, but
> I checked it now and it's only needed by (new) nv50/nvc0 driver code.
> 

I found another cases where -lstdc++ was used with gcc.
Updated patch below.


--
From: Marcin Slusarz <marcin.slusarz at gmail.com>
Subject: [PATCH] gallium/targets: use c++ compiler for linking
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As pointed by Michel Dänzer, gcc -lstdc++ doesn't work on all systems
because it may require other libs which are only pulled in implicitly
by g++. Additionally libstdc++ is GNU-only lib.

So use c++ compiler for linking and remove redundant LDFLAGS += -lstdc++.
---
 configure.ac                           |    2 +-
 src/gallium/targets/Makefile.dri       |    2 --
 src/gallium/targets/Makefile.va        |    4 +---
 src/gallium/targets/Makefile.vdpau     |    4 +---
 src/gallium/targets/Makefile.xorg      |    5 +----
 src/gallium/targets/Makefile.xvmc      |    4 +---
 src/gallium/targets/gbm/Makefile       |    3 +--
 src/gallium/targets/xa-vmwgfx/Makefile |    4 +---
 8 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/configure.ac b/configure.ac
index 49e81ad..a21c9b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1719,7 +1719,7 @@ if test "x$enable_gallium_llvm" = xyes; then
     if test "x$LLVM_CONFIG" != xno; then
 	LLVM_VERSION=`$LLVM_CONFIG --version`
 	LLVM_CFLAGS=`$LLVM_CONFIG --cppflags|sed 's/-DNDEBUG\>//g'`
-	LLVM_LIBS="`$LLVM_CONFIG --libs` -lstdc++"
+	LLVM_LIBS="`$LLVM_CONFIG --libs`
 
 	LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
 	DEFINES="$DEFINES -D__STDC_CONSTANT_MACROS"
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index 857ebfe..a26b3ee 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -4,8 +4,6 @@
 ifeq ($(MESA_LLVM),1)
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 MESA_MODULES = \
diff --git a/src/gallium/targets/Makefile.va b/src/gallium/targets/Makefile.va
index 7ced430..b6ee595 100644
--- a/src/gallium/targets/Makefile.va
+++ b/src/gallium/targets/Makefile.va
@@ -17,8 +17,6 @@ STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/va/libvatracker.a
 ifeq ($(MESA_LLVM),1)
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 # XXX: Hack, VA public funcs aren't exported
@@ -39,7 +37,7 @@ OBJECTS = $(C_SOURCES:.c=.o) \
 default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
 
 $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
-	$(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+	$(MKLIB) -o $(LIBBASENAME) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 		-major $(VA_MAJOR) -minor $(VA_MINOR) $(MKLIB_OPTIONS) \
 		-install $(TOP)/$(LIB_DIR)/gallium \
 		$(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
diff --git a/src/gallium/targets/Makefile.vdpau b/src/gallium/targets/Makefile.vdpau
index c634915..f6b89ad 100644
--- a/src/gallium/targets/Makefile.vdpau
+++ b/src/gallium/targets/Makefile.vdpau
@@ -17,8 +17,6 @@ STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/vdpau/libvdpautracker.a
 ifeq ($(MESA_LLVM),1)
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 # XXX: Hack, VDPAU public funcs aren't exported if we link to libvdpautracker.a :(
@@ -39,7 +37,7 @@ OBJECTS = $(C_SOURCES:.c=.o) \
 default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
 
 $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
-	$(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+	$(MKLIB) -o $(LIBBASENAME) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 		-major $(VDPAU_MAJOR) -minor $(VDPAU_MINOR) $(MKLIB_OPTIONS) \
 		-install $(TOP)/$(LIB_DIR)/gallium \
 		$(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
diff --git a/src/gallium/targets/Makefile.xorg b/src/gallium/targets/Makefile.xorg
index c96eded..0538b2b 100644
--- a/src/gallium/targets/Makefile.xorg
+++ b/src/gallium/targets/Makefile.xorg
@@ -31,10 +31,7 @@ LIBNAME_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
 ifeq ($(MESA_LLVM),1)
 LD = $(CXX)
 LDFLAGS += $(LLVM_LDFLAGS)
-USE_CXX=1
 DRIVER_LINKS += $(LLVM_LIBS) -lm -ldl
-else
-LDFLAGS += -lstdc++
 endif
 
 
@@ -43,7 +40,7 @@ endif
 default: depend $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
 
 $(LIBNAME): $(OBJECTS) Makefile ../Makefile.xorg $(LIBS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES)
-	$(MKLIB) -linker '$(CC)' -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
+	$(MKLIB) -linker '$(CXX)' -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
 
 depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
 	rm -f depend
diff --git a/src/gallium/targets/Makefile.xvmc b/src/gallium/targets/Makefile.xvmc
index 7182356..f0c4779 100644
--- a/src/gallium/targets/Makefile.xvmc
+++ b/src/gallium/targets/Makefile.xvmc
@@ -17,8 +17,6 @@ STATE_TRACKER_LIB = $(TOP)/src/gallium/state_trackers/xorg/xvmc/libxvmctracker.a
 ifeq ($(MESA_LLVM),1)
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 
@@ -40,7 +38,7 @@ OBJECTS = $(C_SOURCES:.c=.o) \
 default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
 
 $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(OBJECTS) $(PIPE_DRIVERS) $(STATE_TRACKER_LIB) $(TOP)/$(LIB_DIR)/gallium Makefile
-	$(MKLIB) -o $(LIBBASENAME) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
+	$(MKLIB) -o $(LIBBASENAME) -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
 		-major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
 		-install $(TOP)/$(LIB_DIR)/gallium \
 		$(OBJECTS) $(STATE_TRACKER_LIB) $(PIPE_DRIVERS) $(LIBS) $(DRIVER_EXTRAS)
diff --git a/src/gallium/targets/gbm/Makefile b/src/gallium/targets/gbm/Makefile
index 3f52aae..78ce306 100644
--- a/src/gallium/targets/gbm/Makefile
+++ b/src/gallium/targets/gbm/Makefile
@@ -117,7 +117,6 @@ pipe_SOURCES += pipe_i965.c
 endif
 
 ifneq ($(findstring nouveau/drm,$(GALLIUM_WINSYS_DIRS)),)
-LDFLAGS += -lstdc++
 pipe_TARGETS += $(PIPE_PREFIX)nouveau.so
 pipe_SOURCES += pipe_nouveau.c
 endif
@@ -157,7 +156,7 @@ $(GBM_EXTRA_TARGETS): $(TOP)/$(LIB_DIR)/gbm/%: %
 	$(INSTALL) $< $(dir $@)
 
 $(pipe_TARGETS): $(PIPE_PREFIX)%.so: pipe_%.o $(pipe_LIBS) $($*_LIBS)
-	$(MKLIB) -o $@ -noprefix -linker '$(CC)' \
+	$(MKLIB) -o $@ -noprefix -linker '$(CXX)' \
 		-ldflags '-L$(TOP)/$(LIB_DIR) $(pipe_LDFLAGS) $(LDFLAGS)' \
 		$(MKLIB_OPTIONS) $< \
 		-Wl,--start-group $(pipe_LIBS) $($*_LIBS) -Wl,--end-group \
diff --git a/src/gallium/targets/xa-vmwgfx/Makefile b/src/gallium/targets/xa-vmwgfx/Makefile
index fecdba6..1ba0820 100644
--- a/src/gallium/targets/xa-vmwgfx/Makefile
+++ b/src/gallium/targets/xa-vmwgfx/Makefile
@@ -33,8 +33,6 @@ OBJECTS = $(SOURCES:.c=.o)
 ifeq ($(MESA_LLVM),1)
 LDFLAGS += $(LLVM_LDFLAGS)
 GALLIUM_AUXILIARIES += $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 ##### RULES #####
@@ -50,7 +48,7 @@ default: $(TOP)/$(LIB_DIR)/gallium/$(XA_LIB_NAME)
 
 # Make the library
 $(TOP)/$(LIB_DIR)/gallium/$(XA_LIB_NAME): depend $(OBJECTS) $(XA_LIB_DEPS)
-	$(MKLIB) -o $(XA_LIB) -linker $(CC) -ldflags '$(LDFLAGS)' \
+	$(MKLIB) -o $(XA_LIB) -linker $(CXX) -ldflags '$(LDFLAGS)' \
 		-major $(XA_MAJOR) -minor $(XA_MINOR) -patch $(XA_TINY) \
 		$(MKLIB_OPTIONS) \
 		-exports $(TOP)/src/gallium/state_trackers/xa/xa_symbols\
-- 
1.7.7



More information about the mesa-dev mailing list