Skip to content

Commit

Permalink
[Meson] ASan: Fix compilation under LLVM 13
Browse files Browse the repository at this point in the history
LLVM 13 changes the format of the `-asan-use-after-return` option (from
`0|1` to `never|runtime|always`). Unfortunately, the change is not
backward compatible.

Signed-off-by: Paweł Marczewski <[email protected]>
  • Loading branch information
pwmarcz committed Dec 17, 2021
1 parent 624b18c commit de967a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/include/asan.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* -fsanitize=address
* -fno-sanitize-link-runtime
* -mllvm -asan-mapping-offset=0x18000000000
* -mllvm -asan-use-after-return=0
* -mllvm -asan-use-after-return=0 (`never` in LLVM 13 or higher)
* -mllvm -asan-stack=0
* -DASAN
*
Expand Down
7 changes: 6 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,14 @@ if asan
'-fsanitize=address',
'-fno-sanitize-link-runtime',
'-mllvm', '-asan-mapping-offset=' + asan_shadow_start,
'-mllvm', '-asan-use-after-return=0',
'-DASAN',
]

if meson.get_compiler('c').version().version_compare('>=13')
cflags_sanitizers += ['-mllvm', '-asan-use-after-return=never']
else
cflags_sanitizers += ['-mllvm', '-asan-use-after-return=0']
endif
endif

#
Expand Down

0 comments on commit de967a9

Please sign in to comment.