summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2019-03-12 16:53:14 +0100
committerKim Woelders <kim@woelders.dk>2019-03-13 19:25:12 +0100
commit0d88c6d79513bce4d0363ff291c72c179f0cbf8d (patch)
tree9ffaf49352400204d5e0543328d4c21135b711d9
parent2e970c84f810ac354962d98eef86fd5cb33d7575 (diff)
Enable visibility hiding by default
Makes next to no difference in sizes. Let's just do it anyway.
-rw-r--r--api/Makefile.am2
-rw-r--r--configure.ac1
-rw-r--r--epplets/Makefile.am2
-rw-r--r--m4/ec_visibility.m469
4 files changed, 72 insertions, 2 deletions
diff --git a/api/Makefile.am b/api/Makefile.am
index 11083ca..9cdab8f 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -7,7 +7,7 @@ if BUILD_GLX
7EPPLET_LIB_GLX = libepplet_glx.la 7EPPLET_LIB_GLX = libepplet_glx.la
8endif 8endif
9 9
10AM_CPPFLAGS = -I$(top_builddir) $(CWARNFLAGS) 10AM_CPPFLAGS = -I$(top_builddir) $(CWARNFLAGS) $(CFLAGS_VISIBILITY)
11 11
12lib_LTLIBRARIES = libepplet.la $(EPPLET_LIB_GLX) 12lib_LTLIBRARIES = libepplet.la $(EPPLET_LIB_GLX)
13 13
diff --git a/configure.ac b/configure.ac
index 0205e3c..83d44db 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ AC_C_CONST
45AC_C_INLINE 45AC_C_INLINE
46EC_C___ATTRIBUTE__ 46EC_C___ATTRIBUTE__
47EC_C___FUNC__ 47EC_C___FUNC__
48EC_C_VISIBILITY(yes)
48 49
49AC_PATH_XTRA 50AC_PATH_XTRA
50 51
diff --git a/epplets/Makefile.am b/epplets/Makefile.am
index 20d5846..0b95d5a 100644
--- a/epplets/Makefile.am
+++ b/epplets/Makefile.am
@@ -15,7 +15,7 @@ EXTRA_PROGRAMS = EppletTest.epplet EppletConfigTest.epplet E-Mixer.epplet \
15 Emix.epplet E-PlayCD.epplet E-OpenGL-Demo.epplet \ 15 Emix.epplet E-PlayCD.epplet E-OpenGL-Demo.epplet \
16 E-SD.epplet 16 E-SD.epplet
17 17
18AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/api $(IMLIB2_CFLAGS) $(X_CFLAGS) $(LIBGTOP_CFLAGS) $(CWARNFLAGS) 18AM_CPPFLAGS = -I$(top_builddir) -I$(top_builddir)/api $(IMLIB2_CFLAGS) $(X_CFLAGS) $(LIBGTOP_CFLAGS) $(CWARNFLAGS) $(CFLAGS_VISIBILITY)
19LDADD = $(top_builddir)/api/libepplet.la $(X_LIBS) $(KSTAT_LIBS) 19LDADD = $(top_builddir)/api/libepplet.la $(X_LIBS) $(KSTAT_LIBS)
20 20
21################ Conditional Builds ################ 21################ Conditional Builds ################
diff --git a/m4/ec_visibility.m4 b/m4/ec_visibility.m4
new file mode 100644
index 0000000..ed64b12
--- /dev/null
+++ b/m4/ec_visibility.m4
@@ -0,0 +1,69 @@
1# visibility.m4 serial 1 (gettext-0.15)
2dnl Copyright (C) 2005 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Tests whether the compiler supports the command-line option
10dnl -fvisibility=hidden and the function and variable attributes
11dnl __attribute__((__visibility__("hidden"))) and
12dnl __attribute__((__visibility__("default"))).
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
15dnl MacOS X.
16dnl Does *not* test for __visibility__("internal") - which has processor
17dnl dependent semantics.
18dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
19dnl "really only recommended for legacy code".
20dnl Set the variable CFLAGS_VISIBILITY.
21dnl Defines and sets the variable HAVE_VISIBILITY.
22
23dnl Modified for E stuff by Kim Woelders
24
25AC_DEFUN([EC_C_VISIBILITY],
26[
27 AC_REQUIRE([AC_PROG_CC])
28
29 define(ec_c_vis_default, ifelse([$1], [no], [no], [yes]))
30 CFLAGS_VISIBILITY=
31 HAVE_VISIBILITY=0
32
33 AC_ARG_ENABLE([visibility-hiding],
34 [AS_HELP_STRING([--enable-visibility-hiding],
35 [enable visibility hiding @<:@default=]ec_c_vis_default[@:>@])],,
36 [enable_visibility_hiding=]ec_c_vis_default)
37
38 if test -n "$GCC" -a "x$enable_visibility_hiding" = "xyes"; then
39 AC_MSG_CHECKING([for simple visibility declarations])
40 AC_CACHE_VAL(ec_cv_cc_visibility, [
41 ec_save_CFLAGS="$CFLAGS"
42 CFLAGS="$CFLAGS -fvisibility=hidden"
43 AC_COMPILE_IFELSE([
44 AC_LANG_PROGRAM([[
45 ]], [[
46extern __attribute__((__visibility__("hidden"))) int hiddenvar;
47extern __attribute__((__visibility__("default"))) int exportedvar;
48extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
49extern __attribute__((__visibility__("default"))) int exportedfunc (void);
50 ]])
51 ],
52 ec_cv_cc_visibility=yes,
53 ec_cv_cc_visibility=no)
54 CFLAGS="$ec_save_CFLAGS"])
55 AC_MSG_RESULT([$ec_cv_cc_visibility])
56 if test $ec_cv_cc_visibility = yes; then
57 CFLAGS_VISIBILITY="-fvisibility=hidden"
58 HAVE_VISIBILITY=1
59 AC_DEFINE(__EXPORT__, __attribute__((__visibility__("default"))), [Symbol is exported])
60 fi
61 else
62 enable_visibility_hiding=no
63 fi
64
65 AC_SUBST([CFLAGS_VISIBILITY])
66 AC_SUBST([HAVE_VISIBILITY])
67 AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
68 [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
69])