[cairo-commit] 2 commits - src/cairo-compiler-private.h src/cairoint.h src/check-def.sh src/check-has-hidden-symbols.c src/check-plt.sh src/compiler-supports-visibility.c src/Makefile.am
Chris Wilson
ickle at kemper.freedesktop.org
Fri Jan 11 12:27:58 PST 2008
src/Makefile.am | 12 ++++++++----
src/cairo-compiler-private.h | 5 ++---
src/cairoint.h | 5 +++++
src/check-def.sh | 11 ++++++-----
src/check-has-hidden-symbols.c | 12 ++++++++++++
src/check-plt.sh | 14 ++++++++------
src/compiler-supports-visibility.c | 6 ------
7 files changed, 41 insertions(+), 24 deletions(-)
New commits:
commit 8a6a0b43dc249acb0ad8cb9c6f16360294bcfdc3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jan 11 18:47:19 2008 +0000
[check] Replace compiled symbol visibility checker with shell script.
Behdad Esfahbod objected to the execution of a compiled program to check
symbol visibility as it makes cross-compilation more difficult.
Instead of executing the program, this method conditionally exports
a variable if cairo uses symbol hiding and scans the executable for
that symbol in a similar manner to check-def.sh. This has the slight
advantage of using the Makefile for performing the compilation, rather
than attempting to invoke $(CPP) from a shell script within the test
environment.
diff --git a/src/Makefile.am b/src/Makefile.am
index f3657c8..f9e2eb7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -320,10 +320,14 @@ TESTS_ENVIRONMENT = srcdir="$(srcdir)" MAKE="$(MAKE)"
TESTS = check-def.sh check-plt.sh check-headers.sh check-cairoint.sh
EXTRA_DIST += $(TESTS)
-check-def.sh check-plt.sh: compiler-supports-visibility$(EXEEXT)
-EXTRA_PROGRAMS = compiler-supports-visibility
-CLEANFILES += $(EXTRA_PROGRAMS)
-compiler_supports_visibility_CFLAGS = -I$(srcdir) $(CAIRO_CFLAGS)
+check-def.sh check-plt.sh: .check-has-hidden-symbols
+
+EXTRA_PROGRAMS = check-has-hidden-symbols
+CLEANFILES += $(EXTRA_PROGRAMS) .check-has-hidden-symbols
+
+check_has_hidden_symbols_CFLAGS = -I$(srcdir) $(CAIRO_CFLAGS)
+.check-has-hidden-symbols: check-has-hidden-symbols$(EXEEXT)
+ @nm check-has-hidden-symbols$(EXEEXT) 2>/dev/null | grep cairo_has_hidden_symbols 2>/dev/null >/dev/null && echo 1 > $@ || echo 0 > $@
SPARSE = sparse
sparse:
diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index 14aef47..758cde5 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -70,15 +70,14 @@ CAIRO_BEGIN_DECLS
#endif
/* slim_internal.h */
+#define CAIRO_HAS_HIDDEN_SYMBOLS 1
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
#define cairo_private_no_warn __attribute__((__visibility__("hidden")))
-#define CAIRO_HAS_HIDDEN_SYMBOLS 1
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
#define cairo_private_no_warn __hidden
-#define CAIRO_HAS_HIDDEN_SYMBOLS 1
#else /* not gcc >= 3.3 and not Sun Studio >= 8 */
#define cairo_private_no_warn
-#define CAIRO_HAS_HIDDEN_SYMBOLS 0
+#undef CAIRO_HAS_HIDDEN_SYMBOLS
#endif
#ifndef WARN_UNUSED_RESULT
diff --git a/src/check-def.sh b/src/check-def.sh
index a2e736a..334ec6d 100755
--- a/src/check-def.sh
+++ b/src/check-def.sh
@@ -2,11 +2,6 @@
LANG=C
-if ! ./compiler-supports-visibility; then
- echo "Compiler doesn't support symbol visibility; skipping test"
- exit 0
-fi
-
if ! which nm 2>/dev/null >/dev/null; then
echo "'nm' not found; skipping test"
exit 0
@@ -16,6 +11,12 @@ test -z "$srcdir" && srcdir=.
test -z "$MAKE" && MAKE=make
status=0
+has_hidden_symbols=`cat .check-has-hidden-symbols`
+if test "x$has_hidden_symbols" != "x1"; then
+ echo "Compiler doesn't support symbol visibility; skipping test"
+ exit 0
+fi
+
get_cairo_syms='nm "$so" | grep " T " | cut -d" " -f3'
if [ "`uname -s`" = "Linux" ]; then
get_cairo_syms='objdump -t "$so" | sed -n "/.*g *F *\.\(opd\|text\).* \(.*cairo_.*\)$/s//\2/p"'
diff --git a/src/check-has-hidden-symbols.c b/src/check-has-hidden-symbols.c
new file mode 100644
index 0000000..2fb120d
--- /dev/null
+++ b/src/check-has-hidden-symbols.c
@@ -0,0 +1,12 @@
+#include "cairoint.h"
+
+#if CAIRO_HAS_HIDDEN_SYMBOLS
+extern cairo_public int cairo_has_hidden_symbols;
+int cairo_has_hidden_symbols;
+#endif
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/src/check-plt.sh b/src/check-plt.sh
index 05cde35..3007fb9 100755
--- a/src/check-plt.sh
+++ b/src/check-plt.sh
@@ -2,15 +2,17 @@
LANG=C
-status=0
-
-if ! ./compiler-supports-visibility; then
- echo "Compiler doesn't support symbol visibility; skipping test"
+if ! which readelf 2>/dev/null >/dev/null; then
+ echo "'readelf' not found; skipping test"
exit 0
fi
-if ! which readelf 2>/dev/null >/dev/null; then
- echo "'readelf' not found; skipping test"
+test -z "$srcdir" && srcdir=.
+status=0
+
+has_hidden_symbols=`cat .check-has-hidden-symbols`
+if test "x$has_hidden_symbols" != "x1"; then
+ echo "Compiler doesn't support symbol visibility; skipping test"
exit 0
fi
diff --git a/src/compiler-supports-visibility.c b/src/compiler-supports-visibility.c
deleted file mode 100644
index 488c97c..0000000
--- a/src/compiler-supports-visibility.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "cairoint.h"
-
-int main (void)
-{
- return ! CAIRO_HAS_HIDDEN_SYMBOLS;
-}
commit 982f65081f987e2c44f05942411c031bd32fd968
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Jan 11 17:25:33 2008 +0000
[cairoint.h] Compile time check for a font backend.
Add a paranoid check that at least one font backend is available - this
should have been already caught by configure, but it should help if a new
font backend is ever added.
diff --git a/src/cairoint.h b/src/cairoint.h
index ce74db0..efdf0f7 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -847,6 +847,11 @@ typedef struct _cairo_traps {
#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_FT_FONT_FAMILY_DEFAULT
#define CAIRO_SCALED_FONT_BACKEND_DEFAULT &cairo_ft_scaled_font_backend
+#else
+
+/* Paranoia: this should have been caught by configure. */
+#error No font backends are available.
+
#endif
#define CAIRO_GSTATE_OPERATOR_DEFAULT CAIRO_OPERATOR_OVER
More information about the cairo-commit
mailing list