diff mbox series

[3/9] scripts: Makefile.lib: Pass __UBOOT__ to DTC's CPP

Message ID 20220316153948.197650-3-ptosi@google.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [1/9] net: gmac_rockchip: Fix misuse of GENMASK macro | expand

Commit Message

Pierre-Clément Tosi March 16, 2022, 3:39 p.m. UTC
Some headers included (possibly indirectly) from .dts files might have
U-Boot specific content relying on the __UBOOT__ macro passed to CPP
when building C code. In that case, it would be sensible for DTC to see
that content instead of the non-U-Boot one. To do so, pass the macro to
the pre-processor when generate DTC inputs.

Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Cc: Simon Glass <sjg@chromium.org>
---
 scripts/Makefile.lib | 1 +
 1 file changed, 1 insertion(+)

Comments

Simon Glass March 16, 2022, 7:23 p.m. UTC | #1
Hi Pierre-Clément,

On Wed, 16 Mar 2022 at 09:40, Pierre-Clément Tosi <ptosi@google.com> wrote:
>
> Some headers included (possibly indirectly) from .dts files might have
> U-Boot specific content relying on the __UBOOT__ macro passed to CPP
> when building C code. In that case, it would be sensible for DTC to see
> that content instead of the non-U-Boot one. To do so, pass the macro to
> the pre-processor when generate DTC inputs.

Can you give an example of such a situation?

>
> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  scripts/Makefile.lib | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass <sjg@chromium.org>


>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index c14da10de7..d7b548dce8 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -192,6 +192,7 @@ dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
>                  -I$(srctree)/arch/$(ARCH)/include                       \
>                  -include $(srctree)/include/linux/kconfig.h             \
>                  -D__ASSEMBLY__                                          \
> +                -D__UBOOT__                                             \
>                  -undef -D__DTS__
>
>  # Finds the multi-part object the current object will be linked into
> --
> 2.35.1.723.g4982287a31-goog
>
Pierre-Clément Tosi March 17, 2022, 10:42 a.m. UTC | #2
On Wed, Mar 16, 2022 at 01:23:43PM -0600, Simon Glass wrote:
> Hi Pierre-Clément,
> 
> On Wed, 16 Mar 2022 at 09:40, Pierre-Clément Tosi <ptosi@google.com> wrote:
> >
> > Some headers included (possibly indirectly) from .dts files might have
> > U-Boot specific content relying on the __UBOOT__ macro passed to CPP
> > when building C code. In that case, it would be sensible for DTC to see
> > that content instead of the non-U-Boot one. To do so, pass the macro to
> > the pre-processor when generate DTC inputs.
> 
> Can you give an example of such a situation?

This patch isn't fixing an existing issue. Instead, it preempts one that
following patches, adding "#ifndef __UBOOT__/{code not supported in U-Boot}" in
Linux headers, would bring. But IMO (and IIUC), it makes sense on its own given
the meaning that CPP macro has in C code and how it's systematically set through
KBUILD_CPPFLAGS.

> 
> >
> > Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
> > Cc: Simon Glass <sjg@chromium.org>
> > ---
> >  scripts/Makefile.lib | 1 +
> >  1 file changed, 1 insertion(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> 
> >
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index c14da10de7..d7b548dce8 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -192,6 +192,7 @@ dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
> >                  -I$(srctree)/arch/$(ARCH)/include                       \
> >                  -include $(srctree)/include/linux/kconfig.h             \
> >                  -D__ASSEMBLY__                                          \
> > +                -D__UBOOT__                                             \
> >                  -undef -D__DTS__
> >
> >  # Finds the multi-part object the current object will be linked into
> > --
> > 2.35.1.723.g4982287a31-goog
> >
diff mbox series

Patch

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index c14da10de7..d7b548dce8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -192,6 +192,7 @@  dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
 		 -I$(srctree)/arch/$(ARCH)/include                       \
 		 -include $(srctree)/include/linux/kconfig.h             \
 		 -D__ASSEMBLY__                                          \
+		 -D__UBOOT__                                             \
 		 -undef -D__DTS__
 
 # Finds the multi-part object the current object will be linked into