diff --git a/meson.build b/meson.build index 23e01e700..f306d74df 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/package.nix b/package.nix index 573f6b6cb..b106411fd 100644 --- a/package.nix +++ b/package.nix @@ -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.