aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-03-28 20:27:32 +0000
committerGerrit Code Review <gerrit@lix>2024-03-28 20:27:32 +0000
commit61d394e34431eb18c2f750f04e8934238d3508bd (patch)
treecb1a3aadd651495f499f52d435811d01ebfb6683 /meson.build
parentae065a992d250cbfedb0ca47215f152ea85bc496 (diff)
parent14207e1cf83737443636a25534075427f65c1de4 (diff)
Merge "Build with traps on signed overflow" into main
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build17
1 files changed, 17 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 8766fbf8c..14051a130 100644
--- a/meson.build
+++ b/meson.build
@@ -305,6 +305,23 @@ add_project_arguments(
language : 'cpp',
)
+if cxx.get_id() in ['gcc', 'clang']
+ # 2024-03-24: jade benchmarked the default sanitize reporting in clang and got
+ # a regression of about 10% on hackage-packages.nix with clang. So we are trapping instead.
+ #
+ # This has an overhead of 0-4% on gcc and unmeasurably little on clang, in
+ # Nix evaluation benchmarks.
+ #
+ # N.B. Meson generates a completely nonsense warning here:
+ # https://github.com/mesonbuild/meson/issues/9822
+ # Both of these args cannot be written in the default meson configuration.
+ # b_sanitize=signed-integer-overflow is ignored, and
+ # -fsanitize-undefined-trap-on-error is not representable.
+ sanitize_args = ['-fsanitize=signed-integer-overflow', '-fsanitize-undefined-trap-on-error']
+ add_project_arguments(sanitize_args, language: 'cpp')
+ add_project_link_arguments(sanitize_args, language: 'cpp')
+endif
+
add_project_link_arguments('-pthread', language : 'cpp')
if cxx.get_linker_id() in ['ld.bfd', 'ld.gold']
add_project_link_arguments('-Wl,--no-copy-dt-needed-entries', language : 'cpp')