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?

@Buristan
Copy link
Copy Markdown
Collaborator

Hi, Vladimir!
Thanks for the patch!
Yes, it will be more convenient to proceed with our mailing lists.

Patch LGTM, but I ask for a minor fixup: to separate it into 2 commits:
1 -- for the test logic fix and the second one for the FreeBSD + ASAN fix.

You may then send the patchset to the mailing lists like the following:

git format-patch --cover-letter --thread=shallow --subject-prefix="PATCH luajit" HEAD~2
# Update 0000-cover-letter.patch header and description.
git send-email --cc=tarantool-patches@dev.tarantool.org --to="Sergey Kaplun <skaplun@tarantool.org>" --to="Sergey Bronnikov <sergeyb@tarantool.org>" 000*

Before using git send-email command, you need to configure it.
If you use a GMail account, add the following code to your .gitconfig:

	[sendemail]
	    smtpencryption = tls
	    smtpserver = smtp.gmail.com
	    smtpserverport = 587
	    smtpuser = your.name@gmail.com
	    smtppass = topsecret

For mail.ru (or yandex.ru with the corresponding changes) users, the configuration will be slightly different:

	[sendemail]
	    smtpencryption = ssl
	    smtpserver = smtp.mail.ru
	    smtpserverport = 465
	    smtpuser = your.name@mail.ru
	    smtppass = topsecret

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.

2 participants