Some tweaks to support upcoming OSL-1.6
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 6 Feb 2015 09:51:14 +0000 (14:51 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 6 Feb 2015 09:57:32 +0000 (14:57 +0500)
Doesn't mean we're 100% ready for the transition, but need to start somewhere
anyway. Changes:

- OSL is no longer supporting cpp and requires usage of Boost Wave.
  So now Wave component of Boost is optionally demanded when looking for the
  Boost libraries if OSL is enabled.

  Only did this for Linux, MSVC seems already using Wave. Not sure about OSX.

- Because of the same reason OSL should be moved prior Boost for linker.

- Whole archive trick makes it so linking fails with duplicated symbols, so
  removed it for the new OSL. Didn't see issues with this so far.

- Added some code to check OSL version on Linux. Would need to move all that
  to FindOpenShadingLanguage.cmake which we can get from Cycles standalone
  repository.

  So in theory no affect on current stup would be made at all.

- Added some tweaks to buildbot files. It now seems to be happy with the new
  OSL libraries, but again, those tweaks are not in action yet.

All this was tested on Linux only. Win/OSX might still need some tweaks to
support new OSL.

P.S. This doesn't mean we're pushing OSL update yet, just making some
preliminary tweaks to avoid entropy of PITA when we'll actually want to
switch.

CMakeLists.txt
build_files/buildbot/config/user-config-glibc211-i686.py
build_files/buildbot/config/user-config-glibc211-x86_64.py
build_files/cmake/macros.cmake
build_files/scons/tools/Blender.py

index 99357507cbb1b23b2fde1cf2bd64075fc4caf3fb..15356e3445c038347cc5fa433b3dca6c54422dde 100644 (file)
@@ -926,6 +926,44 @@ if(UNIX AND NOT APPLE)
                endif()
        endif()
 
+       if(WITH_CYCLES_OSL)
+               set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
+
+               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
+
+               # TODO(sergey): Move to dedicated FindOpenShadingLanguage.cmake
+               find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
+               find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
+               find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
+               find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
+               find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
+               if(EXISTS ${OSL_INCLUDE_DIR})
+                       file(STRINGS "${OSL_INCLUDE_DIR}/OSL/oslversion.h" OSL_LIBRARY_VERSION_MAJOR
+                            REGEX "^[ \t]*#define[ \t]+OSL_LIBRARY_VERSION_MAJOR[ \t]+[0-9]+.*$")
+                       file(STRINGS "${OSL_INCLUDE_DIR}/OSL/oslversion.h" OSL_LIBRARY_VERSION_MINOR
+                            REGEX "^[ \t]*#define[ \t]+OSL_LIBRARY_VERSION_MINOR[ \t]+[0-9]+.*$")
+                       string(REGEX REPLACE ".*#define[ \t]+OSL_LIBRARY_VERSION_MAJOR[ \t]+([.0-9]+).*"
+                              "\\1" OSL_LIBRARY_VERSION_MAJOR ${OSL_LIBRARY_VERSION_MAJOR})
+                       string(REGEX REPLACE ".*#define[ \t]+OSL_LIBRARY_VERSION_MINOR[ \t]+([.0-9]+).*"
+                              "\\1" OSL_LIBRARY_VERSION_MINOR ${OSL_LIBRARY_VERSION_MINOR})
+               endif()
+
+               if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")
+                       # Note: --whole-archive is needed to force loading of all symbols in liboslexec,
+                       # otherwise LLVM is missing the osl_allocate_closure_component function
+                       list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY})
+               else()
+                       list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
+               endif()
+
+               if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
+                       set(OSL_FOUND TRUE)
+               else()
+                       message(STATUS "OSL not found")
+                       set(WITH_CYCLES_OSL OFF)
+               endif()
+       endif()
+
        if(WITH_BOOST)
                # uses in build instructions to override include and library variables
                if(NOT BOOST_CUSTOM)
@@ -934,6 +972,12 @@ if(UNIX AND NOT APPLE)
                        endif()
                        set(Boost_USE_MULTITHREADED ON)
                        set(__boost_packages filesystem regex system thread date_time)
+                       if(WITH_CYCLES_OSL)
+                               if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6"))
+                                       list(APPEND __boost_packages wave)
+                               else()
+                               endif()
+                       endif()
                        if(WITH_INTERNATIONAL)
                                list(APPEND __boost_packages locale)
                        endif()
@@ -1071,28 +1115,6 @@ if(UNIX AND NOT APPLE)
                set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map")
        endif()
 
