build: update integer overflow sanitizer handling for fixed meson bugs

Change-Id: I27f33e66e107d4af13abe62257be8c696a6a6964
This commit is contained in:
Qyriad
2026-06-30 18:56:51 +00:00
parent 5434ddf4cd
commit 22e2ecdc43
2 changed files with 11 additions and 12 deletions
+10 -12
View File
@@ -43,6 +43,9 @@ project('lix', 'cpp', 'rust',
'debug=true',
'optimization=2',
'errorlogs=true', # Please print logs for tests that fail
# Instead of using the default sanitizer, we combine this with
# -fsanitize-undefined-trap-on-error below in this file.
'b_sanitize=signed-integer-overflow',
],
)
@@ -682,20 +685,15 @@ add_project_arguments(
language : 'cpp',
)
# We turn off the production UBSan if the slower dev UBSan is requested, to
# give better diagnostics.
if cxx.get_id() in ['gcc', 'clang'] and 'undefined' not in get_option('b_sanitize')
# 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 unmeasurably low overhead in Nix evaluation benchmarks.
#
# 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 if the
# signed-integer-overflow sanitizer is requested (our default), we trap instead.
# Trapping has an unmeasurably low overhead in Nix evaluation benchmarks.
if cxx.get_id() in ['gcc', 'clang'] and 'signed-integer-overflow' in get_option('b_sanitize')
# 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']
# -fsanitize-undefined-trap-on-error is not representable in -Db_sanitize=
sanitize_args = ['-fsanitize-undefined-trap-on-error']
add_project_arguments(sanitize_args, language: 'cpp')
add_project_link_arguments(sanitize_args, language: 'cpp')
endif
+1
View File
@@ -453,6 +453,7 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optionals hostPlatform.isStatic [
"-Denable-embedded-sandbox-shell=true"
"-Denable-contrib-plugins=false"
"-Db_sanitize=none"
]
++ lib.optional ciBuildAndDeleteBothLibraries "-Ddefault_library=both"
# musl doesn't support fibers, and we can't detect this with meson alone.