Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: sparse.template: add COMMAND_ERROR_IS_FATAL #67036

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

marc-hb
Copy link
Collaborator

@marc-hb marc-hb commented Dec 28, 2023

There are some situations like #67035 or #63003 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?

There are some situations like zephyrproject-rtos#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 <marc.herbert@intel.com>
Copy link
Collaborator

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.

More generally speaking, the default behavior of execute_process() to
ignore errors is crazy.

and to top it, it was not until CMake 3.19 that COMMAND_ERROR_IS_FATAL was introduced.
Until then you actually had to use RESULT_VARIABLE / RESULTS_VARIABLE to get return code, and then use an if() test to decide if execution should be aborted.
Hence a reason why most execute_process() calls are not using COMMAND_ERROR_IS_FATAL.

Thanks for this cleanup.

@marc-hb
Copy link
Collaborator Author

marc-hb commented Jan 6, 2024

Thanks for the review and additional context.

Hence a reason why most execute_process() calls are not using COMMAND_ERROR_IS_FATAL.

Time for a big search/replace?

@marc-hb marc-hb added bug The issue is a bug, or the PR is fixing a bug Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. labels Jan 10, 2024
@marc-hb
Copy link
Collaborator Author

marc-hb commented Jan 12, 2024

Just a one-word long, CMake option fix... anyone besides Torsten?

@fabiobaltieri fabiobaltieri merged commit d4b0273 into zephyrproject-rtos:main Jan 15, 2024
24 checks passed
@marc-hb marc-hb deleted the sparse-obj-fatal branch January 16, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System bug The issue is a bug, or the PR is fixing a bug Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants