Skip to content

[Cherry-pick][2.57.0][core][build] Drop -Wl,-pie from vendored RocksDB WITH_TSAN link flags (#64917) - #64937

Merged
elliot-barn merged 1 commit into
releases/2.57.0from
cp-2.57.0-64917
Jul 23, 2026
Merged

elliot-barn merged 1 commit into
releases/2.57.0from
cp-2.57.0-64917

Conversation

@elliot-barn

Copy link
Copy Markdown
Collaborator

Cherry-pick of #64917 (9ec3757) onto releases/2.57.0. Clean cherry-pick, no conflicts.

🤖 Generated with Claude Code

#64917)

## Why are these changes needed?

The postmerge `:ray: core: cpp tsan tests` job has been red since #64759
(Jul 16). #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 #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 #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 #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]>
(cherry picked from commit 9ec3757)
Signed-off-by: elliot-barn <[email protected]>
@elliot-barn
elliot-barn requested review from a team as code owners July 22, 2026 20:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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). The patch (rocksdb-tsan-no-pie.patch) removes the -Wl,-pie flag from CMAKE_EXE_LINKER_FLAGS in RocksDB's CMake configuration, as this flag causes CMake's try_compile checks to fail under Ray's rules_foreign_cc toolchain (clang + static libc++). There are no review comments, and we have no additional feedback to provide.

@ray-gardener ray-gardener Bot added the core Issues that should be addressed in Ray Core label Jul 23, 2026
@elliot-barn
elliot-barn merged commit e39d3e7 into releases/2.57.0 Jul 23, 2026
3 checks passed
@elliot-barn
elliot-barn deleted the cp-2.57.0-64917 branch July 23, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant