diff mbox series

Don't include config.h when building helpers using the native compiler

Message ID 20200622052513.1850288-1-fontaine.fabrice@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show
Series Don't include config.h when building helpers using the native compiler | expand

Commit Message

Fabrice Fontaine June 22, 2020, 5:25 a.m. UTC
config.h contains settings for the cross compiler (most importantly
32/64bit versions of functions), so don't include it when calling the
native compiler to build the helpers.

Otherwise we get build errors like:

/usr/bin/gcc -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN  -g -O2 -Wall    -o mkinit mkinit.c
In file included from /usr/include/sys/stat.h:107,
                 from /usr/include/fcntl.h:38,
                 from mkinit.c:50:
/usr/include/bits/stat.h:117: error: redefinition of ‘struct stat’
In file included from /usr/include/fcntl.h:38,
                 from mkinit.c:50:
/usr/include/sys/stat.h:504: error: redefinition of ‘stat’
/usr/include/sys/stat.h:455: note: previous definition of ‘stat’ was here

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
[Retrieved from:
https://git.buildroot.net/buildroot/tree/package/dash/0001-no-config.h-for-helpers.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 src/Makefile.am | 1 -
 1 file changed, 1 deletion(-)

Comments

Herbert Xu June 22, 2020, 7:42 a.m. UTC | #1
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:
> config.h contains settings for the cross compiler (most importantly
> 32/64bit versions of functions), so don't include it when calling the
> native compiler to build the helpers.
> 
> Otherwise we get build errors like:
> 
> /usr/bin/gcc -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN  -g -O2 -Wall    -o mkinit mkinit.c
> In file included from /usr/include/sys/stat.h:107,
>                 from /usr/include/fcntl.h:38,
>                 from mkinit.c:50:
> /usr/include/bits/stat.h:117: error: redefinition of ‘struct stat’
> In file included from /usr/include/fcntl.h:38,
>                 from mkinit.c:50:
> /usr/include/sys/stat.h:504: error: redefinition of ‘stat’
> /usr/include/sys/stat.h:455: note: previous definition of ‘stat’ was here
> 
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> [Retrieved from:
> https://git.buildroot.net/buildroot/tree/package/dash/0001-no-config.h-for-helpers.patch]
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> ---
> src/Makefile.am | 1 -
> 1 file changed, 1 deletion(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 1732465..3b1b54e 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -7,7 +7,6 @@ COMMON_CPPFLAGS = \
> AM_CFLAGS = $(COMMON_CFLAGS)
> AM_CPPFLAGS = -include $(top_builddir)/config.h $(COMMON_CPPFLAGS)
> AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) 
> -AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS)

Hmm, why is config.h ending up in COMMON_CPPFLAGS at all?

I don't see in my build:

$ make V=1 -C build
...
gcc -I. -I../../src -I.. -DBSD=1 -DSHELL  -g -O2 -Wall    -o mkinit ../../src/mkinit.c
./mkinit ../../src/alias.c ../../src/arith_yacc.c ../../src/arith_yylex.c ../../src/cd.c ../../src/error.c ../../src/eval.c ../../src/exec.c ../../src/expand.c ../../src/histedit.c ../../src/input.c ../../src/jobs.c ../../src/mail.c ../../src/main.c ../../src/memalloc.c ../../src/miscbltin.c ../../src/mystring.c ../../src/options.c ../../src/parser.c ../../src/redir.c ../../src/show.c ../../src/trap.c ../../src/output.c ../../src/bltin/printf.c ../../src/system.c ../../src/bltin/test.c ../../src/bltin/times.c ../../src/var.c

I'm not cross-compiling though.

Cheers,
Harald van Dijk June 22, 2020, 8:53 a.m. UTC | #2
On 22/06/2020 06:25, Fabrice Fontaine wrote:
> config.h contains settings for the cross compiler (most importantly
> 32/64bit versions of functions), so don't include it when calling the
> native compiler to build the helpers.
> 
> Otherwise we get build errors like:
> 
> /usr/bin/gcc -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN  -g -O2 -Wall    -o mkinit mkinit.c
> In file included from /usr/include/sys/stat.h:107,
>                   from /usr/include/fcntl.h:38,
>                   from mkinit.c:50:
> /usr/include/bits/stat.h:117: error: redefinition of ‘struct stat’
> In file included from /usr/include/fcntl.h:38,
>                   from mkinit.c:50:
> /usr/include/sys/stat.h:504: error: redefinition of ‘stat’
> /usr/include/sys/stat.h:455: note: previous definition of ‘stat’ was here
> 
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> [Retrieved from:
> https://git.buildroot.net/buildroot/tree/package/dash/0001-no-config.h-for-helpers.patch]
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

A better version of this patch has already been submitted and accepted 
in 2018: <https://www.spinics.net/lists/dash/msg01629.html>.

Cheers,
Harald van Dijk
Fabrice Fontaine June 22, 2020, 10:44 a.m. UTC | #3
Dear all,

Le lun. 22 juin 2020 à 10:53, Harald van Dijk <harald@gigawatt.nl> a écrit :
>
> On 22/06/2020 06:25, Fabrice Fontaine wrote:
> > config.h contains settings for the cross compiler (most importantly
> > 32/64bit versions of functions), so don't include it when calling the
> > native compiler to build the helpers.
> >
> > Otherwise we get build errors like:
> >
> > /usr/bin/gcc -include ../config.h -DBSD=1 -DSHELL -DIFS_BROKEN  -g -O2 -Wall    -o mkinit mkinit.c
> > In file included from /usr/include/sys/stat.h:107,
> >                   from /usr/include/fcntl.h:38,
> >                   from mkinit.c:50:
> > /usr/include/bits/stat.h:117: error: redefinition of ‘struct stat’
> > In file included from /usr/include/fcntl.h:38,
> >                   from mkinit.c:50:
> > /usr/include/sys/stat.h:504: error: redefinition of ‘stat’
> > /usr/include/sys/stat.h:455: note: previous definition of ‘stat’ was here
> >
> > Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> > [Retrieved from:
> > https://git.buildroot.net/buildroot/tree/package/dash/0001-no-config.h-for-helpers.patch]
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
>
> A better version of this patch has already been submitted and accepted
> in 2018: <https://www.spinics.net/lists/dash/msg01629.html>.
Thanks and sorry for the noise, I'll then remove this patch from my
buildroot as we have just bumped to 0.5.11.
>
> Cheers,
> Harald van Dijk
Best Regards,

Fabrice
diff mbox series

Patch

diff --git a/src/Makefile.am b/src/Makefile.am
index 1732465..3b1b54e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,6 @@  COMMON_CPPFLAGS = \
 AM_CFLAGS = $(COMMON_CFLAGS)
 AM_CPPFLAGS = -include $(top_builddir)/config.h $(COMMON_CPPFLAGS)
 AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) 
-AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS)
 
 COMPILE_FOR_BUILD = \
 	$(CC_FOR_BUILD) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS_FOR_BUILD) \