[Bf-blender-cvs] [78d48343ae0] master: Make deps: Fix compilation error on CentOS

Sergey Sharybin noreply at git.blender.org
Thu Jul 9 17:24:58 CEST 2020


Commit: 78d48343ae0ece8723d2404d6f07354a7ce9512b
Author: Sergey Sharybin
Date:   Thu Jul 9 15:59:57 2020 +0200
Branches: master
https://developer.blender.org/rB78d48343ae0ece8723d2404d6f07354a7ce9512b

Make deps: Fix compilation error on CentOS

There were two issues.

First is related on ISPC's CMake configuration forcing C and C++
compilers to be clang and clang++. This goes against of desired
behavior when we use our own compiled clang compilers.

The second issue was related on linker failure: CLang libraries
are linked statically, and they need some of C++ 11 STL symbols
which are coming from libstdc++.

Differential Revision: https://developer.blender.org/D8258

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

M	build_files/build_environment/cmake/ispc.cmake
M	build_files/build_environment/patches/ispc.diff

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

diff --git a/build_files/build_environment/cmake/ispc.cmake b/build_files/build_environment/cmake/ispc.cmake
index 9143a7ec984..b67351dcf9f 100644
--- a/build_files/build_environment/cmake/ispc.cmake
+++ b/build_files/build_environment/cmake/ispc.cmake
@@ -28,6 +28,11 @@ elseif(APPLE)
   set(ISPC_EXTRA_ARGS_APPLE
     -DBISON_EXECUTABLE=/usr/local/opt/bison/bin/bison
   )
+elseif(UNIX)
+  set(ISPC_EXTRA_ARGS_UNIX
+    -DCMAKE_C_COMPILER=${LIBDIR}/clang/bin/clang
+    -DCMAKE_CXX_COMPILER=${LIBDIR}/clang/bin/clang++
+  )
 endif()
 
 set(ISPC_EXTRA_ARGS
@@ -43,6 +48,7 @@ set(ISPC_EXTRA_ARGS
     -DCLANG_INCLUDE_DIRS=${LIBDIR}/clang/include
     ${ISPC_EXTRA_ARGS_WIN}
     ${ISPC_EXTRA_ARGS_APPLE}
+    ${ISPC_EXTRA_ARGS_UNIX}
 )
 
 ExternalProject_Add(external_ispc
diff --git a/build_files/build_environment/patches/ispc.diff b/build_files/build_environment/patches/ispc.diff
index 710bfc7a448..689dd0abdc5 100644
--- a/build_files/build_environment/patches/ispc.diff
+++ b/build_files/build_environment/patches/ispc.diff
@@ -34,3 +34,52 @@ diff -Naur orig/cmake/GenerateBuiltins.cmake.txt external_ispc/cmake/GenerateBui
      elseif ("${bit}" STREQUAL "64" AND ${arch} STREQUAL "x86")
          set(target_arch "x86_64")
      elseif ("${bit}" STREQUAL "32" AND ${arch} STREQUAL "arm")
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 46a8db8..f53beef 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -36,8 +36,12 @@
+ cmake_minimum_required(VERSION 3.13)
+ 
+ if (UNIX)
+-    set(CMAKE_C_COMPILER "clang")
+-    set(CMAKE_CXX_COMPILER "clang++")
++    if (NOT CMAKE_C_COMPILER)
++        set(CMAKE_C_COMPILER "clang")
++    endif()
++    if (NOT CMAKE_CXX_COMPILER)
++        set(CMAKE_CXX_COMPILER "clang++")
++    endif()
+ endif()
+ 
+ set(PROJECT_NAME ispc)
+@@ -412,6 +416,29 @@ else()
+     endif()
+ endif()
+ 
++# Link against libstdc++.a which must be provided to the linker after
++# LLVM and CLang libraries.
++# This is needed because some of LLVM/CLang dependencies are using
++# std::make_shared, which is defined in one of those:
++#  - libclang-cpp.so
++#  - libstdc++.a
++# Using the former one is tricky because then generated binary depends
++# on a library which is outside of the LD_LIBRARY_PATH.
++#
++# Hence, using C++ implementation from G++ which seems to work just fine.
++# In fact, from investigation seems that libclang-cpp.so itself is pulling
++# std::_Sp_make_shared_tag from G++'s libstdc++.a.
++if(UNIX AND NOT APPLE)
++    execute_process(
++        COMMAND g++ --print-file-name libstdc++.a
++        OUTPUT_VARIABLE GCC_LIBSTDCXX_A
++        OUTPUT_STRIP_TRAILING_WHITESPACE
++    )
++    if(GCC_LIBSTDCXX_A AND EXISTS ${GCC_LIBSTDCXX_A})
++        target_link_libraries(${PROJECT_NAME} ${GCC_LIBSTDCXX_A})
++    endif()
++endif()
++
+ # Build target for utility checking host ISA
+ if (ISPC_INCLUDE_UTILS)
+     add_executable(check_isa "")



More information about the Bf-blender-cvs mailing list