diff mbox

Fix genmatch linking

Message ID alpine.LSU.2.11.1410231046100.9891@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 23, 2014, 8:47 a.m. UTC
This adds a libcpp host module without NLS and ICONV support
and properly links genmatch against the build libcpp instead of
the host one.

Bootstrap running on x86_64-unknown-linux-gnu (stage1 all-gcc
finished fine).

Ok for trunk?

Thanks,
Richard.

2014-10-23  Richard Biener  <rguenther@suse.de>

	* Makefile.def: Add libcpp build module and dependencies.
	* configure.ac: Add libcpp build module.
	* Makefile.in: Regenerate.
	* configure: Likewise.

	gcc/
	* Makefile.in (BUILD_CPPLIB): Add.
	(build/genmatch$(build_exeext)): Use BUILD_CPPLIB, not CPPLIB.
	Drop LIBIBERTY.

Comments

Jakub Jelinek Oct. 23, 2014, 9:01 a.m. UTC | #1
On Thu, Oct 23, 2014 at 10:47:43AM +0200, Richard Biener wrote:
> 
> This adds a libcpp host module without NLS and ICONV support
> and properly links genmatch against the build libcpp instead of
> the host one.
> 
> Bootstrap running on x86_64-unknown-linux-gnu (stage1 all-gcc
> finished fine).
> 
> Ok for trunk?

Ok, thanks.

> 2014-10-23  Richard Biener  <rguenther@suse.de>
> 
> 	* Makefile.def: Add libcpp build module and dependencies.
> 	* configure.ac: Add libcpp build module.
> 	* Makefile.in: Regenerate.
> 	* configure: Likewise.
> 
> 	gcc/
> 	* Makefile.in (BUILD_CPPLIB): Add.
> 	(build/genmatch$(build_exeext)): Use BUILD_CPPLIB, not CPPLIB.
> 	Drop LIBIBERTY.

	Jakub
Richard Sandiford Oct. 23, 2014, 9:26 p.m. UTC | #2
Richard Biener <rguenther@suse.de> writes:
> This adds a libcpp host module without NLS and ICONV support
> and properly links genmatch against the build libcpp instead of
> the host one.
>
> Bootstrap running on x86_64-unknown-linux-gnu (stage1 all-gcc
> finished fine).
>
> Ok for trunk?
>
> Thanks,
> Richard.
>
> 2014-10-23  Richard Biener  <rguenther@suse.de>
>
> 	* Makefile.def: Add libcpp build module and dependencies.
> 	* configure.ac: Add libcpp build module.
> 	* Makefile.in: Regenerate.
> 	* configure: Likewise.
>
> 	gcc/
> 	* Makefile.in (BUILD_CPPLIB): Add.
> 	(build/genmatch$(build_exeext)): Use BUILD_CPPLIB, not CPPLIB.
> 	Drop LIBIBERTY.

This breaks a -j1 (!) build on x86_64-linux-gnu for me with:

g++  -I/blah/libcpp -I. -I/blah/libcpp/../include -I/blah/libcpp/include  -g -O2 -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -pedantic -Wno-long-long  -fno-exceptions -fno-rtti -I/blah/libcpp -I. -I/blah/libcpp/../include -I/blah/libcpp/include   -c -o charset.o -MT charset.o -MMD -MP -MF .deps/charset.Tpo /blah/libcpp/charset.c
In file included from /blah/libcpp/../include/hashtab.h:40:0,
                 from /blah/libcpp/../include/filenames.h:29,
                 from /blah/libcpp/system.h:367,
                 from /blah/libcpp/charset.c:21:
/blah/libcpp/../include/ansidecl.h:171:64: error: new declaration ‘char* basename(const char*)’
 #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
                                                                ^
/blah/libcpp/../include/libiberty.h:113:64: note: in expansion of macro ‘ATTRIBUTE_NONNULL’
 extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
                                                                ^
In file included from /blah/libcpp/system.h:201:0,
                 from /blah/libcpp/charset.c:21:
/usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’
 extern "C++" const char *basename (const char *__filename)
                          ^
make: *** [charset.o] Error 1

The build libiberty and libcpp share a config.cache file and both check
for basename.  The problem is that libiberty is built without _GNU_SOURCE
and doesn't see the declaration while libcpp is built with it and does
see the declaration.  So if libiberty configures first we assume basename
isn't available.  If they both configure at the same time we're OK.

Thanks,
Richard
Richard Biener Oct. 24, 2014, 7:52 a.m. UTC | #3
On Thu, 23 Oct 2014, Richard Sandiford wrote:

