shithub: freetype+ttf2subf

Download patch

ref: f4a3255d450e18e4981074ef9a42a2318f9e7cbc
parent: 036bdc0c9a4fb55b4fe5a7276e97b70b95c8a260
author: Alexei Podtelezhnikov <apodtele@gmail.com>
date: Sat Feb 3 19:09:02 EST 2018

[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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2018-02-04  Alexei Podtelezhnikov  <apodtele@gmail.com>
+
+	[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  <wl@gnu.org>
 
 	[truetype] Better protection against invalid VF data.
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -299,6 +299,18 @@
 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).
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -454,9 +454,9 @@
 #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 @@
   /*                                                                       */
 #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 */
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -406,9 +406,9 @@
 #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 @@
   /*                                                                       */
 #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 */
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -422,9 +422,9 @@
 #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 @@
   /*                                                                       */
 #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 */
--