Message ID | 20180523062003.GH2816@rink.nu (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Herbert Xu |
Headers | show |
Hi Rink, On Wed, May 23, 2018 at 08:20:03AM +0200, Rink Springer wrote: > On Tue, May 22, 2018 at 06:57:07PM +0300, Baruch Siach wrote: > > From: Peter Korsgaard <peter@korsgaard.com> > > > > 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 <peter@korsgaard.com> > > [baruch: apply to Makefile.am; update Peter's email address] > > Signed-off-by: Baruch Siach <baruch@tkos.co.il> > > --- > > src/Makefile.am | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/src/Makefile.am b/src/Makefile.am > > index 139355e5b7e9..55780f4689da 100644 > > --- a/src/Makefile.am > > +++ b/src/Makefile.am > > @@ -2,12 +2,11 @@ AM_YFLAGS = -d > > > > COMMON_CFLAGS = -Wall > > COMMON_CPPFLAGS = \ > > - -include $(top_builddir)/config.h \ > > -DBSD=1 -DSHELL \ > > -DIFS_BROKEN > > > > AM_CFLAGS = $(COMMON_CFLAGS) > > -AM_CPPFLAGS = $(COMMON_CPPFLAGS) > > +AM_CPPFLAGS = -include $(top_builddir)/config.h $(COMMON_CPPFLAGS) > > AM_CFLAGS_FOR_BUILD = -g -O2 $(COMMON_CFLAGS) > > AM_CPPFLAGS_FOR_BUILD = $(COMMON_CPPFLAGS) > > I seem to recall that I encountered the same problem when cross-building > dash; however, I fixed it in a different way: > > diff --git a/src/Makefile.am b/src/Makefile.am > index 139355e..ed18844 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -12,7 +12,7 @@ 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) \ > + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) \ > $(CPPFLAGS_FOR_BUILD) \ > $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) > > I am unsure what is the best solution here. This removes the only reference to AM_CPPFLAGS_FOR_BUILD, so you can remove it entirely. Also, the intermediate COMMON_CPPFLAGS would only used once to initialize AM_CPPFLAGS, so you can remove that one as well. baruch
diff --git a/src/Makefile.am b/src/Makefile.am index 139355e..ed18844 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,7 +12,7 @@ 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) \ + $(CC_FOR_BUILD) $(DEFAULT_INCLUDES) \ $(CPPFLAGS_FOR_BUILD) \ $(AM_CFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)