Subject: bug#70716: flymake-cc creates `-.o` files

From: [email-masked]
Date: Wed, 28 Aug 2024 17:01:18 +0000 (UTC)

Mattias Engdegård <[email-masked]> writes:
> `flymake-cc-use-special-make-target`, the standard value for `flymake-cc-command`, generates a command like
>
>   make check-syntax CHK_SOURCES="-x c -c -"
>
> which causes the compiler (at least Clang) to create the file `-.o` that is never cleaned up and whose name is mysterious and awkward to remove.
>
> What about the patch below?

(info "(flymake) Example---Configuring a tool called via make")

mentions a check-syntax target looking like:

check-syntax:
	gcc -o /dev/null -S ${CHK_SOURCES} || true

So it seems like it would be better to add this -o /dev/null in your
Makefile.

That also allows you to run, e.g.,

  make check-syntax CHK_SOURCES="file1.c file2.c"

from a shell or M-x compile.

So I think this is a bug in your Makefile, not flymake-cc.

But, also, probably the docstring of flymake-cc-use-special-make-target
should be updated to link to the manual.  And probably the manual should
mention that CHK_SOURCES can be an explicit list of files too.

BTW, the CHK_SOURCES target mentioned by flymake is, AFAICT from web
searches, completely unique to flymake.  I wonder if there's a more
standard alternative... but we probably can't change the default of
flymake-cc-command anyway.