> Richard Biener <rguenther@suse.de> writes:
> > This adds a libcpp host module without NLS and ICONV support
> > and properly links genmatch against the build libcpp instead of
> > the host one.
> >
> > Bootstrap running on x86_64-unknown-linux-gnu (stage1 all-gcc
> > finished fine).
> >
> > Ok for trunk?
> >
> > Thanks,
> > Richard.
> >
> > 2014-10-23  Richard Biener  <rguenther@suse.de>
> >
> > 	* Makefile.def: Add libcpp build module and dependencies.
> > 	* configure.ac: Add libcpp build module.
> > 	* Makefile.in: Regenerate.
> > 	* configure: Likewise.
> >
> > 	gcc/
> > 	* Makefile.in (BUILD_CPPLIB): Add.
> > 	(build/genmatch$(build_exeext)): Use BUILD_CPPLIB, not CPPLIB.
> > 	Drop LIBIBERTY.
> 
> This breaks a -j1 (!) build on x86_64-linux-gnu for me with:
> 
> g++  -I/blah/libcpp -I. -I/blah/libcpp/../include -I/blah/libcpp/include  -g -O2 -W -Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -pedantic -Wno-long-long  -fno-exceptions -fno-rtti -I/blah/libcpp -I. -I/blah/libcpp/../include -I/blah/libcpp/include   -c -o charset.o -MT charset.o -MMD -MP -MF .deps/charset.Tpo /blah/libcpp/charset.c
> In file included from /blah/libcpp/../include/hashtab.h:40:0,
>                  from /blah/libcpp/../include/filenames.h:29,
>                  from /blah/libcpp/system.h:367,
>                  from /blah/libcpp/charset.c:21:
> /blah/libcpp/../include/ansidecl.h:171:64: error: new declaration ‘char* basename(const char*)’
>  #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
>                                                                 ^
> /blah/libcpp/../include/libiberty.h:113:64: note: in expansion of macro ‘ATTRIBUTE_NONNULL’
>  extern char *basename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_NONNULL(1);
>                                                                 ^
> In file included from /blah/libcpp/system.h:201:0,
>                  from /blah/libcpp/charset.c:21:
> /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’
>  extern "C++" const char *basename (const char *__filename)
>                           ^
> make: *** [charset.o] Error 1
> 
> The build libiberty and libcpp share a config.cache file and both check

Ugh - why do they do this kind of thing?  Btw, I can't decipher
where or how it's doing that.

> for basename.  The problem is that libiberty is built without _GNU_SOURCE
> and doesn't see the declaration while libcpp is built with it and does
> see the declaration.  So if libiberty configures first we assume basename
> isn't available.  If they both configure at the same time we're OK.

Bah.  Where does the _GNU_SOURCE come from?  Is it libcpp being built
with C++ and libiberty build with C?

I think the solution is to force a separate config.cache for libcpp.
But as I didn't yet figure out how it ends up sharing config.cache
I didn't figure out how to disable that sharing...

Thanks,
Richard.

> Thanks,
> Richard
> 
>
diff mbox

Patch

Index: Makefile.def
===================================================================
--- Makefile.def	(revision 216543)
+++ Makefile.def	(working copy)
@@ -30,6 +30,8 @@  build_modules= { module= flex; };
 build_modules= { module= m4; };
 build_modules= { module= texinfo; };
 build_modules= { module= fixincludes; };
+build_modules= { module= libcpp;
+                 extra_configure_flags='--disable-nls am_cv_func_iconv=no';};
 
 host_modules= { module= bfd; bootstrap=true; };
 host_modules= { module= opcodes; bootstrap=true; };
