summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-01-24 17:43:59 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2017-01-25 12:43:17 +0000
commit7a06803465dd07e152de1b30763d6bea0d3fcc93 (patch)
treeca0a4b11d4d107acd32cf39bce7fe4f497303ad0 /configure.ac
parent0625a74d69f762df8d411bc0451927424aee1f2c (diff)
downloadlibepoxy-7a06803465dd07e152de1b30763d6bea0d3fcc93.tar.gz
Improve consistency of the symbol visibility
To avoid a symbols file on Windows, Epoxy annotates all the publicly visible symbols directly in the source, but uses the default symbol visibility everywhere else. This means that only some symbols are annotated as `EPOXY_IMPORTEXPORT`, and generally only on Windows. Additionally, Epoxy has a private 'PUBLIC' pre-processor macro for internal use, which duplicates the `EPOXY_IMPORTEXPORT` but contains more logic to detect GCC, in case we're building with GCC on Windows. This would be enough, except that EGL is also available on Windows, which means we'd have to annotate the exported `epoxy_*` API inside epoxy/egl.h as well. At that point, though, we should probably avoid any confusion, and adopt a single symbol visibility policy across the board. This requires some surgery of the generated and common dispatch sources, but cuts down the overall complexity: - there is only one annotation, `EPOXY_PUBLIC`, used everywhere - the annotation detection is done at Epoxy configuration time - only annotated symbols are public, on every platform - annotated symbols are immediately visible from the header
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac52
1 files changed, 33 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac
index e733267..e5a6ba0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,25 +125,39 @@ AM_CONDITIONAL(HAS_GLES1, test x$has_gles1 = xyes)
AC_CHECK_LIB([dl], [dlopen], [DLOPEN_LIBS="-ldl"])
AC_SUBST([DLOPEN_LIBS])
-case $host_os in
- mingw*)
- # visibility flags aren't supported for windows DLLs, and the
- # compiler whines to tell you so, so don't set them up.
- ;;
- *)
- if test "x$GCC" = xyes; then
- save_CFLAGS="$CFLAGS"
- AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
- VISIBILITY_CFLAGS="-fvisibility=hidden"
- CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
- AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
- [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
-
- # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
- CFLAGS=$save_CFLAGS
- fi
- ;;
-esac
+VISIBILITY_CFLAGS=""
+AS_CASE(["$host"],
+
+ [*-*-mingw*], [
+ dnl on mingw32 we do -fvisibility=hidden and __declspec(dllexport)
+ AC_DEFINE([EPOXY_PUBLIC],
+ [__attribute__((visibility("default"))) __declspec(dllexport) extern],
+ [defines how to decorate public symbols while building])
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+ ],
+
+ [
+ dnl on other compilers, check if we can do -fvisibility=hidden
+ SAVED_CFLAGS="${CFLAGS}"
+ CFLAGS="-fvisibility=hidden"
+ AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+ AC_TRY_COMPILE([], [int main (void) { return 0; }], [
+ AC_MSG_RESULT(yes)
+ enable_fvisibility_hidden=yes
+ ], [
+ AC_MSG_RESULT(no)
+ enable_fvisibility_hidden=no
+ ])
+ CFLAGS="${SAVED_CFLAGS}"
+
+ AS_IF([test "${enable_fvisibility_hidden}" = "yes"], [
+ AC_DEFINE([EPOXY_PUBLIC],
+ [__attribute__((visibility("default"))) extern],
+ [defines how to decorate public symbols while building])
+ VISIBILITY_CFLAGS="-fvisibility=hidden"
+ ])
+ ]
+)
AC_SUBST([VISIBILITY_CFLAGS])