Skip to content

GH-40394: [C++] Add support for mold#40397

Merged
assignUser merged 7 commits intoapache:mainfrom
kou:cpp-mold
Mar 13, 2024
Merged

GH-40394: [C++] Add support for mold#40397
assignUser merged 7 commits intoapache:mainfrom
kou:cpp-mold

Conversation

@kou
Copy link
Copy Markdown
Member

@kou kou commented Mar 7, 2024

Rationale for this change

mold is a faster linker. It will reduce build time.

mold supports only ELF. So it's available on only Linux and *BSD.

What changes are included in this PR?

Add new ARROW_USE_MOLD CMake option. It's OFF by default because it doesn't work with conda.

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

@kou kou requested review from assignUser and raulcd as code owners March 7, 2024 06:56
@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 7, 2024

@github-actions crossbow submit -g cpp -g linux

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2024

⚠️ GitHub issue #40394 has been automatically assigned in GitHub to PR creator.

@github-actions

This comment was marked as outdated.

@pitrou
Copy link
Copy Markdown
Member

pitrou commented Mar 7, 2024

I get the following warnings when building:

[407/859] Linking CXX shared library debug/libarrow.so.1600.0.0
mold: warning: /home/antoine/arrow/dev/cpp/src/arrow/symbols.map: cannot assign version `global` to symbol `descriptor_table_Flight_2eproto`: symbol not found
mold: warning: /home/antoine/arrow/dev/cpp/src/arrow/symbols.map: cannot assign version `global` to symbol `descriptor_table_FlightSql_2eproto`: symbol not found
[591/859] Linking CXX shared library debug/libarrow_cuda.so.1600.0.0
mold: warning: /home/antoine/arrow/dev/cpp/src/arrow/symbols.map: cannot assign version `global` to symbol `descriptor_table_Flight_2eproto`: symbol not found
mold: warning: /home/antoine/arrow/dev/cpp/src/arrow/symbols.map: cannot assign version `global` to symbol `descriptor_table_FlightSql_2eproto`: symbol not found

and then I get various kinds of crashes when running the tests.

@pitrou
Copy link
Copy Markdown
Member

pitrou commented Mar 7, 2024

arrow-acero-fetch-node-test throws an exception here:

#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737222772352) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140737222772352) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140737222772352, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007ffff4314476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007ffff42fa7f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007ffff45f3f00 in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#6  0x00007ffff45f243c in __cxxabiv1::__terminate (handler=<optimized out>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:48
#7  0x00007ffff45f248e in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:58
#8  0x00007ffff45f2680 in __cxxabiv1::__cxa_throw (obj=0x55555561cd70, tinfo=0x7ffff47108d8 <typeinfo for std::system_error>, 
    dest=0x7ffff460fa28 <std::system_error::~system_error()>) at ../../../../libstdc++-v3/libsupc++/eh_throw.cc:98
#9  0x00007ffff45ec92b in std::__throw_system_error (__i=-1)
    at /home/conda/feedstock_root/build_artifacts/gcc_compilers_1706816862910/work/build/x86_64-conda-linux-gnu/libstdc++-v3/include/system_error:233
#10 0x000055555559dcc3 in std::call_once<arrow::acero::RegisterTestNodes()::<lambda()> >(std::once_flag &, struct {...} &&) (__once=..., __f=...)
    at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.3.0/mutex:860
#11 0x000055555559ac67 in arrow::acero::RegisterTestNodes () at /home/antoine/arrow/dev/cpp/src/arrow/acero/test_nodes.cc:360
#12 0x00005555555cc53a in arrow::acero::CheckFetch (options=...) at /home/antoine/arrow/dev/cpp/src/arrow/acero/fetch_node_test.cc:43
#13 0x00005555555cd976 in arrow::acero::FetchNode_Basic_Test::TestBody (this=0x55555561d320) at /home/antoine/arrow/dev/cpp/src/arrow/acero/fetch_node_test.cc:75
#14 0x00007ffff7d5f6d6 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x55555561d320, method=&virtual testing::Test::TestBody(), 
    location=0x7ffff7d26f83 "the test body") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2665
