The first three attached patches make it possible to compile Mesa with
LLVM/Clang:
1. Add -lstdc++ when linking glsl_compiler and glcpp
2. Move -lstdc++ from the Gallium-specific Makefile.dri to
DRI_LIB_DEPS in configure (fixes linking classic Mesa drivers)
3. Since autoconf gives GCC=yes even when using clang (since it just
tests for the __GNUC__ macro), don't check for a minimum version of
3.3 if $(CC) points to a clang executable. (unfortunately I'm not sure
how to properly detect clang, short of test-compiling a file that
contains #ifdef __clang__. I.e. if $(CC) = 'cc', and 'cc' is an
alternatives symlink to llvm-clang, this doesn't detect that case.)

The rest are just fixes to compiler warnings:
4. dri: Fix implicit declaration
5. program: Fix struct/class confusion
6. dr/radeon: Fix printf format
7. llvmpipe: Fix memory leak

With the first three patches, I can compile Mesa with clang 2.7 in
Ubuntu Lucid if I export three variables before configure:
export CC=llvm-clang
export CXX=llvm-clang
export CPPFLAGS=/usr/lib/clang/1.1/include
./configure
(Yeah, the third one is really prone to breakage with new versions and
I'm still trying to figure out how to not need it; it should also get
passed as part of MKDEP_OPTIONS in configure.ac, TBH.)
From 5bd1fd451f459ceede759877d06a846fcc27f29f Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 04:37:28 +0000
Subject: [PATCH] glsl: Add -lstdc++ linkage

Fixes "undefined reference to `__gxx_personality_v0'" error
when linking with a non-g++ compiler (e.g. llvm-clang).
---
 src/glsl/Makefile    |    3 ++-
 src/glsl/Makefile.am |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/glsl/Makefile b/src/glsl/Makefile
index 1d200b4..64016d2 100644
--- a/src/glsl/Makefile
+++ b/src/glsl/Makefile
@@ -75,7 +75,8 @@ CXX_SOURCES = \
 
 LIBS = \
 	$(TOP)/src/glsl/libglsl.a \
-	$(shell pkg-config --libs talloc)
+	$(shell pkg-config --libs talloc) \
+	-lstdc++
 
 APPS = glsl_compiler glcpp/glcpp
 
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 5728a8b..a683598 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -28,7 +28,7 @@ SUBDIRS = glcpp
 bin_PROGRAMS = glsl
 
 glsl_LDADD = ./glcpp/libglcpp.la
-glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS)
+glsl_LDFLAGS = @LDFLAGS@ $(talloc_LIBS) -lstdc++
 glsl_SOURCES = \
 	main.cpp \
 	builtin_types.h \
-- 
1.5.4.3

From ebeb533110e8d0a9afd716c058a9e99024d124cc Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 04:37:53 +0000
Subject: [PATCH] Move -lstdc++ to DRI_LIB_DEPS

Fixes "undefined reference to `operator new[](unsigned int)'"
error when linking classic drivers with a non-g++ compiler
(e.g. llvm-clang).
---
 configure.ac                     |    3 ++-
 src/gallium/targets/Makefile.dri |    2 --
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3d86dec..c319c1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -855,7 +855,8 @@ if test "$mesa_driver" = dri; then
         [AC_MSG_ERROR([Expat required for DRI.])])
 
     # put all the necessary libs together
-    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread $DLOPEN_LIBS $TALLOC_LIBS"
+    DRI_LIB_DEPS="$SELINUX_LIBS $LIBDRM_LIBS $EXPAT_LIB -lm -lpthread \
+        $DLOPEN_LIBS $TALLOC_LIBS -lstdc++"
 fi
 AC_SUBST([DRI_DIRS])
 AC_SUBST([EXPAT_INCLUDES])
diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
index 59961e9..d487481 100644
--- a/src/gallium/targets/Makefile.dri
+++ b/src/gallium/targets/Makefile.dri
@@ -5,8 +5,6 @@ ifeq ($(MESA_LLVM),1)
 PIPE_DRIVERS += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
 LDFLAGS += $(LLVM_LDFLAGS)
 DRIVER_EXTRAS = $(LLVM_LIBS)
-else
-LDFLAGS += -lstdc++
 endif
 
 MESA_MODULES = \
-- 
1.5.4.3

From dd4a3298e7594edb835731afef57de13838d9a98 Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 06:42:32 +0000
Subject: [PATCH] Make configure work with clang

