summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Podtelezhnikov <apodtele@gmail.com>2018-07-24 23:01:34 -0400
committerAlexei Podtelezhnikov <apodtele@gmail.com>2018-07-24 23:01:34 -0400
commit4b97ab98a8e90ae5403058b73c345974247bf01e (patch)
treee09d4f4d5844bbae1f598cbe721d993e228bfaed
parentd8ea52dee53defec67cbea8f467f1ad1e971ba25 (diff)
downloadfreetype2-4b97ab98a8e90ae5403058b73c345974247bf01e.tar.gz
[build] Fortify dllexport/dllimport attributes (#53969,#54330).
We no longer use predefined _DLL, which can be defined for static builds too with /MD. We use DLL_EXPORT and DLL_IMPORT instead, following libtool convention. * CMakeLists.txt [WIN32], builds/windows/vc2010/freetype.vcxproj: Define DLL_EXPORT manually. * include/freetype/config/ftconfig.h, builds/unix/ftconfig.in, builds/vms/ftconfig.h, builds/windows/vc2010/index.html, src/base/ftver.rc: /_DLL/d, s/FT2_DLLIMPORT/DLL_IMPORT/.
-rw-r--r--CMakeLists.txt4
-rw-r--r--ChangeLog15
-rw-r--r--builds/unix/ftconfig.in4
-rw-r--r--builds/vms/ftconfig.h4
-rw-r--r--builds/windows/vc2010/freetype.vcxproj16
-rw-r--r--builds/windows/vc2010/index.html2
-rw-r--r--include/freetype/config/ftconfig.h4
-rw-r--r--src/base/ftver.rc2
8 files changed, 35 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f54e68871..3f583373a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,6 +353,10 @@ target_compile_definitions(
if (WIN32)
target_compile_definitions(
freetype PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
+ if (BUILD_SHARED_LIBS)
+ target_compile_definitions(
+ freetype PRIVATE DLL_EXPORT)
+ endif ()
endif ()
if (BUILD_SHARED_LIBS)
diff --git a/ChangeLog b/ChangeLog
index bdfb41c5e..0096724e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2018-07-24 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [build] Fortify dllexport/dllimport attributes (#53969,#54330).
+
+ We no longer use predefined _DLL, which can be defined for static
+ builds too with /MD. We use DLL_EXPORT and DLL_IMPORT instead,
+ following libtool convention.
+
+ * CMakeLists.txt [WIN32], builds/windows/vc2010/freetype.vcxproj:
+ Define DLL_EXPORT manually.
+
+ * include/freetype/config/ftconfig.h, builds/unix/ftconfig.in,
+ builds/vms/ftconfig.h, builds/windows/vc2010/index.html,
+ src/base/ftver.rc: /_DLL/d, s/FT2_DLLIMPORT/DLL_IMPORT/.
+
2018-07-24 Werner Lemberg <wl@gnu.org>
[type1] Check relationship between number of axes and designs.
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index dc4aff75c..cdb7f22e5 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -489,7 +489,7 @@ FT_BEGIN_HEADER
#ifdef FT2_BUILD_LIBRARY
-#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#if defined( _WIN32 ) && defined( DLL_EXPORT )
#define FT_EXPORT( x ) __declspec( dllexport ) x
#elif defined( __GNUC__ ) && __GNUC__ >= 4
#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
@@ -503,7 +503,7 @@ FT_BEGIN_HEADER
#else
-#if defined( FT2_DLLIMPORT )
+#if defined( _WIN32 ) && defined( DLL_IMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h
index 77bca5459..733b09b49 100644
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -441,7 +441,7 @@ FT_BEGIN_HEADER
#ifdef FT2_BUILD_LIBRARY
-#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#if defined( _WIN32 ) && defined( DLL_EXPORT )
#define FT_EXPORT( x ) __declspec( dllexport ) x
#elif defined( __GNUC__ ) && __GNUC__ >= 4
#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
@@ -455,7 +455,7 @@ FT_BEGIN_HEADER
#else
-#if defined( FT2_DLLIMPORT )
+#if defined( _WIN32 ) && defined( DLL_IMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
diff --git a/builds/windows/vc2010/freetype.vcxproj b/builds/windows/vc2010/freetype.vcxproj
index fe2fe6880..7052c6c42 100644
--- a/builds/windows/vc2010/freetype.vcxproj
+++ b/builds/windows/vc2010/freetype.vcxproj
@@ -121,7 +121,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
@@ -135,7 +135,7 @@
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
</ClCompile>
<ResourceCompile>
- <PreprocessorDefinitions>_DEBUG;_DLL;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
@@ -149,7 +149,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT_DEBUG_LEVEL_ERROR;FT_DEBUG_LEVEL_TRACE;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
@@ -163,7 +163,7 @@
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
</ClCompile>
<ResourceCompile>
- <PreprocessorDefinitions>_DEBUG;_DLL;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>_DEBUG;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
@@ -234,7 +234,7 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@@ -258,7 +258,7 @@
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
<ResourceCompile>
- <PreprocessorDefinitions>NDEBUG;_DLL;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
@@ -274,7 +274,7 @@
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(UserOptionDirectory);..\..\..\include;$(UserIncludeDirectories);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;FT2_BUILD_LIBRARY;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
@@ -298,7 +298,7 @@
<OmitFramePointers>true</OmitFramePointers>
</ClCompile>
<ResourceCompile>
- <PreprocessorDefinitions>NDEBUG;_DLL;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>NDEBUG;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
diff --git a/builds/windows/vc2010/index.html b/builds/windows/vc2010/index.html
index c3e604034..634ea9305 100644
--- a/builds/windows/vc2010/index.html
+++ b/builds/windows/vc2010/index.html
@@ -33,7 +33,7 @@ simplifies automated (command-line) builds using <a
href="http://msdn.microsoft.com/library/dd393574%28v=vs.100%29.aspx">msbuild</a>.</p>
<p>To link your executable with FreeType DLL, you may want to define
-FT2_DLLIMPORT so that the imported functions are appropriately
+DLL_IMPORT so that the imported functions are appropriately
attributed with <tt>dllimport<tt>.</p>
</body>
diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h
index b093f6f5f..3d127f8fa 100644
--- a/include/freetype/config/ftconfig.h
+++ b/include/freetype/config/ftconfig.h
@@ -457,7 +457,7 @@ FT_BEGIN_HEADER
#ifdef FT2_BUILD_LIBRARY
-#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
+#if defined( _WIN32 ) && defined( DLL_EXPORT )
#define FT_EXPORT( x ) __declspec( dllexport ) x
#elif defined( __GNUC__ ) && __GNUC__ >= 4
#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
@@ -471,7 +471,7 @@ FT_BEGIN_HEADER
#else
-#if defined( FT2_DLLIMPORT )
+#if defined( _WIN32 ) && defined( DLL_IMPORT )
#define FT_EXPORT( x ) __declspec( dllimport ) x
#elif defined( __cplusplus )
#define FT_EXPORT( x ) extern "C" x
diff --git a/src/base/ftver.rc b/src/base/ftver.rc
index a2903d588..b0b6e0074 100644
--- a/src/base/ftver.rc
+++ b/src/base/ftver.rc
@@ -28,7 +28,7 @@ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#endif
-#ifdef _DLL
+#ifdef DLL_EXPORT
FILETYPE VFT_DLL
#define FT_FILENAME "freetype.dll"
#else