#15 0x00007ffff7d39b6f in testing::Test::Run (this=0x55555561d320) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2682
#16 0x00007ffff7d3a625 in testing::TestInfo::Run (this=0x55555561eba0) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2861
#17 0x00007ffff7d3b011 in testing::TestSuite::Run (this=0x55555561d4b0) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:3015
#18 0x00007ffff7d4b7d9 in testing::internal::UnitTestImpl::RunAllTests (this=0x55555561ca50) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:5855
#19 0x00007ffff7d608c4 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x55555561ca50, 
    method=(bool (testing::internal::UnitTestImpl::*)(class testing::internal::UnitTestImpl * const)) 0x7ffff7d4b3c2 <testing::internal::UnitTestImpl::RunAllTests()>, 
    location=0x7ffff7d279e8 "auxiliary test code (environments or event listeners)") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2665
#20 0x00007ffff7d49be3 in testing::UnitTest::Run (this=0x7ffff7d80ec0 <testing::UnitTest::GetInstance()::instance>)
    at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:5438
#21 0x00007ffff7d82a02 in RUN_ALL_TESTS () at /build/build-test/_deps/googletest-src/googletest/include/gtest/gtest.h:2490
#22 0x00007ffff7d82a4b in main (argc=1, argv=0x7fffffffc0f8) at /build/build-test/_deps/googletest-src/googletest/src/gtest_main.cc:52

@pitrou
Copy link
Copy Markdown
Member

pitrou commented Mar 7, 2024

arrow-acero-util-test hangs here:

#0  __futex_abstimed_wait_common64 (private=0, cancel=true, abstime=0x0, op=393, expected=0, futex_word=0x555555621c20) at ./nptl/futex-internal.c:57
#1  __futex_abstimed_wait_common (cancel=true, private=0, abstime=0x0, clockid=0, expected=0, futex_word=0x555555621c20) at ./nptl/futex-internal.c:87
#2  __GI___futex_abstimed_wait_cancelable64 (futex_word=futex_word@entry=0x555555621c20, expected=expected@entry=0, clockid=clockid@entry=0, abstime=abstime@entry=0x0, private=private@entry=0) at ./nptl/futex-internal.c:139
#3  0x00007ffff4365a41 in __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x555555621b70, cond=0x555555621bf8) at ./nptl/pthread_cond_wait.c:503
#4  ___pthread_cond_wait (cond=0x555555621bf8, mutex=0x555555621b70) at ./nptl/pthread_cond_wait.c:627
#5  0x00007ffff7421774 in std::condition_variable::wait<arrow::internal::ThreadPool::WaitForIdle()::<lambda()> >(std::unique_lock<std::mutex> &, struct {...}) (this=0x555555621bf8, __lock=..., __p=...) at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.3.0/condition_variable:102
#6  0x00007ffff741f612 in arrow::internal::ThreadPool::WaitForIdle (this=0x55555561e0d0) at /home/antoine/arrow/dev/cpp/src/arrow/util/thread_pool.cc:497
#7  0x00005555555cad6a in arrow::acero::MakePrimedThreadPool (num_threads=11) at /home/antoine/arrow/dev/cpp/src/arrow/acero/task_util_test.cc:67
#8  0x00005555555ccf33 in arrow::acero::TaskScheduler_StressTwo_Test::TestBody (this=0x55555561a930) at /home/antoine/arrow/dev/cpp/src/arrow/acero/task_util_test.cc:193
#9  0x00007ffff7d686d1 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void> (object=0x55555561a930, method=&virtual testing::Test::TestBody(), location=0x7ffff7d26f83 "the test body") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2607
#10 0x00007ffff7d5f691 in testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void> (object=0x55555561a930, method=&virtual testing::Test::TestBody(), location=0x7ffff7d26f83 "the test body") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2643
#11 0x00007ffff7d39b6f in testing::Test::Run (this=0x55555561a930) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2682
#12 0x00007ffff7d3a625 in testing::TestInfo::Run (this=0x55555561c2f0) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2861
#13 0x00007ffff7d3b011 in testing::TestSuite::Run (this=0x55555560b180) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:3015
#14 0x00007ffff7d4b7d9 in testing::internal::UnitTestImpl::RunAllTests (this=0x55555561aa50) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:5855
#15 0x00007ffff7d69690 in testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x55555561aa50, method=(bool (testing::internal::UnitTestImpl::*)(class testing::internal::UnitTestImpl * const)) 0x7ffff7d4b3c2 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x7ffff7d279e8 "auxiliary test code (environments or event listeners)") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2607
#16 0x00007ffff7d60878 in testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> (object=0x55555561aa50, method=(bool (testing::internal::UnitTestImpl::*)(class testing::internal::UnitTestImpl * const)) 0x7ffff7d4b3c2 <testing::internal::UnitTestImpl::RunAllTests()>, location=0x7ffff7d279e8 "auxiliary test code (environments or event listeners)") at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:2643
#17 0x00007ffff7d49be3 in testing::UnitTest::Run (this=0x7ffff7d80ec0 <testing::UnitTest::GetInstance()::instance>) at /build/build-test/_deps/googletest-src/googletest/src/gtest.cc:5438
#18 0x00007ffff7d82a02 in RUN_ALL_TESTS () at /build/build-test/_deps/googletest-src/googletest/include/gtest/gtest.h:2490
#19 0x00007ffff7d82a4b in main (argc=1, argv=0x7fffffffc108) at /build/build-test/_deps/googletest-src/googletest/src/gtest_main.cc:52