-       if(WITH_CYCLES_OSL)
-               set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
-       
-               message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
-       
-               find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
-               find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
-               find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
-               # Note: --whole-archive is needed to force loading of all symbols in liboslexec,
-               # otherwise LLVM is missing the osl_allocate_closure_component function
-               list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY})
-               find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
-               find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
-       
-               if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
-                       set(OSL_FOUND TRUE)
-               else()
-                       message(STATUS "OSL not found")
-                       set(WITH_CYCLES_OSL OFF)
-               endif()
-       endif()
-
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
        list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
 
index 59a11072f2bde73eeb2b08a347b154c023600aed..06c43be32f212aabca909360fab2bba4e547598c 100644 (file)
@@ -124,13 +124,15 @@ BF_OIIO_INC = '${BF_OIIO}/include'
 BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_JPEG}/lib/libjpeg.a'
 BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
 
+BF_IS_NEW_OSL = False
 WITH_BF_CYCLES_OSL = True
-WITH_BF_STATICOSL = False
+WITH_BF_STATICOSL = BF_IS_NEW_OSL
 BF_OSL = '/opt/lib/osl'
 BF_OSL_INC = '${BF_OSL}/include'
 # note oslexec would passed via program linkflags, which is needed to
 # make llvm happy with osl_allocate_closure_component
 BF_OSL_LIB = 'oslcomp oslexec oslquery'
+BF_OSL_LIB_STATIC = '${BF_OSL}/lib/liboslcomp.a ${BF_OSL}/lib/liboslexec.a ${BF_OSL}/lib/liboslquery.a'
 BF_OSL_LIBPATH = '${BF_OSL}/lib'
 BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
 
