Skip to content

[Core] In C++, there are D_GLIBCXX_USE_CXX11_ABI settings conflicts when both Ray and Arrow are used. #24566

@infzo

Description

@infzo

What happened + What you expected to happen

I expected to use both Ray and Arrow in a c++ project, but a build conflict caused it to fail.

Problem Scene

In a C++ project, both Ray and Arrow are used to develop functions and features. Build code with CMake and link Ray's libray_api.so, Arrow's libarrow.so, and so on.

Problem Description

Cannot set D_GLIBCXX_USE_CXX11_ABI to both 0 and 1 in CMakeLists.txt.

The problem is caused by the C++ standard conflict. The field parameter in CMakeLists.txt is D_GLIBCXX_USE_CXX11_ABI.

Ray

When libray_api.so is used, D_GLIBCXX_USE_CXX11_ABI must be set to 0.

# CMakeList.txt
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

If the D_GLIBCXX_USE_CXX11_ABI set to 1, the error information is as follows:

free(): invalid pointer
*** SIGABRT received at time=1651890091 on cpu 3 ***
PC: @     0x7fc3d04ea03b  (unknown)  raise
    @     0x7fc3d04ea0c0  1379971456  (unknown)
    @     0x7fc3d053c32c        320  (unknown)
    @           0x40597c       1952  main
    @     0x7fc3d04cb0b3  (unknown)  __libc_start_main
[2022-05-07 10:21:31,829 E 2888918 2888918] logging.cc:325: *** SIGABRT received at time=1651890091 on cpu 3 ***
[2022-05-07 10:21:31,829 E 2888918 2888918] logging.cc:325: PC: @     0x7fc3d04ea03b  (unknown)  raise
[2022-05-07 10:21:31,830 E 2888918 2888918] logging.cc:325:     @     0x7fc3d04ea0c0  1379971456  (unknown)
[2022-05-07 10:21:31,830 E 2888918 2888918] logging.cc:325:     @     0x7fc3d053c32c        320  (unknown)
[2022-05-07 10:21:31,830 E 2888918 2888918] logging.cc:325:     @           0x40597c       1952  main
[2022-05-07 10:21:31,830 E 2888918 2888918] logging.cc:325:     @     0x7fc3d04cb0b3  (unknown)  __libc_start_main
Aborted (core dumped)

Arrow

When libarrow*.so is used, D_GLIBCXX_USE_CXX11_ABI must be set to 1.

# CMakeList.txt
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)

If the D_GLIBCXX_USE_CXX11_ABI set to 0, the error information is as follows:

/usr/bin/ld: CMakeFiles/arrow_demo.dir/arrow_demo.cpp.o: in function `CreateTable()':
arrow_demo.cpp:(.text+0xc1): undefined reference to `arrow::field(std::string, std::shared_ptr<arrow::DataType>, bool, std::shared_ptr<arrow::KeyValueMetadata const>)'
/usr/bin/ld: arrow_demo.cpp:(.text+0x13a): undefined reference to `arrow::field(std::string, std::shared_ptr<arrow::DataType>, bool, std::shared_ptr<arrow::KeyValueMetadata const>)'
/usr/bin/ld: arrow_demo.cpp:(.text+0x1b3): undefined reference to `arrow::field(std::string, std::shared_ptr<arrow::DataType>, bool, std::shared_ptr<arrow::KeyValueMetadata const>)'
/usr/bin/ld: arrow_demo.cpp:(.text+0x22c): undefined reference to `arrow::field(std::string, std::shared_ptr<arrow::DataType>, bool, std::shared_ptr<arrow::KeyValueMetadata const>)'
/usr/bin/ld: CMakeFiles/arrow_demo.dir/arrow_demo.cpp.o: in function `arrow::Result<std::shared_ptr<arrow::Buffer> >::Result(arrow::Status const&)':
...

References

D_GLIBCXX_USE_CXX11_ABI : https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi

Versions / Dependencies

os         ubuntu 20.04.2 LTS

gcc        11.2.0
g++        11.2.0
cmake      3.22.3

ray        1.12.0
ray-cpp    1.12.0
pyarrow    5.0.0

Reproduction script

# CMakeLists.txt

# cmake verson
cmake_minimum_required(VERSION 3.22.3)

# D_GLIBCXX_USE_CXX11_ABI
# add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)

project(ray_and_arrow_demo)

link_directories(***/lib)
include_directories(***/include)

# ray_and_arrow_demo
add_executable(ray_and_arrow_demo ray_and_arrow_demo.cc)
add_library(ray_and_arrow_demo_code SHARED ray_and_arrow_demo.cc)

target_link_libraries(ray_and_arrow_demo -larrow -lray_api)
target_link_libraries(ray_and_arrow_demo_code -larrow -lray_api)

Issue Severity

High: It blocks me from completing my task.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++-WorkerP2Important issue, but not time-criticalcoreIssues that should be addressed in Ray CoreenhancementRequest for new feature and/or capabilitypending-cleanupThis issue is pending cleanup. It will be removed in 2 weeks after being assigned.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions