* [PATCH 0/5] clang: more warning and error fixes
@ 2026-09-04 7:59 Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 1/5] kbuild: emit asm-offsets markers as .ascii strings Ahmad Fatoum
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
In preparation for making bare metal targets also compile with clang,
here are some more warning and error fixes for both assembler and compiler.
Ahmad Fatoum (5):
kbuild: emit asm-offsets markers as .ascii strings
scripts: imx9image: fix warnings reported by clang
kbuild: disable -Wunused-but-set-variable after -Wall
kbuild: disable -Winitializer-overrides for clang
ARM64: cache: use WEAK() for v8_flush_l3_cache stub
Makefile | 4 ----
arch/arm/cpu/cache-armv8.S | 3 +--
include/linux/kbuild.h | 6 +++---
scripts/Makefile.warn | 8 ++++++++
scripts/imx9image.c | 9 ++-------
5 files changed, 14 insertions(+), 16 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] kbuild: emit asm-offsets markers as .ascii strings
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
@ 2026-09-04 7:59 ` Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 2/5] scripts: imx9image: fix warnings reported by clang Ahmad Fatoum
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
From: Ahmad Fatoum <a.fatoum@barebox.org>
The DEFINE()/BLANK()/COMMENT() macros emit their "->" markers as bare
lines, which clang's integrated assembler rejects:
arch/arm/lib/asm-offsets.c:16:3: error: unexpected token at start of statement
Switch to the .ascii form from Linux commit cf0c3e68aa81 ("kbuild: fix
asm-offset generation to work with clang"). $(sed-offsets) already
handles both forms and the generated header is byte-identical.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
include/linux/kbuild.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index de0f9bdb952f..6023904b5b67 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -4,14 +4,14 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
-#define BLANK() asm volatile("\n->" : : )
+#define BLANK() asm volatile("\n.ascii \"->\"" : : )
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
#define COMMENT(x) \
- asm volatile("\n->#" x)
+ asm volatile("\n.ascii \"->#" x "\"")
#endif
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] scripts: imx9image: fix warnings reported by clang
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 1/5] kbuild: emit asm-offsets markers as .ascii strings Ahmad Fatoum
@ 2026-09-04 7:59 ` Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 3/5] kbuild: disable -Wunused-but-set-variable after -Wall Ahmad Fatoum
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
From: Ahmad Fatoum <a.fatoum@barebox.org>
Host tools inherit -Werror with CONFIG_WERROR=y and clang fails on:
scripts/imx9image.c:889:6: error: variable 'cont_img_count' set but not used [-Werror,-Wunused-but-set-variable]
scripts/imx9image.c:1263:33: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
Drop the unused counter and the extra parentheses.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
scripts/imx9image.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/scripts/imx9image.c b/scripts/imx9image.c
index 61b7cc943f00..bd015a6ab7fc 100644
--- a/scripts/imx9image.c
+++ b/scripts/imx9image.c
@@ -886,7 +886,6 @@ static int build_container_qx_qm_b0(soc_type_t soc, uint32_t sector_size, uint32
const char *platform;
int container = -1;
- int cont_img_count = 0; /* indexes to arrange the container */
if (image_stack == NULL) {
fprintf(stderr, "Empty image stack ");
@@ -948,7 +947,6 @@ static int build_container_qx_qm_b0(soc_type_t soc, uint32_t sector_size, uint32
img_sp->src = file_off;
file_off += ALIGN(sbuf.st_size, sector_size);
- cont_img_count++;
break;
case DUMMY_V2X:
@@ -966,7 +964,6 @@ static int build_container_qx_qm_b0(soc_type_t soc, uint32_t sector_size, uint32
images_hash);
img_sp->src = file_off;
- cont_img_count++;
break;
case SECO:
@@ -986,7 +983,6 @@ static int build_container_qx_qm_b0(soc_type_t soc, uint32_t sector_size, uint32
img_sp->src = file_off;
file_off += sbuf.st_size;
- cont_img_count++;
break;
case NEW_CONTAINER:
@@ -995,7 +991,6 @@ static int build_container_qx_qm_b0(soc_type_t soc, uint32_t sector_size, uint32
CONTAINER_ALIGNMENT,
CONTAINER_FLAGS_DEFAULT,
fuse_version);
- cont_img_count = 0; /* reset img count when moving to new container */
scfw_flags = 0;
break;
@@ -1260,12 +1255,12 @@ static void print_image_array_fields(struct flash_header_v3 *container_hdrs, soc
if ((soc == ULP) || (soc == IMX9)) {
if (img_flags.core_id == CORE_ULP_UPOWER)
strcpy(img_name, "uPower FW");
- else if ((img_flags.core_id == CORE_ULP_CA35))
+ else if (img_flags.core_id == CORE_ULP_CA35)
if (app_cntr)
strcpy(img_name, "A core Image");
else
strcpy(img_name, "Bootloader");
- else if ((img_flags.core_id == CORE_ULP_CM33))
+ else if (img_flags.core_id == CORE_ULP_CM33)
strcpy(img_name, "M33");
} else {
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] kbuild: disable -Wunused-but-set-variable after -Wall
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 1/5] kbuild: emit asm-offsets markers as .ascii strings Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 2/5] scripts: imx9image: fix warnings reported by clang Ahmad Fatoum
@ 2026-09-04 7:59 ` Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 4/5] kbuild: disable -Winitializer-overrides for clang Ahmad Fatoum
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
From: Ahmad Fatoum <a.fatoum@barebox.org>
The top-level Makefile passes -Wno-unused-but-set-variable before
scripts/Makefile.warn adds -Wall. GCC keeps the warning disabled, but
clang processes options in order and re-enables it, failing dozens of
files with CONFIG_WERROR=y:
drivers/video/edid.c:390:6: error: variable 'hfmin' set but not used [-Werror,-Wunused-but-set-variable]
Move the option after -Wall in scripts/Makefile.warn, where Linux'
scripts/Makefile.extrawarn has it.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
Makefile | 4 ----
scripts/Makefile.warn | 5 +++++
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index be81ac70403d..8762d2ae68b9 100644
--- a/Makefile
+++ b/Makefile
@@ -833,10 +833,6 @@ endif
# Clear used registers at func exit (to reduce data lifetime and ROP gadgets).
KBUILD_CFLAGS-$(CONFIG_ZERO_CALL_USED_REGS) += -fzero-call-used-regs=used-gpr
-# This warning generated too much noise in a regular build.
-# Use make W=1 to enable this warning (see scripts/Makefile.build)
-KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
-
KBUILD_CFLAGS += $(call cc-disable-warning, trampolines)
KBUILD_CFLAGS += $(call cc-option, -fno-delete-null-pointer-checks,)
diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
index a39c8223352a..393f7fd522c8 100644
--- a/scripts/Makefile.warn
+++ b/scripts/Makefile.warn
@@ -43,6 +43,11 @@ endif
# disable pointer signed / unsigned warnings in gcc 4.0
KBUILD_CFLAGS += -Wno-pointer-sign
+# Some diagnostics enabled by default are noisy. Unlike GCC, Clang re-enables
+# them when -Wall is passed later on the command line, so the -Wno... options
+# must come after -Wall
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+
#
# W=e and CONFIG_WERROR - error out on warnings
#
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] kbuild: disable -Winitializer-overrides for clang
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
` (2 preceding siblings ...)
2026-09-04 7:59 ` [PATCH 3/5] kbuild: disable -Wunused-but-set-variable after -Wall Ahmad Fatoum
@ 2026-09-04 7:59 ` Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 5/5] ARM64: cache: use WEAK() for v8_flush_l3_cache stub Ahmad Fatoum
2026-09-04 9:44 ` [PATCH 0/5] clang: more warning and error fixes Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
From: Ahmad Fatoum <a.fatoum@barebox.org>
clang warns about the intentional [0 ... N] = default followed by
per-entry overrides, e.g. in arch/arm/cpu/interrupts_64.c:
arch/arm/cpu/interrupts_64.c:28:26: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
Disable it for clang, as Linux does.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
scripts/Makefile.warn | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
index 393f7fd522c8..237597d18af4 100644
--- a/scripts/Makefile.warn
+++ b/scripts/Makefile.warn
@@ -47,6 +47,9 @@ KBUILD_CFLAGS += -Wno-pointer-sign
# them when -Wall is passed later on the command line, so the -Wno... options
# must come after -Wall
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+ifdef CONFIG_CC_IS_CLANG
+KBUILD_CFLAGS += -Wno-initializer-overrides
+endif
#
# W=e and CONFIG_WERROR - error out on warnings
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] ARM64: cache: use WEAK() for v8_flush_l3_cache stub
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
` (3 preceding siblings ...)
2026-09-04 7:59 ` [PATCH 4/5] kbuild: disable -Winitializer-overrides for clang Ahmad Fatoum
@ 2026-09-04 7:59 ` Ahmad Fatoum
2026-09-04 9:44 ` [PATCH 0/5] clang: more warning and error fixes Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Ahmad Fatoum @ 2026-09-04 7:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
From: Ahmad Fatoum <a.fatoum@barebox.org>
clang's integrated assembler warns when a symbol is made weak after
being defined global:
warning: v8_flush_l3_cache changed binding to STB_WEAK
Use WEAK() from linkage.h, which emits .weak before the label.
Assisted-by: Claude:fable-5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/cpu/cache-armv8.S | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/arm/cpu/cache-armv8.S b/arch/arm/cpu/cache-armv8.S
index e6f50886f924..b381da5e34d0 100644
--- a/arch/arm/cpu/cache-armv8.S
+++ b/arch/arm/cpu/cache-armv8.S
@@ -229,8 +229,7 @@ ENTRY(v8_invalidate_icache_all)
ENDPROC(v8_invalidate_icache_all)
.section .text.v8_flush_l3_cache
-ENTRY(v8_flush_l3_cache)
+WEAK(v8_flush_l3_cache)
mov x0, #0 /* return status as success */
ret
ENDPROC(v8_flush_l3_cache)
- .weak v8_flush_l3_cache
--
2.47.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/5] clang: more warning and error fixes
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
` (4 preceding siblings ...)
2026-09-04 7:59 ` [PATCH 5/5] ARM64: cache: use WEAK() for v8_flush_l3_cache stub Ahmad Fatoum
@ 2026-09-04 9:44 ` Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2026-09-04 9:44 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Fri, 04 Sep 2026 09:59:12 +0200, Ahmad Fatoum wrote:
> In preparation for making bare metal targets also compile with clang,
> here are some more warning and error fixes for both assembler and compiler.
>
> Ahmad Fatoum (5):
> kbuild: emit asm-offsets markers as .ascii strings
> scripts: imx9image: fix warnings reported by clang
> kbuild: disable -Wunused-but-set-variable after -Wall
> kbuild: disable -Winitializer-overrides for clang
> ARM64: cache: use WEAK() for v8_flush_l3_cache stub
>
> [...]
Applied, thanks!
[1/5] kbuild: emit asm-offsets markers as .ascii strings
https://git.pengutronix.de/cgit/barebox/commit/?id=d0be5d7ff7d9 (link may not be stable)
[2/5] scripts: imx9image: fix warnings reported by clang
https://git.pengutronix.de/cgit/barebox/commit/?id=0ed92a5f4ca1 (link may not be stable)
[3/5] kbuild: disable -Wunused-but-set-variable after -Wall
https://git.pengutronix.de/cgit/barebox/commit/?id=52d6a7a60bae (link may not be stable)
[4/5] kbuild: disable -Winitializer-overrides for clang
https://git.pengutronix.de/cgit/barebox/commit/?id=9c787cdf53df (link may not be stable)
[5/5] ARM64: cache: use WEAK() for v8_flush_l3_cache stub
https://git.pengutronix.de/cgit/barebox/commit/?id=69b498bb79a5 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-04 9:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04 7:59 [PATCH 0/5] clang: more warning and error fixes Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 1/5] kbuild: emit asm-offsets markers as .ascii strings Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 2/5] scripts: imx9image: fix warnings reported by clang Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 3/5] kbuild: disable -Wunused-but-set-variable after -Wall Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 4/5] kbuild: disable -Winitializer-overrides for clang Ahmad Fatoum
2026-09-04 7:59 ` [PATCH 5/5] ARM64: cache: use WEAK() for v8_flush_l3_cache stub Ahmad Fatoum
2026-09-04 9:44 ` [PATCH 0/5] clang: more warning and error fixes Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox