Skip to content

Commit 8297db9

Browse files
committed
fix(build): support sanitizers in single-file builds
2 parents d37312d + bf78485 commit 8297db9

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎src/commands/BuildCommand.cpp‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6411,8 +6411,23 @@ namespace vix::commands::BuildCommand
64116411
runOpt.withSqlite = opt_.withSqlite;
64126412
runOpt.withMySql = opt_.withMySql;
64136413

6414-
runOpt.enableSanitizers = false;
6415-
runOpt.enableUbsanOnly = false;
6414+
// Single-file builds reuse the script engine. Do not silently drop the
6415+
// sanitizer selected by `vix build`: its cache key and generated CMake
6416+
// fallback both need the same instrumentation choice.
6417+
runOpt.enableSanitizers =
6418+
opt_.sanitizerMode == process::SanitizerMode::AddressUndefined;
6419+
runOpt.enableUbsanOnly =
6420+
opt_.sanitizerMode == process::SanitizerMode::Undefined;
6421+
runOpt.enableThreadSanitizer =
6422+
opt_.sanitizerMode == process::SanitizerMode::Thread;
6423+
6424+
if (opt_.sanitizerMode == process::SanitizerMode::Address)
6425+
{
6426+
error("The address-only sanitizer is not supported for single-file builds.");
6427+
hint("Use `vix build file.cpp --sanitize` for address and undefined checks.");
6428+
hint("`--asan` remains available for CMake and vix.app projects.");
6429+
return 2;
6430+
}
64166431

64176432
runOpt.forceServerLike = false;
64186433
runOpt.forceScriptLike = true;
@@ -7526,7 +7541,7 @@ namespace vix::commands::BuildCommand
75267541
out << " --no-up-to-date Disable Ninja dry-run up-to-date detection\n\n";
75277542

75287543
out << "CMake:\n";
7529-
out << " -- [cmake args...] Pass extra arguments to CMake configure\n\n";
7544+
out << " -- [args...] Pass CMake configure arguments (project), or compiler/linker flags (single file)\n\n";
75307545

75317546
out << " -h, --help Show this help\n";
75327547

0 commit comments

Comments
 (0)