Skip to content

Fix ASan build on FreeBSD#10

Open
vkrivopalov wants to merge 1 commit into
tarantool:tarantool/masterfrom
vkrivopalov:freebsd-asan-support
Open

Fix ASan build on FreeBSD#10
vkrivopalov wants to merge 1 commit into
tarantool:tarantool/masterfrom
vkrivopalov:freebsd-asan-support

Conversation

@vkrivopalov
Copy link
Copy Markdown

This MR fixes LuaJIT ASan-instrumented builds on FreeBSD, which currently fail with:

CMake Error at test/cmake/LibRealPath.cmake:27 (message):
Library 'libstdc++.so' is not found

Two issues combine to cause this failure:

  1. add_subdirectory(test) is called unconditionally in the root CMakeLists.txt, even when LUAJIT_USE_TEST=OFF.
    This means test configuration runs regardless of whether tests are needed.
  2. When LUAJIT_USE_ASAN=ON, test/LuaJIT-tests/CMakeLists.txt searches for libstdc++.so to set up an LD_PRELOAD workaround for AddressSanitizer CHECK failed: ../../../sanitizer/asan/asan_interceptors.cc:384 "((__interception::real___cxa_throw)) when using --as-needed and dynamically loaded .so google/sanitizers#934. This workaround is GCC-specific, but FreeBSD uses clang with libc++, not libstdc++.

Verified on FreeBSD 15.0 with clang 19:

mkdir build && cd build
cmake .. -DLUAJIT_USE_ASAN=ON
make -j$(sysctl -n hw.ncpu)
ASAN_OPTIONS=verbosity=1 ./src/luajit -v 2>&1 | grep -i AddressSanitizer

Introduce two fixes to CMake to support ASan-enabled builds on FreeBSD:

1. Move add_subdirectory(test) inside if(LUAJIT_USE_TEST) block.
Previously, the test directory was configured unconditionally even
when LUAJIT_USE_TEST was OFF, wasting configuration time and potentially
triggering errors in the test setup.

2. Skip libstdc++ LD_PRELOAD workaround on FreeBSD.
The workaround for google/sanitizers#934 assumes GCC's libstdc++,
but FreeBSD uses LLVM's libc++ and doesn't require this workaround.

Signed-off-by: Vladimir Krivopalov <argenet@yandex.ru>
@vkrivopalov
Copy link
Copy Markdown
Author

Hi @Buristan,

I looked at another PR currently opened in this repo and found you reply that patches for Tarantool's LuaJIT should go into the mailing list.
Does this still apply? Should I send the patch there or can it be accepted here on GitHub?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant