Skip to content

Commit

Permalink
cmake: sparse.template: add COMMAND_ERROR_IS_FATAL
Browse files Browse the repository at this point in the history
There are some situations like #67035 where sparse aborts and returns an
error code before the compiler has generated the .obj file; without any
clear indication that the .obj is missing (in normal situations sparse
prints warnings and _does_ creates the .obj file)

Also, builds are parallel by default and sparse runs tend to be massive
walls of text which all conspires to make it totally impossible to find
the relevant error message. Instead, we get an link-time error.

The only clear indication is the exit code. So catch it and abort the
build ASAP thanks to COMMAND_ERROR_IS_FATAL.

More generally speaking, the default behavior of execute_process() to
ignore errors is crazy. How frequently does a build system run commands
that do NOT matter?

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb committed Dec 28, 2023
1 parent 87d056b commit 6b440b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmake/sca/sparse/sparse.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ endforeach()
foreach(i RANGE ${end_of_options} ${CMAKE_ARGC})
list(APPEND ARGS ${CMAKE_ARGV${i}})
endforeach()
execute_process(COMMAND @CMAKE_COMMAND@ -E env REAL_CC=@CMAKE_C_COMPILER@ @SPARSE_COMPILER@ ${ARGS})
execute_process(COMMAND @CMAKE_COMMAND@ -E env REAL_CC=@CMAKE_C_COMPILER@ @SPARSE_COMPILER@ ${ARGS}
COMMAND_ERROR_IS_FATAL ANY
)

0 comments on commit 6b440b3

Please sign in to comment.