diff --git a/.github/workflows/Dockerfile.cuda b/.github/workflows/Dockerfile.cuda index 3631fb28cd1..19ff85fe145 100644 --- a/.github/workflows/Dockerfile.cuda +++ b/.github/workflows/Dockerfile.cuda @@ -134,6 +134,7 @@ RUN mkdir build \ -DBUILD_CUDA_MODULE=ON \ -DBUILD_COMMON_CUDA_ARCHS=ON \ -DBUILD_COMMON_ISPC_ISAS=ON \ + -DGLIBCXX_USE_CXX11_ABI=$( { [ "$BUILD_PYTORCH_OPS" == ON ] || [ "$BUILD_TENSORFLOW_OPS" == ON ]; } && echo OFF || echo ON) \ -DBUILD_TENSORFLOW_OPS="${BUILD_TENSORFLOW_OPS}" \ -DBUILD_PYTORCH_OPS="${BUILD_PYTORCH_OPS}" \ -DBUILD_UNIT_TESTS=ON \ diff --git a/.github/workflows/Dockerfile.openblas b/.github/workflows/Dockerfile.openblas index cfe00668801..f7449d62076 100644 --- a/.github/workflows/Dockerfile.openblas +++ b/.github/workflows/Dockerfile.openblas @@ -102,6 +102,7 @@ RUN mkdir build \ -DCMAKE_C_COMPILER=gcc \ -DCMAKE_CXX_COMPILER=g++ \ -DBUILD_FILAMENT_FROM_SOURCE=ON \ + -DGLIBCXX_USE_CXX11_ABI=ON \ -DBUILD_TENSORFLOW_OPS=OFF \ -DBUILD_PYTORCH_OPS=OFF \ -DBUILD_UNIT_TESTS=ON \ diff --git a/3rdparty/webrtc/CMakeLists.txt b/3rdparty/webrtc/CMakeLists.txt index 7a15558c64f..34d052ae4df 100644 --- a/3rdparty/webrtc/CMakeLists.txt +++ b/3rdparty/webrtc/CMakeLists.txt @@ -30,7 +30,7 @@ include(CMakeDependentOption) cmake_dependent_option(WEBRTC_IS_DEBUG "WebRTC Debug build. Use ON for Win32 Open3D Debug." OFF "NOT CMAKE_BUILD_TYPE STREQUAL Debug OR NOT WIN32" ON) -option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" OFF) +option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" ON) # Set paths set(WEBRTC_ROOT ${PROJECT_SOURCE_DIR}) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae4b1a9e7b6..87f0d828247 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ if(BUILD_SHARED_LIBS) else() option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" ON ) endif() -option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" OFF) +option(GLIBCXX_USE_CXX11_ABI "Set -D_GLIBCXX_USE_CXX11_ABI=1" ON) if(BUILD_GUI AND (WIN32 OR UNIX AND NOT LINUX_AARCH64)) option(BUILD_WEBRTC "Build WebRTC visualizer" ON ) else() @@ -408,11 +408,6 @@ add_custom_target(open3d_downloads # Folder view for project files set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# Check if the compiler defines the _GLIBCXX_USE_CXX11_ABI macro -include(CheckCXXSourceCompiles) -check_cxx_source_compiles("#include -int main() { return _GLIBCXX_USE_CXX11_ABI; }" HAS_GLIBCXX_USE_CXX11_ABI) - macro(add_source_group module_name) file(GLOB MODULE_HEADER_FILES "${module_name}/*.h") source_group("Header Files\\${module_name}" FILES ${MODULE_HEADER_FILES}) diff --git a/docs/compilation.rst b/docs/compilation.rst index d01a9cc24a5..a06a218d1ea 100644 --- a/docs/compilation.rst +++ b/docs/compilation.rst @@ -286,6 +286,7 @@ for all supported ML frameworks and bundling the high level Open3D-ML code. # In the build directory cmake -DBUILD_CUDA_MODULE=ON \ + -DGLIBCXX_USE_CXX11_ABI=OFF \ -DBUILD_PYTORCH_OPS=ON \ -DBUILD_TENSORFLOW_OPS=ON \ -DBUNDLE_OPEN3D_ML=ON \ @@ -295,10 +296,10 @@ for all supported ML frameworks and bundling the high level Open3D-ML code. make -j install-pip-package .. note:: - Importing Python libraries compiled with different CXX ABI may cause segfaults - in regex. https://stackoverflow.com/q/51382355/1255535. By default, PyTorch - and TensorFlow Python releases use the older CXX ABI; while when they are - compiled from source, newer ABI is enabled by default. + On Linux, importing Python libraries compiled with different CXX ABI may + cause segfaults in regex. https://stackoverflow.com/q/51382355/1255535. By + default, PyTorch and TensorFlow Python releases use the older CXX ABI; while + when compiled from source, the newer CXX11 ABI is enabled by default. When releasing Open3D as a Python package, we set ``-DGLIBCXX_USE_CXX11_ABI=OFF`` and compile all dependencies from source, diff --git a/util/ci_utils.sh b/util/ci_utils.sh index 9de23c0c8cf..800b6be1871 100644 --- a/util/ci_utils.sh +++ b/util/ci_utils.sh @@ -121,6 +121,10 @@ build_all() { mkdir -p build cd build + GLIBCXX_USE_CXX11_ABI=ON + if [ "$BUILD_PYTORCH_OPS" == ON ] || [ "$BUILD_TENSORFLOW_OPS" == ON ]; then + GLIBCXX_USE_CXX11_ABI=OFF + fi cmakeOptions=( -DBUILD_SHARED_LIBS="$SHARED" @@ -129,6 +133,7 @@ build_all() { -DBUILD_CUDA_MODULE="$BUILD_CUDA_MODULE" -DBUILD_COMMON_CUDA_ARCHS=ON -DBUILD_COMMON_ISPC_ISAS=ON + -DGLIBCXX_USE_CXX11_ABI="$GLIBCXX_USE_CXX11_ABI" -DBUILD_TENSORFLOW_OPS="$BUILD_TENSORFLOW_OPS" -DBUILD_PYTORCH_OPS="$BUILD_PYTORCH_OPS" -DCMAKE_INSTALL_PREFIX="$OPEN3D_INSTALL_DIR" @@ -198,6 +203,7 @@ build_pip_conda_package() { "-DBUILD_COMMON_ISPC_ISAS=ON" "-DBUILD_AZURE_KINECT=$BUILD_AZURE_KINECT" "-DBUILD_LIBREALSENSE=ON" + "-DGLIBCXX_USE_CXX11_ABI=OFF" "-DBUILD_TENSORFLOW_OPS=ON" "-DBUILD_PYTORCH_OPS=ON" "-DBUILD_FILAMENT_FROM_SOURCE=$BUILD_FILAMENT_FROM_SOURCE" @@ -226,8 +232,8 @@ build_pip_conda_package() { rm -r "${rebuild_list[@]}" || true set -x # Echo commands on cmake -DBUILD_CUDA_MODULE=ON \ - -DBUILD_COMMON_CUDA_ARCHS=ON \ - "${cmakeOptions[@]}" .. + -DBUILD_COMMON_CUDA_ARCHS=ON \ + "${cmakeOptions[@]}" .. set +x # Echo commands off fi echo @@ -364,7 +370,7 @@ install_docs_dependencies() { command -v python python -V python -m pip install -U -q "wheel==$WHEEL_VER" \ - "pip==$PIP_VER" + "pip==$PIP_VER" python -m pip install -U -q "yapf==$YAPF_VER" python -m pip install -r "${OPEN3D_SOURCE_ROOT}/docs/requirements.txt" python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements.txt" @@ -407,6 +413,7 @@ build_docs() { "-DWITH_OPENMP=ON" "-DBUILD_AZURE_KINECT=ON" "-DBUILD_LIBREALSENSE=ON" + "-DGLIBCXX_USE_CXX11_ABI=OFF" "-DBUILD_TENSORFLOW_OPS=ON" "-DBUILD_PYTORCH_OPS=ON" "-DBUNDLE_OPEN3D_ML=ON"