mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Bastian Krause <bst@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH] kbuild: undefine linux/unix macros
Date: Thu, 27 Mar 2025 14:24:22 +0100	[thread overview]
Message-ID: <deb2ab3f-1a24-4af3-bfea-878ecd9f545f@pengutronix.de> (raw)
In-Reply-To: <20250327132052.3187117-1-bst@pengutronix.de>

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@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@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@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 \




  reply	other threads:[~2025-03-27 13:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27 13:20 Bastian Krause
2025-03-27 13:24 ` Ahmad Fatoum [this message]
2025-03-31  7:11 ` Sascha Hauer

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=deb2ab3f-1a24-4af3-bfea-878ecd9f545f@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=bst@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox