From patchwork Wed Jul 30 13:48:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 4649381 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 08B1BC0338 for ; Wed, 30 Jul 2014 13:48:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1ADAC2012B for ; Wed, 30 Jul 2014 13:48:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A73FF20149 for ; Wed, 30 Jul 2014 13:48:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63BC16E61B; Wed, 30 Jul 2014 06:48:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by gabe.freedesktop.org (Postfix) with ESMTP id B69556E617; Wed, 30 Jul 2014 06:48:10 -0700 (PDT) Received: by mail-wi0-f169.google.com with SMTP id n3so7053224wiv.2 for ; Wed, 30 Jul 2014 06:48:09 -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=yLddg4b/tDLL7fOhvq9iXZam6xZLOJg1nxcVXl1BQVE=; b=DPuQMjz6KgztZ+l9fC/KngsXffeSk2PokdCXUUVGWLF1KN0mtZGWRj3iaEXXaKIyX9 XXr7xOvnJQYAyJqyZ8xh8MhEGu9+X1BUleLrobyfX5so/mG+JiV+Wg77ICzTOrX0JVSf 21LiX3zZ4StiZnqoa/JnbkfnUxFQYkBZ4mUDyz3mj1du2zlXStcZtrcZKgvTjdlDPWjN 7rPWrCPYtFVk2KnFhyFT9p2fZKT1WQztC4oEkaGJImJ5wKloRC0pCkGwK8UzWpoEP6Pd s8StyO6aUqtIQgfldsEjEUUY0XvNjgb2sDkOubWlLF8vKDzqliFaCVyLNk/gsrh7Lr+2 4m8Q== X-Received: by 10.180.198.173 with SMTP id jd13mr7351703wic.9.1406728089102; Wed, 30 Jul 2014 06:48:09 -0700 (PDT) Received: from localhost (port-91976.pppoe.wtnet.de. [84.46.71.192]) by mx.google.com with ESMTPSA id o2sm55563846wij.24.2014.07.30.06.48.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jul 2014 06:48:08 -0700 (PDT) From: Thierry Reding To: Emil Velikov Subject: [PATCH libdrm] configure: Support symbol visibility when available Date: Wed, 30 Jul 2014 15:48:05 +0200 Message-Id: <1406728085-981-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.0.3 In-Reply-To: <53D8E68D.3090503@gmail.com> References: <53D8E68D.3090503@gmail.com> MIME-Version: 1.0 Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Julien Cristau 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=-4.8 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. 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 Reviewed-by: Emil Velikov --- Changes in v3: - distribute libdrm.h Makefile.am | 1 + configure.ac | 20 ++++++++++++++++++++ libdrm.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 libdrm.h diff --git a/Makefile.am b/Makefile.am index 826c30d0c0d9..65680da963eb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -69,6 +69,7 @@ libdrm_la_SOURCES = \ xf86drmSL.c \ xf86drmMode.c \ xf86atomic.h \ + libdrm.h \ libdrm_lists.h libdrmincludedir = ${includedir} diff --git a/configure.ac b/configure.ac index 1c78c4520c49..f7c7177bfb2a 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