From patchwork Wed Feb 19 16:04:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3682151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B7250BF13A for ; Wed, 19 Feb 2014 16:05:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAB1A2016C for ; Wed, 19 Feb 2014 16:05:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BEC94201BA for ; Wed, 19 Feb 2014 16:05:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E33BFF9D57; Wed, 19 Feb 2014 08:05:09 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 9ED65F9D57 for ; Wed, 19 Feb 2014 08:05:00 -0800 (PST) Received: by mail-bk0-f52.google.com with SMTP id e11so270647bkh.11 for ; Wed, 19 Feb 2014 08:04:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1q7fmj2jFJzr5kTMpGwZ1vPmU2Xmw6rWumxjYq4Nbb8=; b=bf3WS5MX3xlgPuLsjvJaCilaYm2HFob1tbXeRIQKooudQcTa3RHMC0VI6ijgp7KG7r O81AD2pufFzxyauN7O0f+f8Ojo0GjfIc7lzqddbyvCe21eSjqNdyUBv3dswQ4pa6dLeE tlex7uIkohNTZbS95zMe8NIGjgZyeZq4AyzDXWMzFAb70NDsZr+ic4STrfyfHvHErwH0 9s8avN38RWhblkXOE3kLrQ9+JUffP2IXCIozyc998Yrvg1dhDfxsAhSbcAdm8l66a5xE iy2ekCw8GOJL1qd8RLWN8x9euEv7AkyDNiuKMsHz5PMe0A5/4OORRX/kQxYPHgCnZKfa orow== X-Received: by 10.205.25.6 with SMTP id rg6mr20434566bkb.10.1392825898288; Wed, 19 Feb 2014 08:04:58 -0800 (PST) Received: from localhost (port-25108.pppoe.wtnet.de. [46.59.159.204]) by mx.google.com with ESMTPSA id yt4sm910291bkb.7.2014.02.19.08.04.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2014 08:04:57 -0800 (PST) From: Thierry Reding 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 Message-Id: <1392825893-7380-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1392825893-7380-1-git-send-email-thierry.reding@gmail.com> References: <1392825893-7380-1-git-send-email-thierry.reding@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding 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 --- 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