Skip to content

Commit

Permalink
Revert libc++ and libc++abi to version 10 to avoid libunwind dependence
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Aug 19, 2024
1 parent 937a625 commit 5553cb7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 31 deletions.
20 changes: 7 additions & 13 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1328,20 +1328,15 @@ 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)
message(STATUS "Searching /usr/lib/llvm-[7..19]/lib/ for libc++, libc++abi and libunwind")
message(STATUS "Searching /usr/lib/llvm-[7..19]/lib/ for libc++ and libc++abi")
foreach(llvm_ver RANGE 7 19)
set(llvm_lib_dir "/usr/lib/llvm-${llvm_ver}/lib")
find_library(CPP_LIBRARY c++ 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)
# libunwind.so is in /usr/lib/<ARCH> in Ubuntu 20.04, but libunwind.so is in /usr/lib/llvm-<VERSION>/lib in Ubuntu 22.04+
# The LLVM folder libunwind is needed in Ubuntu 22.04+
find_library(UNWIND_LIBRARY unwind HINTS ${llvm_lib_dir})
if (UNWIND_LIBRARY)
set(CLANG_LIBDIR ${llvm_lib_dir})
message(STATUS "CLANG_LIBDIR found in ubuntu-default: ${CLANG_LIBDIR}")
break()
endif()
set(CLANG_LIBDIR ${llvm_lib_dir})
message(STATUS "CLANG_LIBDIR found in ubuntu-default: ${CLANG_LIBDIR}")
break()
endif()
endforeach()
endif()
Expand Down Expand Up @@ -1372,16 +1367,15 @@ if(BUILD_GUI)
if (CLANG_LIBDIR)
message(STATUS "Using CLANG_LIBDIR: ${CLANG_LIBDIR}")
else()
message(FATAL_ERROR "Cannot find matching libc++, libc++abi and libunwind libraries with version >=7.")
message(FATAL_ERROR "Cannot find matching libc++ and libc++abi 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 HINTS ${CLANG_LIBDIR} REQUIRED)

# Ensure that libstdc++ gets linked first.
target_link_libraries(3rdparty_filament INTERFACE -lstdc++
${CPP_LIBRARY} ${CPPABI_LIBRARY} ${UNIWIND_LIBRARY})
message(STATUS "Filament C++ libraries: ${CPP_LIBRARY} ${CPPABI_LIBRARY} ${UNWIND_LIBRARY}")
${CPP_LIBRARY} ${CPPABI_LIBRARY})
message(STATUS "Filament C++ libraries: ${CPP_LIBRARY} ${CPPABI_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, libc++abi.so, libunwind.so (needed by filament) for Linux.
# eg: libc++.so, libc++abi.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} ${UNWIND_LIBRARY})
list(APPEND PYTHON_EXTRA_LIBRARIES ${CPP_LIBRARY}.1 ${CPPABI_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
6 changes: 2 additions & 4 deletions python/open3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,10 @@ def load_cdll(path):
_win32_dll_dir = os.add_dll_directory(str(Path(__file__).parent))

if _build_config["BUILD_GUI"] and not (find_library("c++abi") or
find_library("c++") or
find_library("unwind")):
try: # Preload libc++.so, libc++abi.so and libunwind.so (required by filament)
find_library("c++")):
try: # Preload libc++.so and libc++abi.so (required by filament)
load_cdll(str(next((Path(__file__).parent).glob("*c++abi.*"))))
load_cdll(str(next((Path(__file__).parent).glob("*c++.*"))))
load_cdll(str(next((Path(__file__).parent).glob("*unwind.*"))))
except StopIteration: # Not found: check system paths while loading
pass

Expand Down
17 changes: 5 additions & 12 deletions util/install_deps_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ deps=(
clang
libc++-dev
libc++abi-dev
libunwind-dev
libsdl2-dev
ninja-build
libxi-dev
Expand All @@ -41,17 +40,11 @@ eval $(
echo DISTRIB_RELEASE="$DISTRIB_RELEASE"
)
if [ "$DISTRIB_ID" == "Ubuntu" -a "$DISTRIB_RELEASE" == "20.04" ]; then
# Ubuntu 20.04's clang/libc++-dev/libc++abi-dev are version 10.
# To build Filament from source, we need version 12+.
deps=("${deps[@]/clang/clang-12}")
deps=("${deps[@]/libc++-dev/libc++-12-dev}")
deps=("${deps[@]/libc++abi-dev/libc++abi-12-dev}")
elif [ "$DISTRIB_ID" == "Ubuntu" ] && dpkg --compare-versions "$DISTRIB_RELEASE" gt "20.04" ; then
# Ubuntu > 20.04 have libunwind-dev breaks libunwind-14-dev !!
deps=("${deps[@]/clang/clang-14}")
deps=("${deps[@]/libc++-dev/libc++-14-dev}")
deps=("${deps[@]/libc++abi-dev/libc++abi-14-dev}")
deps=("${deps[@]/libunwind-dev/libunwind-14-dev}")
# Ubuntu 20.04's clang/libc++-dev/libc++abi-dev are version 8, 10 or 12.
# To avoid dependence on libunwind, we don't want to use versions later than 10.
deps=("${deps[@]/clang/clang-10}")
deps=("${deps[@]/libc++-dev/libc++-10-dev}")
deps=("${deps[@]/libc++abi-dev/libc++abi-10-dev}")
fi

# Special case for ARM64
Expand Down

0 comments on commit 5553cb7

Please sign in to comment.