[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15124] branches/apricot:
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Jun 4 23:29:48 CEST 2008
Revision: 15124
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15124
Author: blendix
Date: 2008-06-04 23:29:47 +0200 (Wed, 04 Jun 2008)
Log Message:
-----------
Apricot Branch: add -fvisibility=hidden if supported, to prevent conflicts
with bullet symbols used by b2cs. Note msvc does this already. Support was
added to Make/CMake/Scons, though it's pretty ugly code with shell commands,
couldn't figure out how to do it nicer.
Modified Paths:
--------------
branches/apricot/CMakeLists.txt
branches/apricot/SConstruct
branches/apricot/source/blender/blenpluginapi/externdef.h
branches/apricot/source/nan_compile.mk
Modified: branches/apricot/CMakeLists.txt
===================================================================
--- branches/apricot/CMakeLists.txt 2008-06-04 18:11:48 UTC (rev 15123)
+++ branches/apricot/CMakeLists.txt 2008-06-04 21:29:47 UTC (rev 15124)
@@ -188,12 +188,19 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
ENDIF(WITH_OPENMP)
-
SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
SET(PLATFORM_LINKFLAGS "-pthread")
INCLUDE_DIRECTORIES(/usr/include /usr/local/include)
+
+ # msvc already hides symbols, for others do it if the compiler supports it
+ EXECUTE_PROCESS(COMMAND echo "int main() { return 0; }" COMMAND ${CMAKE_C_COMPILER} -fvisibility=hidden -o /dev/null -xc - RESULT_VARIABLE VISIBILITY_RESULT OUTPUT_QUIET ERROR_QUIET)
+ IF(NOT VISIBILITY_RESULT)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
+ ENDIF(NOT VISIBILITY_RESULT)
+
ENDIF(UNIX)
IF(WIN32)
@@ -384,6 +391,14 @@
SET(TIFF_INC ${TIFF}/include)
SET(EXETYPE MACOSX_BUNDLE)
+
+ # msvc already hides symbols, for others do it if the compiler supports it
+ EXECUTE_PROCESS(COMMAND echo "int main() { return 0; }" COMMAND ${CMAKE_C_COMPILER} -fvisibility=hidden -o /dev/null -xc - RESULT_VARIABLE VISIBILITY_RESULT OUTPUT_QUIET ERROR_QUIET)
+ IF(NOT VISIBILITY_RESULT)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -DGCC_HASCLASSVISIBILITY")
+ ENDIF(NOT VISIBILITY_RESULT)
+
ENDIF(APPLE)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
Modified: branches/apricot/SConstruct
===================================================================
--- branches/apricot/SConstruct 2008-06-04 18:11:48 UTC (rev 15123)
+++ branches/apricot/SConstruct 2008-06-04 21:29:47 UTC (rev 15124)
@@ -36,6 +36,7 @@
import shutil
import glob
import re
+import commands
from tempfile import mkdtemp
import tools.Blender
@@ -235,6 +236,18 @@
os.rmdir(os.path.join(root, name))
if root: os.rmdir(root)
+# msvc already hides symbols, for others do it if the compiler supports it
+
+if env['OURPLATFORM'] != 'win32-vc':
+ def check_option(cc, option):
+ cmd = "echo \"int main() { return 0; }\" | " + cc + " " + option + " -o /dev/null -xc -"
+ return (commands.getstatusoutput(cmd)[0] == 0)
+
+ if check_option(env['CC'], '-fvisibility=hidden'):
+ env['CPPFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
+ env['CXXFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
+ env['CCFLAGS'].extend(['-fvisibility=hidden', '-DGCC_HASCLASSVISIBILITY'])
+
if len(B.quickdebug) > 0 and printdebug != 0:
print B.bc.OKGREEN + "Buildings these libs with debug symbols:" + B.bc.ENDC
for l in B.quickdebug:
Modified: branches/apricot/source/blender/blenpluginapi/externdef.h
===================================================================
--- branches/apricot/source/blender/blenpluginapi/externdef.h 2008-06-04 18:11:48 UTC (rev 15123)
+++ branches/apricot/source/blender/blenpluginapi/externdef.h 2008-06-04 21:29:47 UTC (rev 15124)
@@ -30,17 +30,24 @@
#ifndef _EXTERNDEF_H
#define _EXTERNDEF_H
-#ifdef WIN32
- #ifdef PLUGIN_INTERN
- #define LIBEXPORT __declspec(dllexport)
- #define LIBIMPORT __declspec(dllexport)
- #else
- #define LIBEXPORT __declspec(dllexport)
- #define LIBIMPORT extern __declspec(dllimport)
+#ifdef GCC_HASCLASSVISIBILITY
+ /* with gcc, we enable hiding of symbols if -fvisibility=hidden is
+ * supported, and define GCC_HASCLASSVISIBILITY to check it */
+ #define LIBEXPORT extern __attribute__ ((visibility("default")))
+ #define LIBIMPORT extern __attribute__ ((visibility("default")))
+#else
+ #ifdef WIN32
+ #ifdef PLUGIN_INTERN
+ #define LIBEXPORT __declspec(dllexport)
+ #define LIBIMPORT __declspec(dllexport)
+ #else
+ #define LIBEXPORT __declspec(dllexport)
+ #define LIBIMPORT extern __declspec(dllimport)
+ #endif
+ #elif !defined(WIN32)
+ #define LIBEXPORT extern
+ #define LIBIMPORT extern
#endif
-#elif !defined(WIN32)
- #define LIBEXPORT extern
- #define LIBIMPORT extern
#endif
#endif /* _EXTERNDEF_H */
Modified: branches/apricot/source/nan_compile.mk
===================================================================
--- branches/apricot/source/nan_compile.mk 2008-06-04 18:11:48 UTC (rev 15123)
+++ branches/apricot/source/nan_compile.mk 2008-06-04 21:29:47 UTC (rev 15124)
@@ -259,6 +259,23 @@
endif
endif
+# msvc already hides symbols, for others do it if the compiler supports it
+ifeq ($(OS),windows)
+ ifeq ($(FREE_WINDOWS),true)
+ CHECK_VISIBILITY_FLAG = 1
+ endif
+else
+ CHECK_VISIBILITY_FLAG = 1
+endif
+
+ifdef CHECK_VISIBILITY_FLAG
+ VISIBILITY_RESULT = $(shell echo "int main() { return 0; }" | $(CC) -fvisibility=hidden -o /dev/null -xc - 2> /dev/null; echo $$?)
+ ifeq ($(VISIBILITY_RESULT), 0)
+ CFLAGS += -fvisibility=hidden -DGCC_HASCLASSVISIBILITY
+ CCFLAGS += -fvisibility=hidden -DGCC_HASCLASSVISIBILITY
+ endif
+endif
+
ifeq (debug, $(findstring debug, $(MAKECMDGOALS)))
export DEBUG_DIR=debug/
endif
More information about the Bf-blender-cvs
mailing list