It was mistaking clang for gcc and deciding its version
was too low.
---
 configure.ac |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index c319c1e..e6ba34b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,9 +48,20 @@ solaris*)
     ;;
 esac
 
+dnl This is to hack around the GCC=yes false positive with clang,
+dnl since it's mostly GCC-compatible, but its version is much lower.
+case "$CC" in
+*clang*)
+    CLANG=yes
+    ;;
+*)
+    CLANG=no
+    ;;
+esac
+
 dnl If we're using GCC, make sure that it is at least version 3.3.0.  Older
 dnl versions are explictly not supported.
-if test "x$GCC" = xyes; then
+if test "x$GCC" = xyes -a "x$CLANG" = xno; then
     AC_MSG_CHECKING([whether gcc version is sufficient])
     major=0
     minor=0
-- 
1.5.4.3

From 375788bcdd310abd0a5f2c03858750028ddb02b4 Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 05:15:30 +0000
Subject: [PATCH] dri: Fix 'implicit declaration'

Fixes "warning: implicit declaration of function
'_mesa_destroy_shader_compiler' is invalid in C99"
---
 src/mesa/drivers/dri/common/dri_util.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index b1a7b3e..57669bf 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -33,6 +33,9 @@
 #include "utils.h"
 #include "xmlpool.h"
 
+/* from src/glsl/glsl_parser_extras.{h,cpp} */
+extern void _mesa_destroy_shader_compiler();
+
 PUBLIC const char __dri2ConfigOptions[] =
    DRI_CONF_BEGIN
       DRI_CONF_SECTION_PERFORMANCE
-- 
1.5.4.3

From 7cdf40a8bbcf8ce018a61c3a80dd0c536df0aac6 Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 05:16:53 +0000
Subject: [PATCH] program: Fix struct/class confusion

---
 src/mesa/program/ir_to_mesa.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 9fdeaa9..d9bba05 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1543,7 +1543,7 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir)
    if (deref_var && strncmp(deref_var->var->name,
 			    "gl_TextureMatrix",
 			    strlen("gl_TextureMatrix")) == 0) {
-      struct variable_storage *entry;
+      variable_storage *entry;
 
       entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var,
 				     ir->array_index);
-- 
1.5.4.3

From bc26919575c6236eed0218de726c1431bb713a54 Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 05:17:41 +0000
Subject: [PATCH] dri/radeon: Fix printf format

---
 src/mesa/drivers/dri/radeon/radeon_dma.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c
index 31a4516..53ff548 100644
--- a/src/mesa/drivers/dri/radeon/radeon_dma.c
+++ b/src/mesa/drivers/dri/radeon/radeon_dma.c
@@ -181,7 +181,7 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size)
 	if (size > rmesa->dma.minimum_size)
 		rmesa->dma.minimum_size = (size + 15) & (~15);
 
-	radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %Zi\n",
+	radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %zu\n",
 			__FUNCTION__, size, rmesa->dma.minimum_size);
 
 	if (is_empty_list(&rmesa->dma.free)
-- 
1.5.4.3

From c69eae787fd64f8519db5c002930799d7855e314 Mon Sep 17 00:00:00 2001
From: nobled <nob...@dreamwidth.org>
Date: Sun, 22 Aug 2010 05:18:15 +0000
Subject: [PATCH] llvmpipe: Fix memory leak

---
 src/gallium/drivers/llvmpipe/lp_setup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 556e571..cb3da91 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -54,6 +54,7 @@
 #include "state_tracker/sw_winsys.h"
 
 #include "draw/draw_context.h"
+#include "draw/draw_pipe.h"
 #include "draw/draw_vbuf.h"
 
 
@@ -838,6 +839,8 @@ lp_setup_destroy( struct lp_setup_context *setup )
       lp_scene_destroy(scene);
    }
 
+   setup->vbuf->destroy(setup->vbuf);
+
    lp_scene_queue_destroy(setup->empty_scenes);
 
    FREE( setup );
@@ -891,7 +894,7 @@ lp_setup_create( struct pipe_context *pipe,
 
 fail:
    if (setup->vbuf)
-      ;
+      setup->vbuf->destroy(setup->vbuf);
 
    if (setup->empty_scenes)
       lp_scene_queue_destroy(setup->empty_scenes);
-- 
1.5.4.3

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

Reply via email to