All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: dri-devel@lists.freedesktop.org
Subject: [RFC libdrm 1/6] configure: Support symbol visibility when available
Date: Wed, 19 Feb 2014 17:04:48 +0100	[thread overview]
Message-ID: <1392825893-7380-2-git-send-email-thierry.reding@gmail.com> (raw)
In-Reply-To: <1392825893-7380-1-git-send-email-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

Checks whether or not the compiler supports the -fvisibility option. If
so it sets the VISIBILITY_CFLAGS variable which can be added to the per
directory AM_CFLAGS where appropriate.

Libraries can use the HAVE_VISIBILITY preprocessor definition to check
for availability and use something like this:

	#if defined(HAVE_VISIBILITY)
	#  define drm_private __attribute__((visibility("hidden")))
	#  define drm_public __attribute__((visibility("default")))
	#else
	#  define drm_private
	#  define drm_public
	#endif

By default all symbols will be hidden via the VISIBILITY_CFLAGS. Only
symbols explicitly marked drm_public will be exported.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 configure.ac | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/configure.ac b/configure.ac
index d2d19d66dc17..3f4164238494 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,6 +365,26 @@ AC_ARG_WITH([kernel-source],
 	    [kernel_source="$with_kernel_source"])
 AC_SUBST(kernel_source)
 
+dnl Add flags for gcc and g++
+if test "x$GCC" = xyes; then
+    # Enable -fvisibility=hidden if using a gcc that supports it
+    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
+
+    if test "x$VISIBILITY_CFLAGS" != x; then
+        AC_DEFINE(HAVE_VISIBILITY, 1, [Compiler has -fvisibility support])
+    fi
+
+    AC_SUBST([VISIBILITY_CFLAGS])
+fi
+
 AC_SUBST(WARN_CFLAGS)
 AC_CONFIG_FILES([
 	Makefile
-- 
1.8.4.2

  reply	other threads:[~2014-02-19 16:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 16:04 [RFC libdrm 0/6] Add NVIDIA Tegra support Thierry Reding
2014-02-19 16:04 ` Thierry Reding [this message]
2014-02-19 21:05   ` [RFC libdrm 1/6] configure: Support symbol visibility when available Erik Faye-Lund
2014-02-19 21:50     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 2/6] libdrm: Add NVIDIA Tegra support Thierry Reding
2014-02-19 19:59   ` Rémi Cardona
2014-02-19 20:03   ` Erik Faye-Lund
2014-02-19 21:33     ` Thierry Reding
2014-02-19 20:13   ` Erik Faye-Lund
2014-02-19 21:32     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 3/6] tegra: Add simple test for drm_tegra_open() Thierry Reding
2014-02-19 20:19   ` Erik Faye-Lund
2014-02-19 20:50     ` Erik Faye-Lund
2014-02-19 21:34   ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 4/6] tegra: Add channel, job, pushbuf and fence APIs Thierry Reding
2014-02-19 19:57   ` Erik Faye-Lund
2014-02-19 21:11     ` Thierry Reding
2014-02-19 16:04 ` [RFC libdrm 5/6] tegra: Add helper library for tests Thierry Reding
2014-02-19 20:54   ` Erik Faye-Lund
2014-02-19 16:04 ` [RFC libdrm 6/6] tegra: Add gr2d-fill test Thierry Reding
2014-02-19 21:03   ` Erik Faye-Lund
2014-02-19 21:49     ` Thierry Reding
2014-03-20 15:23 ` [RFC libdrm 0/6] Add NVIDIA Tegra support Erik Faye-Lund
2014-04-08 12:58   ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392825893-7380-2-git-send-email-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.