Skip to content

Commit

Permalink
Filament also needs libunwind with newer llvm / libc++ / libc++abi. A…
Browse files Browse the repository at this point in the history
…dd to build and python wheel.
  • Loading branch information
ssheorey committed Aug 18, 2024
1 parent 26d3de3 commit 73b6b18
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
47 changes: 23 additions & 24 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,10 @@ if(BUILD_GUI)
# If the default version is not sufficient, look for some specific versions
if(NOT FILAMENT_C_COMPILER OR NOT FILAMENT_CXX_COMPILER)
find_program(CLANG_VERSIONED_CC NAMES
clang-19
clang-18
clang-17
clang-16
clang-15
clang-14
clang-13
Expand All @@ -1251,6 +1255,10 @@ if(BUILD_GUI)
clang-7
)
find_program(CLANG_VERSIONED_CXX NAMES
clang++-19
clang++-18
clang++-17
clang++-16
clang++-15
clang++-14
clang++-13
Expand Down Expand Up @@ -1278,7 +1286,7 @@ if(BUILD_GUI)
#
# On aarch64, the symbolic link path may not work for CMake's
# find_library. Therefore, when compiling Filament from source,
# we explicitly find the corresponidng path based on the clang
# we explicitly find the corresponding path based on the clang
# version.
execute_process(COMMAND ${FILAMENT_CXX_COMPILER} --version OUTPUT_VARIABLE clang_version)
if(clang_version MATCHES "clang version ([0-9]+)")
Expand Down Expand Up @@ -1320,26 +1328,14 @@ if(BUILD_GUI)
# We first search for these paths, and then search CMake's default
# search path. LLVM version must be >= 7 to compile Filament.
if (NOT CLANG_LIBDIR)
set(ubuntu_default_llvm_lib_dirs
/usr/lib/llvm-19/lib
/usr/lib/llvm-18/lib
/usr/lib/llvm-17/lib
/usr/lib/llvm-16/lib
/usr/lib/llvm-15/lib
/usr/lib/llvm-14/lib
/usr/lib/llvm-13/lib
/usr/lib/llvm-12/lib
/usr/lib/llvm-11/lib
/usr/lib/llvm-10/lib
/usr/lib/llvm-9/lib
/usr/lib/llvm-8/lib
/usr/lib/llvm-7/lib
)
foreach(llvm_lib_dir in ${ubuntu_default_llvm_lib_dirs})
message(STATUS "Searching ${llvm_lib_dir} for libc++ and libc++abi")
find_library(CPP_LIBRARY c++ PATHS ${llvm_lib_dir} NO_DEFAULT_PATH)
message(STATUS "Searching /usr/lib/llvm-[7..19]/lib/ for libc++, libc++abi and libunwind")
foreach(llvm_ver RANGE 7 19)
set(llvm_lib_dir "/usr/lib/llvm-${llvm_ver}/lib")
message(STATUS "Searching ${llvm_lib_dir} for libc++, libc++abi and libunwind")
find_library(CPP_LIBRARY libc++ PATHS ${llvm_lib_dir} NO_DEFAULT_PATH)
find_library(CPPABI_LIBRARY c++abi PATHS ${llvm_lib_dir} NO_DEFAULT_PATH)
if (CPP_LIBRARY AND CPPABI_LIBRARY)
find_library(UNWIND_LIBRARY unwind PATHS ${llvm_lib_dir} NO_DEFAULT_PATH)
if (CPP_LIBRARY AND CPPABI_LIBRARY AND UNWIND_LIBRARY)
set(CLANG_LIBDIR ${llvm_lib_dir})
message(STATUS "CLANG_LIBDIR found in ubuntu-default: ${CLANG_LIBDIR}")
break()
Expand All @@ -1350,6 +1346,9 @@ if(BUILD_GUI)
# Fallback to non-ubuntu-default paths. Note that the PATH_SUFFIXES
# is not enforced by CMake.
if (NOT CLANG_LIBDIR)
message(WARNING "libc++, libc++abi and libunwind not found in Ubuntu default paths."
"Have you installed libc++-dev libc++abi-dev and libunwind-dev packages?"
"Searching in other paths.")
find_library(CPPABI_LIBRARY c++abi PATH_SUFFIXES
llvm-19/lib
llvm-18/lib
Expand All @@ -1372,16 +1371,16 @@ if(BUILD_GUI)
if (CLANG_LIBDIR)
message(STATUS "Using CLANG_LIBDIR: ${CLANG_LIBDIR}")
else()
message(FATAL_ERROR "Cannot find matching libc++ and libc++abi libraries with version >=7.")
message(FATAL_ERROR "Cannot find matching libc++, libc++abi and libunwind libraries with version >=7.")
endif()
find_library(CPP_LIBRARY c++ PATHS ${CLANG_LIBDIR} REQUIRED NO_DEFAULT_PATH)
find_library(CPPABI_LIBRARY c++abi PATHS ${CLANG_LIBDIR} REQUIRED NO_DEFAULT_PATH)
find_library(UNWIND_LIBRARY unwind PATHS ${CLANG_LIBDIR} REQUIRED NO_DEFAULT_PATH)

# Ensure that libstdc++ gets linked first.
target_link_libraries(3rdparty_filament INTERFACE -lstdc++
${CPP_LIBRARY} ${CPPABI_LIBRARY})
message(STATUS "CPP_LIBRARY: ${CPP_LIBRARY}")
message(STATUS "CPPABI_LIBRARY: ${CPPABI_LIBRARY}")
${CPP_LIBRARY} ${CPPABI_LIBRARY} ${UNIWIND_LIBRARY})
message(STATUS "Filament C++ libraries: ${CPP_LIBRARY} ${CPPABI_LIBRARY} ${UNWIND_LIBRARY}")
endif()
if (APPLE)
find_library(CORE_VIDEO CoreVideo)
Expand Down
4 changes: 2 additions & 2 deletions cpp/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ if (BUILD_SHARED_LIBS)
)
endif()
# Include additional libraries that may be absent from the user system
# eg: libc++.so and libc++abi.so (needed by filament) for Linux.
# eg: libc++.so, libc++abi.so, libunwind.so (needed by filament) for Linux.
# libc++.so is a linker script including libc++.so.1 and libc++abi.so, so append 1 to libc++.so
set(PYTHON_EXTRA_LIBRARIES $<TARGET_FILE:tbb>)
if (BUILD_GUI AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND PYTHON_EXTRA_LIBRARIES ${CPP_LIBRARY}.1 ${CPPABI_LIBRARY})
list(APPEND PYTHON_EXTRA_LIBRARIES ${CPP_LIBRARY}.1 ${CPPABI_LIBRARY} ${UNWIND_LIBRARY})
endif()
if (WITH_OPENMP AND APPLE AND NOT BUILD_SHARED_LIBS)
# Package libomp v11.1.0, if it is not installed. Later version cause crash on
Expand Down
1 change: 1 addition & 0 deletions util/install_deps_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ deps=(
clang
libc++-dev
libc++abi-dev
libunwind-dev
libsdl2-dev
ninja-build
libxi-dev
Expand Down

0 comments on commit 73b6b18

Please sign in to comment.