[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] master f4a3255: [unix] Use -fvisibility=hidden.
From: |
Alexei Podtelezhnikov |
Subject: |
[freetype2] master f4a3255: [unix] Use -fvisibility=hidden. |
Date: |
Sun, 4 Feb 2018 00:10:37 -0500 (EST) |
branch: master
commit f4a3255d450e18e4981074ef9a42a2318f9e7cbc
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>
[unix] Use -fvisibility=hidden.
It is now widely recommended that ELF shared libraries hide symbols
except those with explicit __attribute__((visibility("default"))).
This is supported by all major compilers and should rather be an
option in libtool.
* builds/unix/configure.raw: Add -fvisibility=hidden to CFLAGS.
* builds/unix/ftconfig.in, builds/vms/ftconfig.h,
include/freetype/config/ftconfig.h (FT_EXPORT): Use visibility
attribute.
---
ChangeLog | 14 ++++++++++++++
builds/unix/configure.raw | 12 ++++++++++++
builds/unix/ftconfig.in | 29 ++++++++++++++++++-----------
builds/vms/ftconfig.h | 29 ++++++++++++++++++-----------
include/freetype/config/ftconfig.h | 29 ++++++++++++++++++-----------
5 files changed, 80 insertions(+), 33 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0708e5e..71fd567 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2018-02-04 Alexei Podtelezhnikov <address@hidden>
+
+ [unix] Use -fvisibility=hidden.
+
+ It is now widely recommended that ELF shared libraries hide symbols
+ except those with explicit __attribute__((visibility("default"))).
+ This is supported by all major compilers and should rather be an
+ option in libtool.
+
+ * builds/unix/configure.raw: Add -fvisibility=hidden to CFLAGS.
+ * builds/unix/ftconfig.in, builds/vms/ftconfig.h,
+ include/freetype/config/ftconfig.h (FT_EXPORT): Use visibility
+ attribute.
+
2018-01-27 Werner Lemberg <address@hidden>
[truetype] Better protection against invalid VF data.
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index d76c324..3d17583 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -299,6 +299,18 @@ AC_SUBST([XX_CFLAGS])
AC_SUBST([XX_ANSIFLAGS])
+# It is recommended that shared libraries hide symbols except those with
+# explicit __attribute__((visibility("default"))).
+#
+AC_MSG_CHECKING([for -fvisibility=hidden compiler flag])
+orig_CFLAGS="${CFLAGS}"
+CFLAGS="${CFLAGS} -fvisibility=hidden"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
+ AC_MSG_RESULT(yes),
+ CFLAGS="${orig_CFLAGS}"
+ AC_MSG_RESULT(no))
+
+
# All library tests below try `pkg-config' first. If that fails, a function
# from the library is tested in the traditional autoconf way (zlib, bzip2),
# or a config script is called (libpng).
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index ca90588..b9c21da 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -454,9 +454,9 @@ FT_BEGIN_HEADER
#endif /* !FT_BASE_DEF */
- /* When compiling FreeType as a DLL, some systems/compilers need a */
- /* special attribute in front OR after the return type of function */
- /* declarations. */
+ /* When compiling FreeType as a DLL or DSO with hidden visibility */
+ /* some systems/compilers need a special attribute in front OR after */
+ /* the return type of function declarations. */
/* */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
@@ -487,21 +487,28 @@ FT_BEGIN_HEADER
/* */
#ifndef FT_EXPORT
-#ifdef __cplusplus
+#ifdef FT2_BUILD_LIBRARY
+
+#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#define FT_EXPORT( x ) __declspec( dllexport ) x
+#elif defined( __GNUC__ ) && __GNUC__ >= 4
+#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
+#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
#else
#define FT_EXPORT( x ) extern x
#endif
-#ifdef _WIN32
-#if defined( FT2_BUILD_LIBRARY ) && \
- ( defined( _DLL ) || defined( DLL_EXPORT ) )
-#undef FT_EXPORT
-#define FT_EXPORT( x ) __declspec( dllexport ) x
-#elif defined( FT2_DLLIMPORT )
-#undef FT_EXPORT
+#else
+
+#if defined( FT2_DLLIMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
+#elif defined( __cplusplus )
+#define FT_EXPORT( x ) extern "C" x
+#else
+#define FT_EXPORT( x ) extern x
#endif
+
#endif
#endif /* !FT_EXPORT */
diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h
index d87ea69..021e2c6 100644
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -406,9 +406,9 @@ FT_BEGIN_HEADER
#endif /* !FT_BASE_DEF */
- /* When compiling FreeType as a DLL, some systems/compilers need a */
- /* special attribute in front OR after the return type of function */
- /* declarations. */
+ /* When compiling FreeType as a DLL or DSO with hidden visibility */
+ /* some systems/compilers need a special attribute in front OR after */
+ /* the return type of function declarations. */
/* */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
@@ -439,21 +439,28 @@ FT_BEGIN_HEADER
/* */
#ifndef FT_EXPORT
-#ifdef __cplusplus
+#ifdef FT2_BUILD_LIBRARY
+
+#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#define FT_EXPORT( x ) __declspec( dllexport ) x
+#elif defined( __GNUC__ ) && __GNUC__ >= 4
+#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
+#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
#else
#define FT_EXPORT( x ) extern x
#endif
-#ifdef _WIN32
-#if defined( FT2_BUILD_LIBRARY ) && \
- ( defined( _DLL ) || defined( DLL_EXPORT ) )
-#undef FT_EXPORT
-#define FT_EXPORT( x ) __declspec( dllexport ) x
-#elif defined( FT2_DLLIMPORT )
-#undef FT_EXPORT
+#else
+
+#if defined( FT2_DLLIMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
+#elif defined( __cplusplus )
+#define FT_EXPORT( x ) extern "C" x
+#else
+#define FT_EXPORT( x ) extern x
#endif
+
#endif
#endif /* !FT_EXPORT */
diff --git a/include/freetype/config/ftconfig.h
b/include/freetype/config/ftconfig.h
index 8ff143e..eedebf4 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -422,9 +422,9 @@ FT_BEGIN_HEADER
#endif /* !FT_BASE_DEF */
- /* When compiling FreeType as a DLL, some systems/compilers need a */
- /* special attribute in front OR after the return type of function */
- /* declarations. */
+ /* When compiling FreeType as a DLL or DSO with hidden visibility */
+ /* some systems/compilers need a special attribute in front OR after */
+ /* the return type of function declarations. */
/* */
/* Two macros are used within the FreeType source code to define */
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
@@ -455,21 +455,28 @@ FT_BEGIN_HEADER
/* */
#ifndef FT_EXPORT
-#ifdef __cplusplus
+#ifdef FT2_BUILD_LIBRARY
+
+#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#define FT_EXPORT( x ) __declspec( dllexport ) x
+#elif defined( __GNUC__ ) && __GNUC__ >= 4
+#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
+#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
#else
#define FT_EXPORT( x ) extern x
#endif
-#ifdef _WIN32
-#if defined( FT2_BUILD_LIBRARY ) && \
- ( defined( _DLL ) || defined( DLL_EXPORT ) )
-#undef FT_EXPORT
-#define FT_EXPORT( x ) __declspec( dllexport ) x
-#elif defined( FT2_DLLIMPORT )
-#undef FT_EXPORT
+#else
+
+#if defined( FT2_DLLIMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
+#elif defined( __cplusplus )
+#define FT_EXPORT( x ) extern "C" x
+#else
+#define FT_EXPORT( x ) extern x
#endif
+
#endif
#endif /* !FT_EXPORT */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] master f4a3255: [unix] Use -fvisibility=hidden.,
Alexei Podtelezhnikov <=