mirror of
https://github.com/NixOS/nix
synced 2025-06-30 19:57:59 +02:00
Merge pull request #12615 from xokdvium/ubsan-checks
flake: Enable UBSAN for checks
This commit is contained in:
commit
8e8edb5bf8
2 changed files with 36 additions and 6 deletions
38
flake.nix
38
flake.nix
|
@ -263,18 +263,46 @@
|
||||||
flatMapAttrs
|
flatMapAttrs
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"" = nixpkgsFor.${system}.native;
|
# Run all tests with UBSAN enabled. Running both with ubsan and
|
||||||
|
# without doesn't seem to have much immediate benefit for doubling
|
||||||
|
# the GHA CI workaround.
|
||||||
|
#
|
||||||
|
# TODO: Work toward enabling "address,undefined" if it seems feasible.
|
||||||
|
# This would maybe require dropping Boost coroutines and ignoring intentional
|
||||||
|
# memory leaks with detect_leaks=0.
|
||||||
|
"" = rec {
|
||||||
|
nixpkgs = nixpkgsFor.${system}.native;
|
||||||
|
nixComponents = nixpkgs.nixComponents.overrideScope (
|
||||||
|
nixCompFinal: nixCompPrev: {
|
||||||
|
mesonComponentOverrides = _finalAttrs: prevAttrs: {
|
||||||
|
mesonFlags =
|
||||||
|
(prevAttrs.mesonFlags or [ ])
|
||||||
|
# TODO: Macos builds instrumented with ubsan take very long
|
||||||
|
# to run functional tests.
|
||||||
|
++ lib.optionals (!nixpkgs.stdenv.hostPlatform.isDarwin) [
|
||||||
|
(lib.mesonOption "b_sanitize" "undefined")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) {
|
// lib.optionalAttrs (!nixpkgsFor.${system}.native.stdenv.hostPlatform.isDarwin) {
|
||||||
# TODO: enable static builds for darwin, blocked on:
|
# TODO: enable static builds for darwin, blocked on:
|
||||||
# https://github.com/NixOS/nixpkgs/issues/320448
|
# https://github.com/NixOS/nixpkgs/issues/320448
|
||||||
# TODO: disabled to speed up GHA CI.
|
# TODO: disabled to speed up GHA CI.
|
||||||
#"static-" = nixpkgsFor.${system}.native.pkgsStatic;
|
# "static-" = {
|
||||||
|
# nixpkgs = nixpkgsFor.${system}.native.pkgsStatic;
|
||||||
|
# };
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
(
|
(
|
||||||
nixpkgsPrefix: nixpkgs:
|
nixpkgsPrefix:
|
||||||
flatMapAttrs nixpkgs.nixComponents (
|
{
|
||||||
|
nixpkgs,
|
||||||
|
nixComponents ? nixpkgs.nixComponents,
|
||||||
|
}:
|
||||||
|
flatMapAttrs nixComponents (
|
||||||
pkgName: pkg:
|
pkgName: pkg:
|
||||||
flatMapAttrs pkg.tests or { } (
|
flatMapAttrs pkg.tests or { } (
|
||||||
testName: test: {
|
testName: test: {
|
||||||
|
@ -283,7 +311,7 @@
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
// lib.optionalAttrs (nixpkgs.stdenv.hostPlatform == nixpkgs.stdenv.buildPlatform) {
|
// lib.optionalAttrs (nixpkgs.stdenv.hostPlatform == nixpkgs.stdenv.buildPlatform) {
|
||||||
"${nixpkgsPrefix}nix-functional-tests" = nixpkgs.nixComponents.nix-functional-tests;
|
"${nixpkgsPrefix}nix-functional-tests" = nixComponents.nix-functional-tests;
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// devFlake.checks.${system} or { }
|
// devFlake.checks.${system} or { }
|
||||||
|
|
|
@ -17,8 +17,10 @@ struct view_stringbuf : public std::stringbuf
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string_view toView(const std::ostringstream & os)
|
__attribute__((no_sanitize("undefined"))) std::string_view toView(const std::ostringstream & os)
|
||||||
{
|
{
|
||||||
|
/* Downcasting like this is very much undefined behavior, so we disable
|
||||||
|
UBSAN for this function. */
|
||||||
auto buf = static_cast<view_stringbuf *>(os.rdbuf());
|
auto buf = static_cast<view_stringbuf *>(os.rdbuf());
|
||||||
return buf->toView();
|
return buf->toView();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue