Repository navigation
[core][build] Drop -Wl,-pie from vendored RocksDB WITH_TSAN link flags - #64917
Conversation
The postmerge cpp tsan job has been failing since #64759 enabled WITH_TSAN=ON for the vendored RocksDB. RocksDB's WITH_TSAN block appends -Wl,-pie to CMAKE_EXE_LINKER_FLAGS, passing -pie to the linker behind the compiler driver's back. Under the rules_foreign_cc crosstool (clang + static libc++), the driver still emits non-PIE startup objects, so every CMake try_compile probe fails to link and configure aborts at find_package(Threads REQUIRED), breaking the build of all rocksdb-dependent test targets. Patch the vendored archive to drop -Wl,-pie. -fsanitize=thread is kept in compile and link flags, so librocksdb.a remains TSan-instrumented. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: elliot-barn <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a patch to the RocksDB dependency in bazel/ray_deps_setup.bzl to resolve a build configuration issue when compiling with ThreadSanitizer (TSan). Specifically, the patch removes the -Wl,-pie flag from CMAKE_EXE_LINKER_FLAGS in RocksDB's CMake configuration, which previously caused CMake's try_compile checks to fail under the rules_foreign_cc toolchain. There are no review comments, and I have no feedback to provide.
|
Local validation completed: |
…B WITH_TSAN link flags (#64917) (#64937) Cherry-pick of #64917 (9ec3757) onto `releases/2.57.0`. Clean cherry-pick, no conflicts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
ray-project#64917) ## Why are these changes needed? The postmerge `:ray: core: cpp tsan tests` job has been red since ray-project#64759 (Jul 16). ray-project#64759 enabled `WITH_TSAN=ON` for the vendored RocksDB build (via `--define=ray_rocksdb_tsan=true` on `--config=tsan`) to get a TSan-instrumented `librocksdb.a`. However, RocksDB's `WITH_TSAN` block (CMakeLists.txt:373-378 in v10.6.2) does: ```cmake set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -Wl,-pie") ``` `-Wl,-pie` passes `-pie` directly to the linker behind the compiler driver's back. Under the rules_foreign_cc crosstool (clang + static libc++ via `BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a`), the driver still emits non-PIE startup objects, so **every CMake `try_compile` probe fails to link**. Configure then aborts at the first `REQUIRED` check: ``` CMake Error at .../FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find Threads (missing: Threads_FOUND) Call Stack (most recent call first): ... CMakeLists.txt:639 (find_package) ``` and six rocksdb-dependent test targets fail to build (`rocksdb_store_client_test`, `rocksdb_concurrency_test`, `rocksdb_parity_test`, `rocksdb_smoke_test`, `gcs_client_reconnection_test`, `global_state_accessor_test`). Every postmerge build since ray-project#64759 shows this failure (e.g. builds 18631, 18643, ... 18717); it wasn't caught premerge because the tsan job only runs postmerge. The tell in the configure log is that checks *before* the `WITH_TSAN` block (`HAVE_OMIT_LEAF_FRAME_POINTER`, `BUILTIN_ATOMIC`) pass, while every check *after* it fails — including trivial ones like `Looking for pthread.h - not found`. ### Fix Patch the vendored RocksDB archive to drop ` -Wl,-pie` from the `WITH_TSAN` linker flags. `-fsanitize=thread` is kept in both compile and link flags, so the library is still fully TSan-instrumented (the original goal of ray-project#64759). TSan does not require PIE with modern clang/gcc on x86_64/aarch64 Linux; when a driver does need PIE it adds it itself via `-fsanitize=thread` at link time. This only affects the `WITH_TSAN=ON` path (`--config=tsan`); regular builds use the non-TSAN cache entries and are untouched. ## Related issue number N/A — no issue filed for the postmerge breakage; this PR documents it. Root-caused from postmerge build logs (18631/18643/18717) and anyscale/rayturbo build 13564 which inherited the failure. ## Checks - Duplicate-work check: searched open PRs/issues for `tsan`/`rocksdb` — the most recent related change is ray-project#64759 itself; no open PR addresses this configure failure. - AI assistance was used to root-cause the CI failure and draft this change; a human (submitter) reviewed every line. - Local validation: - `patch -p1` applies cleanly to pristine rocksdb v10.6.2. - `bazel build @com_github_facebook_rocksdb//:rocksdb --define=ray_rocksdb_tsan=true` — with the patch, CMake configure proceeds past `find_package(Threads)` and the TSan-instrumented `librocksdb.a` builds (validated on Linux x86_64 with the gcc host toolchain; the exact CI failure mode is clang+static-libc++-specific — gcc defaults to PIE so `-Wl,-pie` is benign there — so the postmerge-config tsan CI job is the authoritative check). - The unpatched failure is reproduced by every postmerge tsan run since Jul 16 (identical `Could NOT find Threads` at CMakeLists.txt:639). - [ ] I've run scripts/format.sh to lint the changes in this PR. - [ ] I've included any doc changes needed for https://docs.ray.io/en/master/. - [x] I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/ - Testing Strategy - [x] Unit tests (existing cpp tsan test targets; this PR unblocks their build) - [ ] Release tests - [ ] This PR is not tested :( 🤖 Generated with [Claude Code](https://claude.com/claude-code) Postmerge run: https://buildkite.com/ray-project/postmerge/builds/18725/canvas Signed-off-by: elliot-barn <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]> Signed-off-by: 400Ping <[email protected]>
Why are these changes needed?
The postmerge
:ray: core: cpp tsan testsjob has been red since #64759 (Jul 16). #64759 enabledWITH_TSAN=ONfor the vendored RocksDB build (via--define=ray_rocksdb_tsan=trueon--config=tsan) to get a TSan-instrumentedlibrocksdb.a. However, RocksDB'sWITH_TSANblock (CMakeLists.txt:373-378 in v10.6.2) does:-Wl,-piepasses-piedirectly to the linker behind the compiler driver's back. Under the rules_foreign_cc crosstool (clang + static libc++ viaBAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a), the driver still emits non-PIE startup objects, so every CMaketry_compileprobe fails to link. Configure then aborts at the firstREQUIREDcheck:and six rocksdb-dependent test targets fail to build (
rocksdb_store_client_test,rocksdb_concurrency_test,rocksdb_parity_test,rocksdb_smoke_test,gcs_client_reconnection_test,global_state_accessor_test). Every postmerge build since #64759 shows this failure (e.g. builds 18631, 18643, ... 18717); it wasn't caught premerge because the tsan job only runs postmerge.The tell in the configure log is that checks before the
WITH_TSANblock (HAVE_OMIT_LEAF_FRAME_POINTER,BUILTIN_ATOMIC) pass, while every check after it fails — including trivial ones likeLooking for pthread.h - not found.Fix
Patch the vendored RocksDB archive to drop
-Wl,-piefrom theWITH_TSANlinker flags.-fsanitize=threadis kept in both compile and link flags, so the library is still fully TSan-instrumented (the original goal of #64759). TSan does not require PIE with modern clang/gcc on x86_64/aarch64 Linux; when a driver does need PIE it adds it itself via-fsanitize=threadat link time.This only affects the
WITH_TSAN=ONpath (--config=tsan); regular builds use the non-TSAN cache entries and are untouched.Related issue number
N/A — no issue filed for the postmerge breakage; this PR documents it. Root-caused from postmerge build logs (18631/18643/18717) and anyscale/rayturbo build 13564 which inherited the failure.
Checks
Duplicate-work check: searched open PRs/issues for
tsan/rocksdb— the most recent related change is [core][build] Fix TSAN false-positive data races in RocksDB GCS backend #64759 itself; no open PR addresses this configure failure.AI assistance was used to root-cause the CI failure and draft this change; a human (submitter) reviewed every line.
Local validation:
patch -p1applies cleanly to pristine rocksdb v10.6.2.bazel build @com_github_facebook_rocksdb//:rocksdb --define=ray_rocksdb_tsan=true— with the patch, CMake configure proceeds pastfind_package(Threads)and the TSan-instrumentedlibrocksdb.abuilds (validated on Linux x86_64 with the gcc host toolchain; the exact CI failure mode is clang+static-libc++-specific — gcc defaults to PIE so-Wl,-pieis benign there — so the postmerge-config tsan CI job is the authoritative check).Could NOT find Threadsat CMakeLists.txt:639).I've run scripts/format.sh to lint the changes in this PR.
I've included any doc changes needed for https://docs.ray.io/en/master/.
I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
Testing Strategy
🤖 Generated with Claude Code
Postmerge run: https://buildkite.com/ray-project/postmerge/builds/18725/canvas