From patchwork Wed Apr 9 11:40:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3954911 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5CE039F38C for ; Wed, 9 Apr 2014 11:41:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6322A2055C for ; Wed, 9 Apr 2014 11:41:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DFA7620551 for ; Wed, 9 Apr 2014 11:41:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C30F6EB18; Wed, 9 Apr 2014 04:41:32 -0700 (PDT) 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 9CF8C6EB18 for ; Wed, 9 Apr 2014 04:41:28 -0700 (PDT) Received: by mail-bk0-f52.google.com with SMTP id my13so2171890bkb.25 for ; Wed, 09 Apr 2014 04:41:26 -0700 (PDT) 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 :mime-version:content-type:content-transfer-encoding; bh=sSEp1Rty1BONOj8bQv/9deIOw99dRMSmz/MBJvEcmPc=; b=z0oApbri1NjpRl9dR+RTCMElcywWp9k96a0RnfrwVVOEzgL+8/uUI5Q0FdSFuiCS5c RxD5oQyChBEw2et4ZMVkE167Rua+yRqZGUBgkv2zcYObOwT3GO/H6FxgVTOHzyGL5T+B gYZ8ZQ1RMxiUBOJ8tqijkwUqS0SjIxrZwu9lK/sTpxEIho3KKJdLR5EYM/P8iuDysakQ gbAQBmyRpXljqrvhZz6j+qSG5APba0GlwV0uZF+EheoCaYTY3clEHwgQ4GuVKU6gFCzd jr2BuYevhznnSoQq2OjilVEzoK74PPijWxZ/5izb/PKeQ1wiKBTBm4PCINPpBjWSJYHq l65A== X-Received: by 10.204.71.198 with SMTP id i6mr41045bkj.58.1397043686250; Wed, 09 Apr 2014 04:41:26 -0700 (PDT) Received: from localhost (port-93174.pppoe.wtnet.de. [84.46.76.115]) by mx.google.com with ESMTPSA id zl9sm1851483bkb.11.2014.04.09.04.41.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Apr 2014 04:41:25 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 libdrm 1/7] configure: Support symbol visibility when available Date: Wed, 9 Apr 2014 13:40:24 +0200 Message-Id: <1397043630-13972-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1397043630-13972-1-git-send-email-thierry.reding@gmail.com> References: <1397043630-13972-1-git-send-email-thierry.reding@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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. By default all symbols will be hidden via the VISIBILITY_CFLAGS. The drm_public macro can be used to mark symbols that should be exported. Signed-off-by: Thierry Reding --- configure.ac | 20 ++++++++++++++++++++ libdrm.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 libdrm.h diff --git a/configure.ac b/configure.ac index b7eef9673a20..22b45cc7560d 100644 --- a/configure.ac +++ b/configure.ac @@ -366,6 +366,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 diff --git a/libdrm.h b/libdrm.h new file mode 100644 index 000000000000..23926e6f6741 --- /dev/null +++ b/libdrm.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2014 NVIDIA Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LIBDRM_LIBDRM_H +#define LIBDRM_LIBDRM_H + +#if defined(HAVE_VISIBILITY) +# define drm_private __attribute__((visibility("hidden"))) +# define drm_public __attribute__((visibility("default"))) +#else +# define drm_private +# define drm_public +#endif + +#endif