Blender Hack Blog

オープンソースの総合3DCGソフトウェアのBlenderのコード解析や開発を記録していきます。

Blender: はじめてのビルドエラーの解決

はじめに

最新のコードをビルドしようとすると、エラーが発生してビルドできなくなりました。 今までmasterの最新のコードでうまくビルドできていました。 masterはunstableなので、これからも同様の問題が起きそうです。 解決までの記録を残します。

使用したコード

master (2.93.0)を使用しました。 https://developer.blender.org/rBbcd369c3c12e48dd2be544fbd3ebed2ce8b4c1fb

エラーの内容

ビルドすると、以下のエラーが発生します。 Clangは、ローカルで使用できているので、どうもClangの検出がうまくできていないようです。

% make debug

Configuring Blender in "/Users/yoshinori_sano/blender-git/build_darwin_debug" ...
-- Detected OS X 11.1 and Xcode 12.4 at /Applications/Xcode.app/Contents/Developer
-- SDKs Directory: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform//Developer/SDKs
-- Detected OSX_SYSROOT: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform//Developer/SDKs/MacOSX11.1.sdk
-- Could NOT find sse2neon (missing: SSE2NEON_INCLUDE_DIR) 
-- Could NOT find Clang (missing: _CLANG_LIBRARIES) 
CMake Error at build_files/cmake/platform/platform_apple.cmake:339 (message):
  Clang not found.
Call Stack (most recent call first):
  CMakeLists.txt:916 (include)


-- Configuring incomplete, errors occurred!
See also "/Users/yoshinori_sano/blender-git/build_darwin_debug/CMakeFiles/CMakeOutput.log".
See also "/Users/yoshinori_sano/blender-git/build_darwin_debug/CMakeFiles/CMakeError.log".
make: *** [all] Error 1

一時的な解決

このコミットでClangのチェックコードが追加されていました。 https://developer.blender.org/rB4fb0c83c1c8529b61d38d8a409caf58d05a53bd9

そこで、messageのFATAL_ERRORを踏まないようにコメントアウトすると、ビルドできるようになりました。

diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 31302bf1100..1e0b2db6d81 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -336,7 +336,7 @@ if(WITH_LLVM)
   if(WITH_CLANG)
     find_package(Clang)
     if(NOT CLANG_FOUND)
-       message(FATAL_ERROR "Clang not found.")
+       #message(FATAL_ERROR "Clang not found.")
     endif()
   endif()

問題の探求と解決

Blenderの開発者によって問題はすでに発見、解決されていました。

コミットログによると、外部ライブラリの更新作業が前後したことで、ビルドができなくなったようです。

こちらにも、Clang関係のファイルがSubversionに追加されているのが確認できました。 https://developer.blender.org/rBL62576

commit 9a1b29e16c216c2827f28214d4f7af4ee072beec
Author: Sebastián Barschkis <sebbas@sebbas.org>
Date:   Wed Feb 24 20:18:07 2021 +0100

    CMake: Removed temporarily disabled clang block
    
    Was disabled in rBc778fd981e63. Libraries have been updated in rBL62576.

diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index c2e46206046..31302bf1100 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -333,13 +333,12 @@ if(WITH_LLVM)
   if(NOT LLVM_FOUND)
     message(FATAL_ERROR "LLVM not found.")
   endif()
-# Temporarily removing clang - new libs still need to be committed
-#  if(WITH_CLANG)
-#    find_package(Clang)
-#    if(NOT CLANG_FOUND)
-#       message(FATAL_ERROR "Clang not found.")
-#    endif()
-#  endif()
+  if(WITH_CLANG)
+    find_package(Clang)
+    if(NOT CLANG_FOUND)
+       message(FATAL_ERROR "Clang not found.")
+    endif()
+  endif()
 
 endif()


commit c778fd981e636d99f819806471e2ee83a3cb76c0
Author: Sebastián Barschkis <sebbas@sebbas.org>
Date:   Wed Feb 24 16:12:50 2021 +0100

    CMake: Temporarily removing find clang block
    
    New libs have not landed in the SVN repository. Once they are up, this commit will be reverted.

diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index 31302bf1100..c2e46206046 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -333,12 +333,13 @@ if(WITH_LLVM)
   if(NOT LLVM_FOUND)
     message(FATAL_ERROR "LLVM not found.")
   endif()
-  if(WITH_CLANG)
-    find_package(Clang)
-    if(NOT CLANG_FOUND)
-       message(FATAL_ERROR "Clang not found.")
-    endif()
-  endif()
+# Temporarily removing clang - new libs still need to be committed
+#  if(WITH_CLANG)
+#    find_package(Clang)
+#    if(NOT CLANG_FOUND)
+#       message(FATAL_ERROR "Clang not found.")
+#    endif()
+#  endif()
 
 endif()

そこで、外部ライブラリの更新をローカルに取り込んでみます。 Clang関係のファイルが追加されました。 改めて、makeしてみると、無事ビルドエラーが解決しました。

% make update
python3 ./build_files/utils/make_update.py

Updating Precompiled Libraries and Tests

svn --non-interactive cleanup /Users/yoshinori_sano/blender-git/blender/../lib/darwin
svn --non-interactive switch https://svn.blender.org/svnroot/bf-blender/trunk/lib/darwin /Users/yoshinori_sano/blender-git/blender/../lib/darwin
[...]
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang/9.0.1
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang/9.0.1/include
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang/9.0.1/include/cuda_wrappers
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang/9.0.1/include/openmp_wrappers
A    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/clang/9.0.1/include/ppc_wrappers
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdShade/resources/generatedSchema.usda
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdSkel/resources/plugInfo.json
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdSkel/resources/generatedSchema.usda
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdShade/resources/usdShade/schema.usda
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdVol/resources/plugInfo.json
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdVol/resources/generatedSchema.usda
U    /Users/yoshinori_sano/blender-git/lib/darwin/usd/lib/usd/usdUI/resources/plugInfo.json
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/bin/llvm-config
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/bin/clang-format
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/include/llvm/Config/llvm-config.h
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMAsmPrinter.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMBitstreamReader.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMCoverage.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMDebugInfoMSF.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMExecutionEngine.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMAnalysis.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMBitReader.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMInstCombine.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMLTO.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMMC.a
U    /Users/yoshinori_sano/blender-git/lib/darwin/llvm/lib/libLLVMMCParser.a
[...]