[Bf-blender-cvs] [a84bcea] master: OSX/scons: allow for compiling with clang-openmp-3.4 See: http://clang-omp.github.io + fix a longstanding bad include in darwin-config

Jens Verwiebe noreply at git.blender.org
Sun Feb 9 18:03:30 CET 2014


Commit: a84bcea070a81b9729ada289bd15e1d86881aa70
Author: Jens Verwiebe
Date:   Sun Feb 9 18:03:13 2014 +0100
https://developer.blender.org/rBa84bcea070a81b9729ada289bd15e1d86881aa70

OSX/scons: allow for compiling with clang-openmp-3.4
See: http://clang-omp.github.io
+ fix a longstanding bad include in darwin-config

===================================================================

M	SConstruct
M	build_files/scons/config/darwin-config.py
M	build_files/scons/tools/Blender.py
M	intern/itasc/SConscript
M	source/blender/blenlib/intern/threads.c
M	source/blender/ikplugin/SConscript

===================================================================

diff --git a/SConstruct b/SConstruct
index b0c7750..ac5ee06 100644
--- a/SConstruct
+++ b/SConstruct
@@ -410,7 +410,7 @@ if env['OURPLATFORM']=='darwin':
     #Defaults openMP to true if compiler handles it ( only gcc 4.6.1 and newer )
     # if your compiler does not have accurate suffix you may have to enable it by hand !
     if env['WITH_BF_OPENMP'] == 1:
-        if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6.1': # strip down to version string if any
+        if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.6.1' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
             env['WITH_BF_OPENMP'] = 1  # multithreading for fluids, cloth, sculpt and smoke
             print B.bc.OKGREEN + "Using OpenMP"
         else:
@@ -420,7 +420,7 @@ if env['OURPLATFORM']=='darwin':
     if env['WITH_BF_CYCLES_OSL'] == 1:
         OSX_OSL_LIBPATH = Dir(env.subst(env['BF_OSL_LIBPATH'])).abspath
         # we need 2 variants of passing the oslexec with the force_load option, string and list type atm
-        if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.8': # strip down to version string if any
+        if env['C_COMPILER_ID'] == 'gcc' and env['CCVERSION'] >= '4.8' or env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
             env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-loslexec','-loslquery'])
         else:
             env.Append(LINKFLAGS=['-L'+OSX_OSL_LIBPATH,'-loslcomp','-force_load '+ OSX_OSL_LIBPATH +'/liboslexec.a','-loslquery'])
diff --git a/build_files/scons/config/darwin-config.py b/build_files/scons/config/darwin-config.py
index 09dc32f..6a126d4 100644
--- a/build_files/scons/config/darwin-config.py
+++ b/build_files/scons/config/darwin-config.py
@@ -109,7 +109,7 @@ BF_TIFF_LIBPATH = '${BF_TIFF}/lib'
 
 WITH_BF_ZLIB = True
 BF_ZLIB = '/usr'
-BF_ZLIB_INC = '${BF_ZLIB}/include'
+#BF_ZLIB_INC = '${BF_ZLIB}/include' # don't use this, it breaks -isysroot ${MACOSX_SDK}
 BF_ZLIB_LIB = 'z'
 
 WITH_BF_INTERNATIONAL = True
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py
index ac001b5..94346b9 100644
--- a/build_files/scons/tools/Blender.py
+++ b/build_files/scons/tools/Blender.py
@@ -266,6 +266,8 @@ def setup_syslibs(lenv):
     if lenv['WITH_BF_OPENMP'] and lenv['CC'] != 'icc' and not lenv['WITH_BF_STATICOPENMP']:
         if lenv['CC'] == 'cl.exe':
             syslibs += ['vcomp']
+        elif lenv['OURPLATFORM']=='darwin' and lenv['C_COMPILER_ID'] == 'clang' and lenv['CCVERSION'] >= '3.4': # clang-omp-3.4 !
+            syslibs += ['iomp5']
         else:
             syslibs += ['gomp']
     if lenv['WITH_BF_ICONV']:
@@ -745,6 +747,15 @@ def AppIt(target=None, source=None, env=None):
         commands.getoutput(cmd)
         cmd = 'install_name_tool -change %s/lib/libgomp.1.dylib  @executable_path/lib/libgomp.1.dylib %s/%s.app/Contents/MacOS/%s'%(instname, installdir, binary, binary) # change ref to libgomp ( blender )
         commands.getoutput(cmd)
+    if env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4':
+        print "Bundling libiomp5"
+        instname = env['BF_CXX']
+        cmd = 'ditto --arch %s %s/lib/libiomp5.dylib %s/%s.app/Contents/MacOS/lib/'%(osxarch, instname, installdir, binary) # copy libiomp5
+        commands.getoutput(cmd)
+        cmd = 'install_name_tool -id @executable_path/lib/libiomp5.dylib %s/%s.app/Contents/MacOS/lib/libiomp5.dylib'%(installdir, binary) # change id of libiomp5
+        commands.getoutput(cmd)
+        cmd = 'install_name_tool -change %s/lib/libiomp5.dylib  @executable_path/lib/libiomp5.dylib %s/%s.app/Contents/MacOS/%s'%(instname, installdir, binary, binary) # change ref to libiomp5 ( blender )
+        commands.getoutput(cmd)
 
 # extract copy system python, be sure to update other build systems
 # when making changes to the files that are copied.
diff --git a/intern/itasc/SConscript b/intern/itasc/SConscript
index 208fee5..1b7709b 100644
--- a/intern/itasc/SConscript
+++ b/intern/itasc/SConscript
@@ -35,5 +35,7 @@ incs = '. ../../extern/Eigen3'
 
 defs = []
 
-env.BlenderLib ('bf_intern_itasc', sources, Split(incs), defs, libtype=['intern','player'], priority=[20,100] )
-
+if env['OURPLATFORM']=='darwin' and env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4': # workaround for friend declaration specifies a default argument expression, not allowed anymore
+    env.BlenderLib ('bf_intern_itasc', sources, Split(incs), defs, libtype=['intern','player'], priority=[20,100], cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++' )
+else:
+    env.BlenderLib ('bf_intern_itasc', sources, Split(incs), defs, libtype=['intern','player'], priority=[20,100])
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 5d8c1af..c9f4e9d 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -54,7 +54,7 @@
 #  include <sys/time.h>
 #endif
 
-#if defined(__APPLE__) && defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+#if defined(__APPLE__) && defined(_OPENMP) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2) && !defined(__clang__)
 #  define USE_APPLE_OMP_FIX
 #endif
 
diff --git a/source/blender/ikplugin/SConscript b/source/blender/ikplugin/SConscript
index 4a4cb4f..ec19b9a 100644
--- a/source/blender/ikplugin/SConscript
+++ b/source/blender/ikplugin/SConscript
@@ -46,4 +46,7 @@ defs = [
     'WITH_IK_SOLVER',
     ]
 
-env.BlenderLib('bf_ikplugin', sources, incs, defs, libtype=['core', 'player'], priority=[180, 190])
+if env['OURPLATFORM']=='darwin' and env['C_COMPILER_ID'] == 'clang' and env['CCVERSION'] >= '3.4': # workaround for friend declaration specifies a default argument expression, not allowed anymore
+    env.BlenderLib('bf_ikplugin', sources, incs, defs, libtype=['core', 'player'], priority=[180, 190], cc_compilerchange='/usr/bin/gcc', cxx_compilerchange='/usr/bin/g++')
+else:
+    env.BlenderLib('bf_ikplugin', sources, incs, defs, libtype=['core', 'player'], priority=[180, 190])




More information about the Bf-blender-cvs mailing list