aboutsummaryrefslogtreecommitdiff
path: root/m4/visibility.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/visibility.m4')
-rw-r--r--m4/visibility.m449
1 files changed, 37 insertions, 12 deletions
diff --git a/m4/visibility.m4 b/m4/visibility.m4
index 2ff6330aa..552e39772 100644
--- a/m4/visibility.m4
+++ b/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 1 (gettext-0.15) 1# visibility.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2005 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008, 2010-2014 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ dnl __attribute__((__visibility__("hidden"))) and
12dnl __attribute__((__visibility__("default"))). 12dnl __attribute__((__visibility__("default"))).
13dnl Does *not* test for __visibility__("protected") - which has tricky 13dnl Does *not* test for __visibility__("protected") - which has tricky
14dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on 14dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
15dnl MacOS X. 15dnl Mac OS X.
16dnl Does *not* test for __visibility__("internal") - which has processor 16dnl Does *not* test for __visibility__("internal") - which has processor
17dnl dependent semantics. 17dnl dependent semantics.
18dnl Does *not* test for #pragma GCC visibility push(hidden) - which is 18dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
@@ -26,18 +26,43 @@ AC_DEFUN([gl_VISIBILITY],
26 CFLAG_VISIBILITY= 26 CFLAG_VISIBILITY=
27 HAVE_VISIBILITY=0 27 HAVE_VISIBILITY=0
28 if test -n "$GCC"; then 28 if test -n "$GCC"; then
29 dnl First, check whether -Werror can be added to the command line, or
30 dnl whether it leads to an error because of some other option that the
31 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_MSG_CHECKING([whether the -Werror option is usable])
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [
34 gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror"
36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])],
38 [gl_cv_cc_vis_werror=yes],
39 [gl_cv_cc_vis_werror=no])
40 CFLAGS="$gl_save_CFLAGS"])
41 AC_MSG_RESULT([$gl_cv_cc_vis_werror])
42 dnl Now check whether visibility declarations are supported.
29 AC_MSG_CHECKING([for simple visibility declarations]) 43 AC_MSG_CHECKING([for simple visibility declarations])
30 AC_CACHE_VAL(gl_cv_cc_visibility, [ 44 AC_CACHE_VAL([gl_cv_cc_visibility], [
31 gl_save_CFLAGS="$CFLAGS" 45 gl_save_CFLAGS="$CFLAGS"
32 CFLAGS="$CFLAGS -fvisibility=hidden" 46 CFLAGS="$CFLAGS -fvisibility=hidden"
33 AC_TRY_COMPILE( 47 dnl We use the option -Werror and a function dummyfunc, because on some
34 [extern __attribute__((__visibility__("hidden"))) int hiddenvar; 48 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
35 extern __attribute__((__visibility__("default"))) int exportedvar; 49 dnl "visibility attribute not supported in this configuration; ignored"
36 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 50 dnl at the first function definition in every compilation unit, and we
37 extern __attribute__((__visibility__("default"))) int exportedfunc (void);], 51 dnl don't want to use the option in this case.
38 [], 52 if test $gl_cv_cc_vis_werror = yes; then
39 gl_cv_cc_visibility=yes, 53 CFLAGS="$CFLAGS -Werror"
40 gl_cv_cc_visibility=no) 54 fi
55 AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM(
57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
58 extern __attribute__((__visibility__("default"))) int exportedvar;
59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
60 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
61 void dummyfunc (void) {}
62 ]],
63 [[]])],
64 [gl_cv_cc_visibility=yes],
65 [gl_cv_cc_visibility=no])
41 CFLAGS="$gl_save_CFLAGS"]) 66 CFLAGS="$gl_save_CFLAGS"])
42 AC_MSG_RESULT([$gl_cv_cc_visibility]) 67 AC_MSG_RESULT([$gl_cv_cc_visibility])
43 if test $gl_cv_cc_visibility = yes; then 68 if test $gl_cv_cc_visibility = yes; then