@@ -301,6 +303,7 @@  dependencies = { module=all-build-flex;
 dependencies = { module=all-build-libiberty; on=all-build-texinfo; };
 dependencies = { module=all-build-m4; on=all-build-texinfo; };
 dependencies = { module=all-build-fixincludes; on=all-build-libiberty; };
+dependencies = { module=all-build-libcpp; on=all-build-libiberty; };
 
 // Host modules specific to gcc.
 dependencies = { module=configure-gcc; on=configure-intl; };
@@ -321,6 +324,7 @@  dependencies = { module=all-gcc; on=all-
 dependencies = { module=all-gcc; on=all-build-flex; };
 dependencies = { module=all-gcc; on=all-build-libiberty; };
 dependencies = { module=all-gcc; on=all-build-fixincludes; };
+dependencies = { module=all-gcc; on=all-build-libcpp; };
 dependencies = { module=all-gcc; on=all-zlib; };
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
Index: configure.ac
===================================================================
--- configure.ac	(revision 216543)
+++ configure.ac	(working copy)
@@ -126,7 +126,7 @@  extra_host_args=
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty"
+build_libs="build-libiberty build-libcpp"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 216543)
+++ gcc/Makefile.in	(working copy)
@@ -981,6 +981,7 @@  else
 LIBIBERTY = ../libiberty/libiberty.a
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
+BUILD_CPPLIB = $(build_libobjdir)/libcpp/libcpp.a
 
 # Dependencies on the intl and portability libraries.
 LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
@@ -2520,7 +2521,7 @@  genprog = $(genprogerr) check checksum c
 # These programs need libs over and above what they get from the above list.
 build/genautomata$(build_exeext) : BUILD_LIBS += -lm
 
-build/genmatch$(build_exeext) : $(CPPLIB) $(LIBIBERTY) \
+build/genmatch$(build_exeext) : $(BUILD_CPPLIB) \
   $(BUILD_ERRORS) build/vec.o build/hash-table.o
 
 # These programs are not linked with the MD reader.
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 216543)
+++ Makefile.in	(working copy)
@@ -991,6 +991,7 @@  all-build: maybe-all-build-flex
 all-build: maybe-all-build-m4
 all-build: maybe-all-build-texinfo
 all-build: maybe-all-build-fixincludes
+all-build: maybe-all-build-libcpp
 
 .PHONY: all-host
 
@@ -3005,6 +3006,63 @@  all-build-fixincludes: configure-build-f
 
 
 
+.PHONY: configure-build-libcpp maybe-configure-build-libcpp
+maybe-configure-build-libcpp:
+@if gcc-bootstrap
+configure-build-libcpp: stage_current
+@endif gcc-bootstrap
+@if build-libcpp
+maybe-configure-build-libcpp: configure-build-libcpp
+configure-build-libcpp: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	test ! -f $(BUILD_SUBDIR)/libcpp/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(BUILD_SUBDIR)/libcpp ; \
+	$(BUILD_EXPORTS)  \
+	echo Configuring in $(BUILD_SUBDIR)/libcpp; \
+	cd "$(BUILD_SUBDIR)/libcpp" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(BUILD_SUBDIR)/libcpp/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	module_srcdir=libcpp; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) \
+	  $$s/$$module_srcdir/configure \
+	  --srcdir=$${topdir}/$$module_srcdir \
+	  $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \
+	  --target=${target_alias} --disable-nls am_cv_func_iconv=no \
+	  || exit 1
+@endif build-libcpp
+
+
+
+
+
+.PHONY: all-build-libcpp maybe-all-build-libcpp
+maybe-all-build-libcpp:
+@if gcc-bootstrap
+all-build-libcpp: stage_current
+@endif gcc-bootstrap
+@if build-libcpp
+TARGET-build-libcpp=all
+maybe-all-build-libcpp: all-build-libcpp
+all-build-libcpp: configure-build-libcpp
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(BUILD_EXPORTS)  \
+	(cd $(BUILD_SUBDIR)/libcpp && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
+		$(TARGET-build-libcpp))
+@endif build-libcpp
+
+
+
+
+
 # --------------------------------------
 # Modules which run on the host machine
 # --------------------------------------
@@ -48047,6 +48105,7 @@  all-build-flex: maybe-all-build-m4
 all-build-libiberty: maybe-all-build-texinfo
 all-build-m4: maybe-all-build-texinfo
 all-build-fixincludes: maybe-all-build-libiberty
+all-build-libcpp: maybe-all-build-libiberty
 configure-gcc: maybe-configure-intl
 
 configure-stage1-gcc: maybe-configure-stage1-intl
@@ -48191,6 +48250,14 @@  all-stage3-gcc: maybe-all-build-fixinclu
 all-stage4-gcc: maybe-all-build-fixincludes
 all-stageprofile-gcc: maybe-all-build-fixincludes
 all-stagefeedback-gcc: maybe-all-build-fixincludes
+all-gcc: maybe-all-build-libcpp
+
+all-stage1-gcc: maybe-all-build-libcpp
+all-stage2-gcc: maybe-all-build-libcpp
+all-stage3-gcc: maybe-all-build-libcpp
+all-stage4-gcc: maybe-all-build-libcpp
+all-stageprofile-gcc: maybe-all-build-libcpp
+all-stagefeedback-gcc: maybe-all-build-libcpp
 all-gcc: maybe-all-zlib
 
 all-stage1-gcc: maybe-all-stage1-zlib
Index: configure
===================================================================
--- configure	(revision 216543)
+++ configure	(working copy)
@@ -2713,7 +2713,7 @@  extra_host_args=
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty"
+build_libs="build-libiberty build-libcpp"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"