mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.39k stars 1.55k forks source link

Improve Clang sanitizer situation by overriding `b_lundef` with `b_sanitize` #13380

Open thesamesam opened 5 days ago

thesamesam commented 5 days ago

We currently just warn when users use b_sanitize with Clang and the default b_lundef, but this is easy to miss and it's also not very Mesony to require a workaround on the user's part for an issue we can diagnose and handle.

We should override b_lundef to default to false if the user didn't specify it, where Clang is being used with b_sanitize.

It was added in https://github.com/mesonbuild/meson/commit/bde99eb6c40a9c7bc4055b0dc84a31021b7623d2 for https://github.com/mesonbuild/meson/issues/764.

At the time, @jpakkane gave https://github.com/mesonbuild/meson/issues/764#issuecomment-250994349 for why we can't fix the default. Maybe things have got better since? If not, given he's working on option refactoring right now...

eli-schwartz commented 5 days ago

The issue is very "fun". gcc inserts a link to libasan.so, while clang inlines the instrumentation code but only for main binaries, not libraries.

What would be really nice is if the linker knew not to worry about specific symbols, but automatically skipping b_lundef seems reasonable given it's effectively a sanity lint and people can just use GCC if they want that (or don't build instrumented test binaries and expect production checks).