@pitrou
Copy link
Copy Markdown
Member

pitrou commented Mar 7, 2024

I think the bottom line is that, for now, we cannot enable mold by default.

@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 7, 2024

The warnings are caused by sharing cpp/src/arrow/symbols.map with libarrow*.so.
descriptor_table_Flight_2eproto exists only in libarrow_flight.so and descriptor_table_FlightSql_2eproto exists only in libarrow_flight_sql.so.
I used * to suppress the warnings.

@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 7, 2024

These test problems aren't happen on my environment. (g++ (Debian 13.2.0-13) 13.2.0)
But mold doesn't work with conda. I'll disable this by default.

mold doesn't work with conda.
@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 7, 2024

@github-actions crossbow submit -g cpp -g linux

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 7, 2024

Revision: c24db80

Submitted crossbow builds: ursacomputing/crossbow @ actions-cbd198594d

Task Status
almalinux-8-amd64 GitHub Actions
almalinux-8-arm64 GitHub Actions
almalinux-9-amd64 GitHub Actions
almalinux-9-arm64 GitHub Actions
amazon-linux-2023-amd64 GitHub Actions
amazon-linux-2023-arm64 GitHub Actions
centos-7-amd64 GitHub Actions
centos-8-stream-amd64 GitHub Actions
centos-8-stream-arm64 GitHub Actions
centos-9-stream-amd64 GitHub Actions
centos-9-stream-arm64 GitHub Actions
debian-bookworm-amd64 GitHub Actions
debian-bookworm-arm64 GitHub Actions
debian-bullseye-amd64 GitHub Actions
debian-bullseye-arm64 GitHub Actions
debian-trixie-amd64 GitHub Actions
debian-trixie-arm64 GitHub Actions
test-alpine-linux-cpp GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind Azure
test-cuda-cpp GitHub Actions
test-debian-11-cpp-amd64 GitHub Actions
test-debian-11-cpp-i386 GitHub Actions
test-fedora-39-cpp GitHub Actions
test-ubuntu-20.04-cpp GitHub Actions
test-ubuntu-20.04-cpp-bundled GitHub Actions
test-ubuntu-20.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-20.04-cpp-thread-sanitizer GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-20 GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
ubuntu-focal-amd64 GitHub Actions
ubuntu-focal-arm64 GitHub Actions
ubuntu-jammy-amd64 GitHub Actions
ubuntu-jammy-arm64 GitHub Actions
ubuntu-noble-amd64 GitHub Actions
ubuntu-noble-arm64 GitHub Actions

@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 8, 2024

Hmm. It seems that mold doesn't work with sanitizers. I disabled ARROW_USE_MOLD if one of ARROW_USE_{ASAN,TSAN,UBSAN} is specified.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Mar 9, 2024
@kou
Copy link
Copy Markdown
Member Author

kou commented Mar 11, 2024

I'll merge this tomorrow if nobody objects this.

Copy link
Copy Markdown
Member

@assignUser assignUser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@assignUser assignUser merged commit 60dbaab into apache:main Mar 13, 2024
@assignUser assignUser removed the awaiting changes Awaiting changes label Mar 13, 2024
@assignUser assignUser linked an issue Mar 13, 2024 that may be closed by this pull request
@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Mar 13, 2024
@kou kou deleted the cpp-mold branch March 13, 2024 04:36
@conbench-apache-arrow
Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit 60dbaab.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 4 possible false positives for unstable benchmarks that are known to sometimes produce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++] Add support for mold

3 participants