All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Mayer <mmayer@broadcom.com>
To: DTC Mailing List <devicetree-compiler@vger.kernel.org>
Cc: Markus Mayer <mmayer@broadcom.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 0/1] DTC v1.7.1 Build Error
Date: Tue,  8 Oct 2024 14:41:31 -0700	[thread overview]
Message-ID: <20241008214134.171436-1-mmayer@broadcom.com> (raw)

Hi all,

Our automated build environment flagged a new build error introduced by
DTC 1.7.1. Specifically, a compiler option (warning) that was added is
only supported by gcc but not by clang. This results in the build
failing immediately if clang is being used.

clang-18 -I libfdt -I . -DFDT_ASSUME_MASK=0 -DNO_VALGRIND -g -Os -fPIC
  -Werror -Wall -Wpointer-arith -Wcast-qual -Wnested-externs -Wsign-compare
  -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
  -Wsuggest-attribute=format -Wwrite-strings  -DNO_YAML -o srcpos.o -c
  srcpos.c
error: unknown warning option '-Wsuggest-attribute=format'; did you mean
  '-Wproperty-attribute-mismatch'? [-Werror,-Wunknown-warning-option]
make: *** [Makefile:359: srcpos.o] Error 1

The commit in question is [1]

e3cde0613bfd Add -Wsuggest-attribute=format warning, correct warnings thus generated

This commit was not part of v1.7.0 and is part of v1.7.1. The problem
is, clang doesn't like this option, and with -Werror enabled, the build
fails. Meanwhile, clang is perfectly capable of building dtc once the
offending option has been removed.

I am submitting a potential solution to this problem that relies on some
Makefile code taken from the Linux kernel to detect if the compiler
supports a certain option or not. Admittedly, the added code is a bit
wordy, but it should work very well going forward if another such
situation occurs. It is also very concise and easy to read when it is
being used.

Lastly, here is some debug output to show how the value of $(WARNINGS)
is affected by the compiler.

# using gcc
$ make
Makefile:49: *** The warnings are: -Wall -Wpointer-arith -Wcast-qual
  -Wnested-externs -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes
  -Wredundant-decls -Wshadow -Wwrite-strings -Wsuggest-attribute=format.
Stop.

# using clang
$ CC=clang-18 make
Makefile:49: *** The warnings are: -Wall -Wpointer-arith -Wcast-qual
  -Wnested-externs -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes
  -Wredundant-decls -Wshadow -Wwrite-strings .
Stop.

As intended, "-Wsuggest-attribute=format" disappears if clang is being
used, and with this, clang can successfully complete the build.

Please let me know what you think.

Thanks,
-Markus

[1] https://git.kernel.org/pub/scm/utils/dtc/dtc.git/commit/?id=e3cde0613bfd

Markus Mayer (1):
  Makefile: only use compiler flags when supported

 Makefile | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

-- 
2.46.0


             reply	other threads:[~2024-10-08 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08 21:41 Markus Mayer [this message]
2024-10-08 21:41 ` [PATCH 1/1] Makefile: only use compiler flags when supported Markus Mayer
2024-10-09  1:57   ` Simon Glass
2024-10-09 20:43     ` Markus Mayer
2024-10-09 21:15       ` Simon Glass
2024-10-09 21:18         ` Markus Mayer
2024-10-16  9:32   ` David Gibson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241008214134.171436-1-mmayer@broadcom.com \
    --to=mmayer@broadcom.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=devicetree-compiler@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.