diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2019-05-09 00:03:41 +0200 |
---|---|---|
committer | Evgeny Vereshchagin <evvers@ya.ru> | 2019-05-14 13:42:17 +0200 |
commit | 9c5c4677fa22c2fc87599c15ca972627ceb17bd7 (patch) | |
tree | f91f1e13982e360cdc1e61f9669dfcca3179918e /meson.build | |
parent | 8c6637bab2a4a3caee28a5337f7c2fcedf43c246 (diff) | |
download | systemd-9c5c4677fa22c2fc87599c15ca972627ceb17bd7.tar.gz systemd-9c5c4677fa22c2fc87599c15ca972627ceb17bd7.tar.bz2 systemd-9c5c4677fa22c2fc87599c15ca972627ceb17bd7.zip |
fuzzers: use -fsanitizer=fuzzer if clang supports it
Closes https://github.com/systemd/systemd/issues/10645
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/meson.build b/meson.build index eaf0eddcb1..9506274239 100644 --- a/meson.build +++ b/meson.build @@ -303,7 +303,14 @@ else endif if want_libfuzzer - fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer') + fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer', required : false) + if fuzzing_engine.found() + add_project_arguments('-fsanitize-coverage=trace-pc-guard,trace-cmp', language : 'c') + elif cc.has_argument('-fsanitize=fuzzer-no-link') + add_project_arguments('-fsanitize=fuzzer-no-link', language : 'c') + else + error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported') + endif elif want_ossfuzz fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine') elif want_fuzzbuzz @@ -2825,9 +2832,16 @@ foreach tuple : fuzzers dependencies = tuple[2] defs = tuple.length() >= 4 ? tuple[3] : [] incs = tuple.length() >= 5 ? tuple[4] : includes + link_args = [] - if fuzzer_build + if want_ossfuzz or want_fuzzbuzz dependencies += fuzzing_engine + elif want_libfuzzer + if fuzzing_engine.found() + dependencies += fuzzing_engine + else + link_args += ['-fsanitize=fuzzer'] + endif else sources += 'src/fuzz/fuzz-main.c' endif @@ -2845,6 +2859,7 @@ foreach tuple : fuzzers link_with : link_with, dependencies : dependencies, c_args : defs, + link_args: link_args, install : false) endforeach endif |