Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CXX11_ABI as default #4387

Merged
merged 2 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/Dockerfile.openblas
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/librealsense/librealsense.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ExternalProject_Add(
-DUSE_EXTERNAL_USB=ON
# Syncing GLIBCXX_USE_CXX11_ABI for MSVC causes problems, but directly
# checking CXX_COMPILER_ID is not supported.
$<IF:$<PLATFORM_ID:Windows>,"",-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=${GLIBCXX_USE_CXX11_ABI}>
$<IF:$<PLATFORM_ID:Windows>,"",-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=$<BOOL:${GLIBCXX_USE_CXX11_ABI}>>
$<$<PLATFORM_ID:Darwin>:-DBUILD_WITH_OPENMP=OFF>
$<$<PLATFORM_ID:Darwin>:-DHWM_OVER_XU=OFF>
$<$<PLATFORM_ID:Windows>:-DBUILD_WITH_STATIC_CRT=${STATIC_WINDOWS_RUNTIME}>
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/webrtc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 <cxxabi.h>
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})
Expand Down
9 changes: 5 additions & 4 deletions docs/compilation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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,
Expand Down
13 changes: 10 additions & 3 deletions util/ci_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down