I'm following these instructions to build Blender from source as a Python module. As I need to share my build with others in a different runtime environment, I need to build it with static linking.
cmake ../blender -DPYTHON_LIBRARY="/home/anaconda3/envs/project/lib/libpython3.6m.a" -DPYTHON_INCLUDE_DIR="/home/anaconda3/envs/project/include/python3.6m" -DOPENIMAGEIO_LIBRARY="$HOME/blender-deps/built/oiio/lib/libOpenImageIO.so" -DOPENIMAGEIO_INCLUDE_DIR="$HOME/blender-deps/built/oiio/include" -DWITH_PYTHON_MODULE=ON -DWITH_PYTHON_INSTALL=OFF -DWITH_STATIC_LIBS=ON make -j; make install
and failed at the very end
[100%] Building C object source/creator/CMakeFiles/blender.dir/creator_args.c.o [100%] Building C object source/creator/CMakeFiles/blender.dir/buildinfo.c.o [100%] Linking CXX shared module ../../bin/bpy.so lto1: internal compiler error: in lto_tag_to_tree_code, at lto-streamer.h:1005 Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions. lto-wrapper: fatal error: /usr/bin/c++ returned 1 exit status compilation terminated. /usr/bin/ld.gold: fatal error: lto-wrapper failed collect2: error: ld returned 1 exit status source/creator/CMakeFiles/blender.dir/build.make:319: recipe for target 'bin/bpy.so' failed make: *** [bin/bpy.so] Error 1 CMakeFiles/Makefile2:7690: recipe for target 'source/creator/CMakeFiles/blender.dir/all' failed make: *** [source/creator/CMakeFiles/blender.dir/all] Error 2 Makefile:162: recipe for target 'all' failed make: *** [all] Error 2
This error is too obscure for me to figure out what is wrong.