ci: fix thread-sanitizer build with lld and PIC googletest

- tsan build failed at link with GNU ld:
  "failed to set dynamic section sizes: bad value" (known binutils +
  ThreadSanitizer incompatibility); install lld and select it via
  -fuse-ld=lld for the tsan job only
- pass -fuse-ld=lld through cxx-flags so it reaches the link line,
  avoiding the semicolon-list pitfall of
  list(APPEND CMAKE_EXE_LINKER_FLAGS ...)
- build the bundled googletest with CMAKE_POSITION_INDEPENDENT_CODE=ON:
  lld rejects R_X86_64_32 relocations from the non-PIC libgtest.a when
  producing the position-independent tsan executable; the bundle is built
  by a separate cmake invocation, so the flag must be set there
This commit is contained in:
Dennis Klein
2026-06-09 17:04:57 +02:00
committed by Dennis Klein
parent 7e30c33bcf
commit 2cf49cc50d
2 changed files with 6 additions and 0 deletions

View File

@@ -81,6 +81,7 @@ jobs:
- name: tsan - name: tsan
options: ENABLE_SANITIZER_THREAD=ON options: ENABLE_SANITIZER_THREAD=ON
cxx-compiler: clang++ cxx-compiler: clang++
cxx-flags: -fuse-ld=lld
steps: steps:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
@@ -100,6 +101,10 @@ jobs:
key: ${{ github.job }}-${{ matrix.sanitizer.name }} key: ${{ github.job }}-${{ matrix.sanitizer.name }}
max-size: 500M max-size: 500M
- name: Install lld
if: matrix.sanitizer.name == 'tsan'
run: sudo apt-get update && sudo apt-get install -y lld
- name: Configure and Build - name: Configure and Build
uses: threeal/cmake-action@v2 uses: threeal/cmake-action@v2
with: with:

View File

@@ -68,6 +68,7 @@ function(build_bundled package bundle)
exec(${CMAKE_COMMAND} -S ${${package}_SOURCE_DIR} -B ${${package}_BINARY_DIR} -G ${CMAKE_GENERATOR} exec(${CMAKE_COMMAND} -S ${${package}_SOURCE_DIR} -B ${${package}_BINARY_DIR} -G ${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${${package}_INSTALL_DIR} -DBUILD_GMOCK=OFF -DCMAKE_INSTALL_PREFIX=${${package}_INSTALL_DIR} -DBUILD_GMOCK=OFF
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
) )
exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR}) exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR})
exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR} --target install) exec(${CMAKE_COMMAND} --build ${${package}_BINARY_DIR} --target install)