[PATCH] kbuild: undefine linux/unix macros
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Mar 27 06:24:22 PDT 2025
Hi,
On 3/27/25 14:20, Bastian Krause wrote:
> gcc and clang, when using `-std=gnu11`, predefine `linux` and `unix` as
> macros:
>
> $ gcc -std=gnu11 -dM -E - < /dev/null | grep -v "define _"
> #define unix 1
> #define linux 1
>
> This causes issues in `BAREBOX_MAGICVAR()`, where variable names
> containing "linux" or "unix" get incorrectly expanded, leading to invalid
> names:
>
> barebox at Sandbox:/ magicvar
> [...]
> global.1.blkdevparts.* Linux blkdevparts variables
> global.1.bootargs.* Linux bootargs variables
> global.1.bootargs.console console= argument for Linux from the stdout-path property in /chosen node
> global.1.bootargs_append append to original oftree bootargs
> global.1.mtdparts.* Linux mtdparts variables
> [...]
>
> Explicitly undefine these non-conforming macros to ensure correct
> behavior.
>
> Signed-off-by: Bastian Krause <bst at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
Thanks,
Ahmad
> ---
> Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 5c9fce83123..ff7179bf9d5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -486,7 +486,8 @@ LINUXINCLUDE := -Iinclude \
> -I$(objtree)/arch/$(SRCARCH)/include \
> $(USERINCLUDE)
>
> -KBUILD_CPPFLAGS := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
> +KBUILD_CPPFLAGS := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) \
> + -fno-builtin -ffreestanding -Ulinux -Uunix
>
> KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
> -fno-strict-aliasing -fno-common -fshort-wchar \
More information about the barebox
mailing list