Skip to content

Commit

Permalink
Makefile: error on GENERATE_COMPILATION_DATABASE=yes failure
Browse files Browse the repository at this point in the history
The "GENERATE_COMPILATION_DATABASE=yes" option added in
3821c38 (Makefile: add support for generating JSON compilation
database, 2020-09-03) positively asserts that you'd like to have a
compilation database generated.

If we can't generate the database because CC isn't clang, then we
shouldn't suppress the errors the compiler itself emits.

Doing so appears to have been done only because 3821c38
copy/pasted most of the code from the earlier
"COMPUTE_HEADER_DEPENDENCIES=auto" added in 111ee18 (Makefile: Use
computed header dependencies if the compiler supports it,
2011-08-18).

In the "COMPUTE_HEADER_DEPENDENCIES" we'd like to be more graceful
since we'll try to turn it on without the user asking, but as
"GENERATE_COMPILATION_DATABASE=yes" is purely opt-in we shouldn't
ignore STDERR on the user's behalf.

So let's stop suppressing STDERR, and call $(error) instead of
$(warning) if we fail here.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  • Loading branch information
avar committed Sep 22, 2021
1 parent 6b18bd0 commit d4bcc0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Makefile
Expand Up @@ -1306,12 +1306,11 @@ ifeq ($(GENERATE_COMPILATION_DATABASE),yes)
compdb_check = $(shell $(CC) $(ALL_CFLAGS) \
-Wno-pedantic \
-c -MJ /dev/null \
-x c /dev/null -o /dev/null 2>&1; \
-x c /dev/null -o /dev/null; \
echo $$?)
ifneq ($(compdb_check),0)
override GENERATE_COMPILATION_DATABASE = no
$(warning GENERATE_COMPILATION_DATABASE is set to "yes", but your compiler does not \
support generating compilation database entries)
$(error Generating the compilation database failed. If your compiler does not \
support generating compilation database entries, do not set GENERATE_COMPILATION_DATABASE=yes)
endif
else
ifneq ($(GENERATE_COMPILATION_DATABASE),no)
Expand Down

0 comments on commit d4bcc0e

Please sign in to comment.