@@ -157,6 +159,8 @@ BF_BOOST_INC = '${BF_BOOST}/include'
 BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ' + \
     '${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a \
     ${BF_BOOST_LIBPATH}/libboost_thread.a'
+if BF_IS_NEW_OSL:
+    BF_BOOST_LIB_STATIC += ' ${BF_BOOST_LIBPATH}/libboost_wave.a'
 BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
 
 # Ocean Simulation
@@ -166,4 +170,7 @@ WITH_BF_OCEANSIM = True
 BF_DEBUG = False
 REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2']  # C & C++
 PLATFORM_LINKFLAGS = ['-lrt']
-BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
+if BF_IS_NEW_OSL:
+    BF_PROGRAM_LINKFLAGS = ['-Wl,--version-script=source/creator/blender.map']
+else:
+  BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
index a0ae6122944ac174f959372a24308f86f479188c..29f6143f50eb6f2f9cab635489dcdc43c20ab0a0 100644 (file)
@@ -124,13 +124,15 @@ BF_OIIO_INC = '${BF_OIIO}/include'
 BF_OIIO_LIB_STATIC = '${BF_OIIO_LIBPATH}/libOpenImageIO.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_JPEG}/lib/libjpeg.a'
 BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
 
+BF_IS_NEW_OSL = False
 WITH_BF_CYCLES_OSL = True
-WITH_BF_STATICOSL = False
+WITH_BF_STATICOSL = BF_IS_NEW_OSL
 BF_OSL = '/opt/lib/osl'
 BF_OSL_INC = '${BF_OSL}/include'
 # note oslexec would passed via program linkflags, which is needed to
 # make llvm happy with osl_allocate_closure_component
 BF_OSL_LIB = 'oslcomp oslexec oslquery'
+BF_OSL_LIB_STATIC = '${BF_OSL}/lib/liboslcomp.a ${BF_OSL}/lib/liboslexec.a ${BF_OSL}/lib/liboslquery.a'
 BF_OSL_LIBPATH = '${BF_OSL}/lib'
 BF_OSL_COMPILER = '${BF_OSL}/bin/oslc'
 
@@ -157,6 +159,8 @@ BF_BOOST_INC = '${BF_BOOST}/include'
 BF_BOOST_LIB_STATIC = '${BF_BOOST_LIBPATH}/libboost_filesystem.a ${BF_BOOST_LIBPATH}/libboost_date_time.a ' + \
     '${BF_BOOST_LIBPATH}/libboost_regex.a ${BF_BOOST_LIBPATH}/libboost_locale.a ${BF_BOOST_LIBPATH}/libboost_system.a \
     ${BF_BOOST_LIBPATH}/libboost_thread.a'
+if BF_IS_NEW_OSL:
+    BF_BOOST_LIB_STATIC += ' ${BF_BOOST_LIBPATH}/libboost_wave.a'
 BF_BOOST_LIBPATH = '${BF_BOOST}/lib'
 
 # Ocean Simulation
@@ -166,4 +170,7 @@ WITH_BF_OCEANSIM = True
 BF_DEBUG = False
 REL_CCFLAGS = ['-DNDEBUG', '-O2', '-msse', '-msse2']  # C & C++
 PLATFORM_LINKFLAGS = ['-lrt']
-BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
+if BF_IS_NEW_OSL:
+    BF_PROGRAM_LINKFLAGS = ['-Wl,--version-script=source/creator/blender.map']
+else:
+    BF_PROGRAM_LINKFLAGS = ['-Wl,--whole-archive', '-loslexec', '-Wl,--no-whole-archive', '-Wl,--version-script=source/creator/blender.map']
index f4b241bd2e042a6d9026affbfd1627d8ec2c41b1..056241b376746988e9570ea06871945d3dd58f3a 100644 (file)
@@ -354,6 +354,9 @@ macro(setup_liblinks
        if(WITH_OPENCOLORIO)
                target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
        endif()
+       if(WITH_CYCLES_OSL)
+               target_link_libraries(${target} ${OSL_LIBRARIES})
+       endif()
        if(WITH_BOOST)
                target_link_libraries(${target} ${BOOST_LIBRARIES})
                if(Boost_USE_STATIC_LIBS AND Boost_USE_ICU)
@@ -412,9 +415,6 @@ macro(setup_liblinks
        if(WITH_MOD_CLOTH_ELTOPO)
                target_link_libraries(${target} ${LAPACK_LIBRARIES})
        endif()
-       if(WITH_CYCLES_OSL)
-               target_link_libraries(${target} ${OSL_LIBRARIES})
-       endif()
        if(WITH_LLVM)
                target_link_libraries(${target} ${LLVM_LIBRARY})
        endif()
index eb2e57ad7931411f794e15ba828603b7c0f58b06..f903668ba10063bf337fd67a18f2bd7b2b50e1b9 100644 (file)
@@ -216,16 +216,16 @@ def setup_staticlibs(lenv):
         if lenv['WITH_BF_STATICOCIO']:
             statlibs += Split(lenv['BF_OCIO_LIB_STATIC'])
 
-    if lenv['WITH_BF_BOOST']:
-        libincs += Split(lenv['BF_BOOST_LIBPATH'])
-        if lenv['WITH_BF_STATICBOOST']:
-            statlibs += Split(lenv['BF_BOOST_LIB_STATIC'])
-
     if lenv['WITH_BF_CYCLES_OSL']:
         libincs += Split(lenv['BF_OSL_LIBPATH'])
         if lenv['WITH_BF_STATICOSL']:
             statlibs += Split(lenv['BF_OSL_LIB_STATIC'])
 
+    if lenv['WITH_BF_BOOST']:
+        libincs += Split(lenv['BF_BOOST_LIBPATH'])
+        if lenv['WITH_BF_STATICBOOST']:
+            statlibs += Split(lenv['BF_BOOST_LIB_STATIC'])
+
     if lenv['WITH_BF_LLVM']:
         libincs += Split(lenv['BF_LLVM_LIBPATH'])
         if lenv['WITH_BF_STATICLLVM']:
@@ -325,16 +325,16 @@ def setup_syslibs(lenv):
         if lenv['WITH_BF_3DMOUSE']:
             if not lenv['WITH_BF_STATIC3DMOUSE']:
                 syslibs += Split(lenv['BF_3DMOUSE_LIB'])
-                
+
+    if lenv['WITH_BF_CYCLES_OSL'] and not lenv['WITH_BF_STATICOSL']:
+        syslibs += Split(lenv['BF_OSL_LIB'])
+
     if lenv['WITH_BF_BOOST'] and not lenv['WITH_BF_STATICBOOST']:
         syslibs += Split(lenv['BF_BOOST_LIB'])
-        
+
         if lenv['WITH_BF_INTERNATIONAL']:
             syslibs += Split(lenv['BF_BOOST_LIB_INTERNATIONAL'])
 
-    if lenv['WITH_BF_CYCLES_OSL'] and not lenv['WITH_BF_STATICOSL']:
-        syslibs += Split(lenv['BF_OSL_LIB'])
-
     if lenv['WITH_BF_LLVM'] and not lenv['WITH_BF_STATICLLVM']:
         syslibs += Split(lenv['BF_LLVM_LIB'])