AK: Use __builtin_offsetof() + -Wno-invalid-offsetof to silence ASAN

ASAN was crying way too much when running the LibJS JIT since the old
OFFSET_OF implementation was too wild for its liking.

By turning off the invalid-offsetof warnings, we can use the offsetof
builtin instead. However, I'm leaving this as a wrapper macro, since
we may still want to do something different for other compilers.
This commit is contained in:
Andreas Kling 2023-11-24 09:24:23 +01:00
parent 1541942e10
commit a6106ca221
Notes: sideshowbarker 2024-07-17 18:49:10 +09:00
2 changed files with 3 additions and 1 deletions

View file

@ -16,7 +16,7 @@
#include <AK/Assertions.h>
#define OFFSET_OF(class, member) (reinterpret_cast<ptrdiff_t>(&reinterpret_cast<class*>(0x1000)->member) - 0x1000)
#define OFFSET_OF(class, member) __builtin_offsetof(class, member)
namespace AK {

View file

@ -6,6 +6,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wno-invalid-offsetof)
add_compile_options(-Wno-unknown-warning-option)
add_compile_options(-Wno-unused-command-line-argument)