Re: [PATCH v1] env: Fix compile error for envtools

Tom Rini <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <20260825183422.GZ523975@bill-the-cat>
On Tue, Aug 25, 2026 at 12:21:01PM -0600, Simon Glass wrote:
> Hi Jacky,
> 
> On 2026-07-13T08:31:41, [email protected] <[email protected]> wrote:
> > env: Fix compile error for envtools
> >
> > Following error happens when build envtools for mx6qsabrelite.
> >
> > $ make tools envtools
> >   UPD     include/generated/timestamp_autogenerated.h
> >   HOSTCC  tools/printinitialenv
> >   GENENV  u-boot-initial-env
> >   COPY    tools/version.h
> >   HOSTCC  tools/env/crc32.o
> >   HOSTCC  tools/env/ctype.o
> >   HOSTCC  tools/env/env_attr.o
> >   HOSTCC  tools/env/env_flags.o
> > In file included from ./arch/arm/include/asm/mach-imx/regs-lcdif.h:16,
> >                  from ./arch/arm/include/asm/arch/imx-regs.h:371,
> >                  from include/configs/mx6_common.h:21,
> >                  from include/configs/nitrogen6x.h:13,
> >                  from include/config.h:3,
> >                  from include/env.h:12,
> >                  from tools/env/../../env/flags.c:7,
> >                  from tools/env/env_flags.c:1:
> > ./arch/arm/include/asm/mach-imx/regs-common.h:51:9: error: unknown type name 'uint8_t'
> >    51 |         __mxs_reg_8(reg)
> >       |         ^~~~~~~~~~~
> >
> > uint8_t type is defined in linux/types.h header file.
> > The config.h includes regs-common.h that uses uint8_t type,
> > to fix this, include config.h after linux/types.h in env.h file.
> >
> > Fixes: 9f1807e57cbb ("env: add env_set_runtime() helper")
> 
> env.h only needs <config.h> so that IS_ENABLED() works inside the
> inline env_set_runtime() helper. A cleaner fix is to make
> env_set_runtime() a normal (non-inline) function declared in env.h and
> defined in env/common.c (or wherever env_set() lives). Then env.h no
> longer needs <config.h> and the tools build stops dragging board
> configs into the host-side compilation. What do you think?

Just using a normal #if/#else/#endif would be the better fix here.

> > [...]
> >
> > include/env.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> > diff --git a/include/env.h b/include/env.h
> > @@ -9,10 +9,10 @@
> >  #ifndef __ENV_H
> >  #define __ENV_H
> >
> > -#include <config.h>
> >  #include <compiler.h>
> >  #include <stdbool.h>
> >  #include <linux/types.h>
> > +#include <config.h>
> 
> As Tom mentioned, we really don't want to move config.h later - even
> though the files above it are probably unrelated in this case...

It's not "don't want", it's "cannot". You cannot have it be anywhere
other than the first line or you will introduce other obscure problems.

-- 
Tom
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQTzzqh0PWDgGS+bTHor4qD1Cr/kCgUCao3gLgAKCRAr4qD1Cr/k
ClpHAQCPJcfasayPBoc+ChjNLf7MqSK90ws9hsY/rLtXfJPtxgD+Kx4L8kdagsTp
2eC+Fml8SkVnv8Did98arMnCd3bw7wE=
=iV2U
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.