public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH build/doc] Replacing libiberty with gnulib
@ 2016-08-15 12:51 ayush goel
  2016-08-15 14:26 ` Manuel López-Ibáñez
  2016-08-16 16:54 ` Pedro Alves
  0 siblings, 2 replies; 33+ messages in thread
From: ayush goel @ 2016-08-15 12:51 UTC (permalink / raw)
  To: Joseph Myers, Pedro Alves, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 6166 bytes --]

Included gnulib’s config.h header file inside gcc’s config.h itself as
per the discussions.

Built and tested the system.

PFA the patch



2016-08-14 Ayush Goel <ayushgoel1610@gmail.com>

* Makefile.def: Added gnulib as build & host library and dependency of
all-gcc on gnulib
* Makefile.in: regenerated
* configure.ac: Added gnulib as build and host library
* configure: regenerated
* gcc/Makefile.in: Added path to gnulib static library (libgnu.a) and
gnulib header files
* gcc/mkconfig.sh: Included gnulib’s config.h
* gcc/doc/sourcebuild.texi: Added gnulib and how to use the update
script to update/import gnu lib modules
* gnulib: created directory
* gnulib/Makefile.in: new file
* gnulib/configure.ac: new file
* gnulib/update-gnulib.sh: script to import gnulib modules using gnulib-tool
* gnulib/import: created by update-gnulib.sh
* gnulib/import/Makefile.in: imported from gnulib
* gnulib/import/alignof.h: Imported from gnulib
* gnulib/import/exitfail.c: Imported from gnulib
* gnulib/import/exitfail.h: Imported from gnulib
* gnulib/import/extra: Imported from gnulib
* gnulib/import/extra/snippet: Imported from gnulib
* gnulib/import/extra/snippet/_Noreturn.h: Imported from gnulib
* gnulib/import/extra/snippet/arg-nonnull.h: Imported from gnulib
* gnulib/import/extra/snippet/c++defs.h: Imported from gnulib
* gnulib/import/extra/snippet/warn-on-use.h: Imported from gnulib
* gnulib/import/gettext.h: Imported from gnulib
* gnulib/import/m4: Imported from gnulib
* gnulib/import/m4/00gnulib.m4: Imported from gnulib
* gnulib/import/m4/absolute-header.m4: Imported from gnulib
* gnulib/import/m4/extern-inline.m4: Imported from gnulib
* gnulib/import/m4/gnulib-cache.m4: Imported from gnulib
* gnulib/import/m4/gnulib-common.m4: Imported from gnulib
* gnulib/import/m4/gnulib-comp.m4: Imported from gnulib
* gnulib/import/m4/gnulib-tool.m4: Imported from gnulib
* gnulib/import/m4/include_next.m4: Imported from gnulib
* gnulib/import/m4/longlong.m4: Imported from gnulib
* gnulib/import/m4/multiarch.m4: Imported from gnulib
* gnulib/import/m4/obstack.m4: Imported from gnulib
* gnulib/import/m4/off_t.m4: Imported from gnulib
* gnulib/import/m4/ssize_t.m4: Imported from gnulib
* gnulib/import/m4/stddef_h.m4: Imported from gnulib
* gnulib/import/m4/stdint.m4: Imported from gnulib
* gnulib/import/m4/stdlib_h.m4: Imported from gnulib
* gnulib/import/m4/sys_types_h.m4: Imported from gnulib
* gnulib/import/m4/unistd_h.m4: Imported from gnulib
* gnulib/import/m4/warn-on-use.m4: Imported from gnulib
* gnulib/import/m4/wchar_t.m4: Imported from gnulib
* gnulib/import/obstack.c: Imported from gnulib
* gnulib/import/obstack.h: Imported from gnulib
* gnulib/import/stddef.in.h: Imported from gnulib
* gnulib/import/stdint.in.h: Imported from gnulib
* gnulib/import/stdlib.in.h: Imported from gnulib
* gnulib/import/sys: Imported from gnulib
* gnulib/import/sys_types.in.h: Imported from gnulib
* gnulib/import/unistd.c: Imported from gnulib
* gnulib/import/unistd.in.h: Imported from gnulib
* gnulib/stamp-h1: generated



-Ayush

On 10 August 2016 at 11:27:49 PM, Pedro Alves (palves@redhat.com) wrote:
> 20-7-16(http://airmail.calendar/2016-07-20%2012:00:00%20IST) Ayush Goel Makefile.def:
> Added gnulib as build & host library and dependency of all-gcc on gnulib * Makefile.in:
> regenerated * configure.ac: Added gnulib as build and host library * configure: regenerated
> * gcc/Makefile.in: Added path to gnulib static library (libgnu.a) and gnulib header
> files * gcc/doc/sourcebuild.texi: Added gnulib and how to use the update script to update/import
> gnu lib modules * gnulib: created directory * gnulib/Makefile.in: new file * gnulib/configure.ac:
> new file * gnulib/update-gnulib.sh: script to import gnulib modules using gnulib-tool
> * gnulib/import: created by update-gnulib.sh * gnulib/import/Makefile.in: imported
> from gnulib * gnulib/import/alignof.h: Imported from gnulib * gnulib/import/exitfail.c:
> Imported from gnulib * gnulib/import/exitfail.h: Imported from gnulib * gnulib/import/extra:
> Imported from gnulib * gnulib/import/extra/snippet: Imported from gnulib * gnulib/import/extra/snippet/_Noreturn.h:
> Imported from gnulib * gnulib/import/extra/snippet/arg-nonnull.h: Imported from
> gnulib * gnulib/import/extra/snippet/c++defs.h: Imported from gnulib * gnulib/import/extra/snippet/warn-on-use.h:
> Imported from gnulib * gnulib/import/gettext.h: Imported from gnulib * gnulib/import/m4:
> Imported from gnulib * gnulib/import/m4/00gnulib.m4: Imported from gnulib * gnulib/import/m4/absolute-header.m4:
> Imported from gnulib * gnulib/import/m4/extern-inline.m4: Imported from gnulib
> * gnulib/import/m4/gnulib-cache.m4: Imported from gnulib * gnulib/import/m4/gnulib-common.m4:
> Imported from gnulib * gnulib/import/m4/gnulib-comp.m4: Imported from gnulib * gnulib/import/m4/gnulib-tool.m4:
> Imported from gnulib * gnulib/import/m4/include_next.m4: Imported from gnulib *
> gnulib/import/m4/longlong.m4: Imported from gnulib * gnulib/import/m4/multiarch.m4:
> Imported from gnulib * gnulib/import/m4/obstack.m4: Imported from gnulib * gnulib/import/m4/off_t.m4:
> Imported from gnulib * gnulib/import/m4/ssize_t.m4: Imported from gnulib * gnulib/import/m4/stddef_h.m4:
> Imported from gnulib * gnulib/import/m4/stdint.m4: Imported from gnulib * gnulib/import/m4/stdlib_h.m4:
> Imported from gnulib * gnulib/import/m4/sys_types_h.m4: Imported from gnulib * gnulib/import/m4/unistd_h.m4:
> Imported from gnulib * gnulib/import/m4/warn-on-use.m4: Imported from gnulib * gnulib/import/m4/wchar_t.m4:
> Imported from gnulib * gnulib/import/obstack.c: Imported from gnulib * gnulib/import/obstack.h:
> Imported from gnulib * gnulib/import/stddef.in.h: Imported from gnulib * gnulib/import/stdint.in.h:
> Imported from gnulib * gnulib/import/stdlib.in.h: Imported from gnulib * gnulib/import/sys:
> Imported from gnulib * gnulib/import/sys_types.in.h: Imported from gnulib * gnulib/import/unistd.c:
> Imported from gnulib * gnulib/import/unistd.in.h: Imported from gnulib * gnulib/stamp-h1:
> generated

[-- Attachment #2: importgnulib_8_14.patch --]
[-- Type: application/octet-stream, Size: 21964 bytes --]

Index: src/Makefile.def
===================================================================
--- src/Makefile.def	(revision 237184)
+++ src/Makefile.def	(working copy)
@@ -25,6 +25,7 @@
 // that recursive target in its Makefile.
 
 build_modules= { module= libiberty; };
+build_modules= { module= gnulib; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
@@ -112,6 +113,8 @@
 host_modules= { module= zlib; no_install=true; no_check=true;
 		bootstrap=true;
 	        extra_configure_flags='@extra_host_zlib_configure_flags@';};
+host_modules= { module= gnulib;
+              bootstrap=true; };
 host_modules= { module= gdb; };
 host_modules= { module= expect; };
 host_modules= { module= guile; };
@@ -342,6 +345,8 @@
 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-gnulib; hard=true; };
+dependencies = { module=all-gcc; on=all-build-gnulib; };
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 237184)
+++ src/configure.ac	(working copy)
@@ -125,7 +125,7 @@
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty build-libcpp"
+build_libs="build-libiberty build-libcpp build-gnulib"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
@@ -132,7 +132,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv gnulib"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
Index: src/gcc/Makefile.in
===================================================================
--- src/gcc/Makefile.in	(revision 237184)
+++ src/gcc/Makefile.in	(working copy)
@@ -484,12 +484,14 @@
 
 # Where to find some libiberty headers.
 HASHTAB_H   = $(srcdir)/../include/hashtab.h
-OBSTACK_H   = $(srcdir)/../include/obstack.h
 SPLAY_TREE_H= $(srcdir)/../include/splay-tree.h
 MD5_H	    = $(srcdir)/../include/md5.h
 XREGEX_H    = $(srcdir)/../include/xregex.h
 FNMATCH_H   = $(srcdir)/../include/fnmatch.h
 
+# GNULIB headers
+OBSTACK_H   = $(srcdir)/../gnulib/import/obstack.h
+
 # Linker plugin API headers
 LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 
@@ -1022,18 +1024,23 @@
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
+# Where to find the gnulib library
+LIBGNU = ../gnulib/import/libgnu.a
+BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
+INCGNU = -I$(srcdir)/../gnulib/import
+
 # Dependencies on the intl and portability libraries.
-LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
+LIBDEPS= libcommon.a $(CPPLIB) $(LIBGNU) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
 	$(LIBDECNUMBER) $(LIBBACKTRACE)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+BUILD_LIBDEPS= $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
-	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+	$(LIBGNU) $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
 BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
@@ -1048,7 +1055,7 @@
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBS = $(BUILD_LIBIBERTY)
+BUILD_LIBS = $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
 	    build/vec.o build/min-insn-modes.o build/gensupport.o \
@@ -1066,7 +1073,7 @@
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
-	   $(ISLINC)
+	   $(ISLINC) $(INCGNU)
 
 COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
 ifeq ($(CXXDEPMODE),depmode=gcc3)
Index: src/gcc/mkconfig.sh
===================================================================
--- src/gcc/mkconfig.sh	(revision 237184)
+++ src/gcc/mkconfig.sh	(working copy)
@@ -43,6 +43,7 @@
 # A special test to ensure that build-time files don't blindly use
 # config.h.
 if test x"$output" = x"config.h"; then
+  echo '#include "../gnulib/config.h"' >> ${output}T
   echo "#ifdef GENERATOR_FILE" >> ${output}T
   echo "#error config.h is for the host, not build, machine." >> ${output}T
   echo "#endif" >> ${output}T
Index: src/gnulib/Makefile.in
===================================================================
--- src/gnulib/Makefile.in	(nonexistent)
+++ src/gnulib/Makefile.in	(working copy)
@@ -0,0 +1,290 @@
+# Copyright (C) 1989-2016 Free Software Foundation, Inc.
+
+# This file is part of GCC.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+localedir = @localedir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+includedir = @includedir@
+
+SHELL = @SHELL@
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DESTDIR =
+
+AR = @AR@
+AR_FLAGS = qv
+RANLIB = @RANLIB@
+DLLTOOL = @DLLTOOL@
+
+SUBDIRS = import
+CLEANDIRS = $(SUBDIRS)
+REQUIRED_SUBDIRS = $(SUBDIRS)
+
+# If you are compiling with GCC, make sure that either 1) You have the
+# fixed include files where GCC can reach them, or 2) You use the
+# -traditional flag.  Otherwise the ioctl calls in inflow.c
+# will be incorrectly compiled.  The "fixincludes" script in the gcc
+# distribution will fix your include files up.
+CC=@CC@
+
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC_LD=$(CC)
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+
+FLAGS_TO_PASS = \
+	"prefix=$(prefix)" \
+	"exec_prefix=$(exec_prefix)" \
+	"infodir=$(infodir)" \
+	"datarootdir=$(datarootdir)" \
+	"docdir=$(docdir)" \
+	"htmldir=$(htmldir)" \
+	"pdfdir=$(pdfdir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
+	"against=$(against)" \
+	"DESTDIR=$(DESTDIR)" \
+	"AR=$(AR)" \
+	"AR_FLAGS=$(AR_FLAGS)" \
+	"CC=$(CC)" \
+	"CFLAGS=$(CFLAGS)" \
+	"CXX=$(CXX)" \
+	"CXXFLAGS=$(CXXFLAGS)" \
+	"DLLTOOL=$(DLLTOOL)" \
+	"LDFLAGS=$(LDFLAGS)" \
+	"RANLIB=$(RANLIB)" \
+	"MAKEINFO=$(MAKEINFO)" \
+	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
+	"MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \
+	"MAKEHTML=$(MAKEHTML)" \
+	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
+	"INSTALL=$(INSTALL)" \
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+	"INSTALL_DATA=$(INSTALL_DATA)" \
+	"RUNTEST=$(RUNTEST)" \
+	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
+
+all installcheck check info install-info clean-info dvi pdf install-pdf html install-html: force
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all
+	@$(MAKE) $(FLAGS_TO_PASS) install-only
+
+install-only: $(CONFIG_INSTALL)
+	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+uninstall: force $(CONFIG_UNINSTALL)
+	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+# Convenience rule to handle recursion.
+$(LIBGNU) $(GNULIB_H): all-lib
+all-lib: import/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=import subdir_do
+.PHONY: all-lib
+
+clean mostlyclean: $(CONFIG_CLEAN)
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
+
+distclean: clean
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
+	rm -f config.status config.h stamp-h
+	rm -f config.log config.cache
+	rm -f Makefile
+	rm -rf $(DEPDIR)
+
+maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
+realclean: maintainer-clean
+
+local-maintainer-clean:
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f config.status
+
+do-maintainer-clean:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
+		subdir_do
+
+subdir_do: force
+	@for i in $(DODIRS); do \
+		case $$i in \
+		$(REQUIRED_SUBDIRS)) \
+			if [ ! -f ./$$i/Makefile ] ; then \
+				echo "Missing $$i/Makefile" >&2 ; \
+				exit 1 ; \
+			fi ;; \
+		esac ; \
+		if [ -f ./$$i/Makefile ] ; then \
+			if (cd ./$$i; \
+				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
+			else exit 1 ; fi ; \
+		else true ; fi ; \
+	done
+
+Makefile: Makefile.in config.status
+	# Regenerate the Makefile.
+	CONFIG_FILES="Makefile" \
+	  CONFIG_COMMANDS= \
+	  CONFIG_HEADERS= \
+	  $(SHELL) config.status
+
+gnulib/Makefile: gnulib/Makefile.in config.status
+	CONFIG_FILES="gnulib/Makefile" \
+	  CONFIG_COMMANDS="depfiles" \
+	  CONFIG_HEADERS= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.h: stamp-h ; @true
+stamp-h: $(srcdir)/config.in config.status
+	CONFIG_HEADERS=config.h:config.in \
+	  CONFIG_COMMANDS="default depdir" \
+	  CONFIG_FILES= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.status: $(srcdir)/configure
+	$(SHELL) config.status --recheck
+
+ACLOCAL = aclocal
+ACLOCAL_AMFLAGS = -I import/m4 -I ../../config
+aclocal_m4_deps = \
+	configure.ac \
+	import/m4/00gnulib.m4 \
+	import/m4/alloca.m4 \
+	import/m4/codeset.m4 \
+	import/m4/configmake.m4 \
+	import/m4/extensions.m4 \
+	import/m4/fcntl-o.m4 \
+	import/m4/fnmatch.m4 \
+	import/m4/glibc21.m4 \
+	import/m4/gnulib-cache.m4 \
+	import/m4/gnulib-common.m4 \
+	import/m4/gnulib-comp.m4 \
+	import/m4/gnulib-tool.m4 \
+	import/m4/include_next.m4 \
+	import/m4/inttypes-pri.m4 \
+	import/m4/inttypes.m4 \
+	import/m4/localcharset.m4 \
+	import/m4/locale-fr.m4 \
+	import/m4/locale-ja.m4 \
+	import/m4/locale-zh.m4 \
+	import/m4/longlong.m4 \
+	import/m4/mbrtowc.m4 \
+	import/m4/mbsinit.m4 \
+	import/m4/mbsrtowcs.m4 \
+	import/m4/mbstate_t.m4 \
+	import/m4/memchr.m4 \
+	import/m4/memmem.m4 \
+	import/m4/mmap-anon.m4 \
+	import/m4/multiarch.m4 \
+	import/m4/off_t.m4 \
+	import/m4/pathmax.m4 \
+	import/m4/ssize_t.m4 \
+	import/m4/stdbool.m4 \
+	import/m4/stddef_h.m4 \
+	import/m4/stdint.m4 \
+	import/m4/obstack.m4 \
+	import/m4/strtok_r.m4 \
+	import/m4/sys_types_h.m4 \
+	import/m4/unistd_h.m4 \
+	import/m4/warn-on-use.m4 \
+	import/m4/wchar_h.m4 \
+	import/m4/wchar_t.m4 \
+	import/m4/wctype_h.m4 \
+	import/m4/wint_t.m4
+
+$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+AUTOCONF = autoconf
+configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+
+AUTOHEADER = autoheader
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h
+	touch $@
+
+# automatic rebuilding in automake-generated Makefiles requires
+# this rule in the toplevel Makefile, which, with GNU make, causes
+# the desired updates through the implicit regeneration of the Makefile
+# and all of its prerequisites.
+am--refresh:
+	@:
+
+force:
+
+force_update:
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+### end of the libgnu Makefile.in.
Index: src/gnulib/configure.ac
===================================================================
--- src/gnulib/configure.ac	(nonexistent)
+++ src/gnulib/configure.ac	(working copy)
@@ -0,0 +1,60 @@
+dnl Autoconf configure script for GCC.
+dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.64)dnl
+AC_INIT()
+AC_CONFIG_HEADER(config.h:config.in)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
+gl_EARLY
+AM_PROG_CC_STDC
+
+AC_CONFIG_AUX_DIR(..)
+AC_CANONICAL_SYSTEM
+
+gl_INIT
+
+# Gnulib uses automake.  This line lets gcc generate
+# its Makefile.in.
+AM_INIT_AUTOMAKE(libgnu, UNUSED-VERSION, [no-define])
+
+# --------------------- #
+# Checks for programs.  #
+# --------------------- #
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+
+AC_CHECK_TOOL(AR, ar)
+
+# ---------------------- #
+# Checks for libraries.  #
+# ---------------------- #
+
+AC_OUTPUT(Makefile import/Makefile,
+[
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
+
+exit 0
Index: src/gnulib/update-gnulib.sh
===================================================================
--- src/gnulib/update-gnulib.sh	(nonexistent)
+++ src/gnulib/update-gnulib.sh	(working copy)
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Copyright (C) 2011-2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-gnulib.sh <path-to-gnulib-repository>
+# Update our import of gnulib in the GCC source tree.
+#
+# This script assumes that it is being called from the gcc/gnulib
+# subdirectory.
+#
+# This script will also make a number of other verifications:
+#   . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
+#   . The correct versions of the auto-tools that are used to
+#     regenerate the various scripts and Makefiles are on the PATH.
+
+# The list of gnulib modules we are importing in GCC.
+IMPORTED_GNULIB_MODULES="\
+    obstack \
+"
+
+# The gnulib commit ID to use for the update.
+GNULIB_COMMIT_SHA1="1029a8112290f6eee9d7878a391c49db42c999bd"
+
+# The expected version number for the various auto tools we will
+# use after the import.
+AUTOCONF_VERSION="2.69"
+AUTOMAKE_VERSION="1.15"
+ACLOCAL_VERSION="$AUTOMAKE_VERSION"
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to gnulib repository missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
+   exit 1
+fi
+gnulib_prefix=$1
+
+gnulib_tool="$gnulib_prefix/gnulib-tool"
+
+# Verify that the gnulib directory does exist...
+if [ ! -f "$gnulib_tool" ]; then
+   echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
+   echo "       ($gnulib_tool)."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the right version of gnulib...
+gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
+if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
+   echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
+   echo "       (we expected it to be $GNULIB_COMMIT_SHA1)"
+   echo "Aborting."
+   exit 1
+fi
+
+ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOCONF_VERSION" ]; then
+   echo "Error: Wrong autoconf version: $ver. Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of automake.
+ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
+   echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of aclocal.
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$ACLOCAL_VERSION" ]; then
+   echo "Error: Wrong aclocal version: $ver. Aborting."
+   exit 1
+fi
+
+# Update our gnulib import.
+$gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
+  --source-base=import --m4-base=import/m4 --doc-base=doc \
+  --tests-base=tests --aux-dir=import/extra \
+  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
+  --no-vc-files \
+  $IMPORTED_GNULIB_MODULES
+if [ $? -ne 0 ]; then
+   echo "Error: gnulib import failed.  Aborting."
+   exit 1
+fi
+
+# Regenerate all necessary files...
+aclocal -Iimport/m4 &&
+autoconf &&
+autoheader &&
+automake
+if [ $? -ne 0 ]; then
+   echo "Error: Failed to regenerate Makefiles and configure scripts."
+   exit 1
+fi
+

Property changes on: src/gnulib/update-gnulib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/gcc/doc/sourcebuild.texi
===================================================================
--- src/gcc/doc/sourcebuild.texi	(revision 237184)
+++ src/gcc/doc/sourcebuild.texi	(working copy)
@@ -97,6 +97,22 @@
 Introduction, libiberty, @sc{gnu} libiberty}, for more information
 about this library.
 
+@item libgnu
+Gnulib - The GNU portability library
+To facilitate the update/import of gnulib, a script called update-gnulib.sh (resides inside path/to/gcc-src/gcc/gnulib) has been created to automate the process.
+Usage: update-gnulib.sh <path-to-gnulib-repository>
+
+The script maintains the two key pieces of information from which the import is created as constants defined inside the script:
+@itemize @bullet
+@item
+GNULIB_COMMIT_SHA1 - which commit from the gnulib respository is to be used for the import; So in order to update gnulib, replace this value with that of the newer version and run the script.
+
+@item
+IMPORTED_GNULIB_MODULES - which modules to import from gnulib. Add a new module to this list in order to import it to gcc and run the script. 
+
+@end itemize
+When updating the import, please only modify one element at a time. For instance, if you want to import a new module only defined in a later version of gnulib, please first update the import to use the newer commit as a first patch, and then update the import to include the new module as a second patch.
+
 @item libitm
 The runtime support library for transactional memory.
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-15 12:51 [PATCH build/doc] Replacing libiberty with gnulib ayush goel
@ 2016-08-15 14:26 ` Manuel López-Ibáñez
  2016-08-16 16:54 ` Pedro Alves
  1 sibling, 0 replies; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-08-15 14:26 UTC (permalink / raw)
  To: ayush goel; +Cc: Joseph Myers, Pedro Alves, Gcc Patch List, Jeff Law

On 15 August 2016 at 13:50, ayush goel <ayushgoel1610@gmail.com> wrote:
> Included gnulib’s config.h header file inside gcc’s config.h itself as
> per the discussions.
>
> Built and tested the system.

You need to mention how you build it (languages, bootstrap, etc.) and
how you tested it (targets).

Do the other patches that you submitted still work with this new one?

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-15 12:51 [PATCH build/doc] Replacing libiberty with gnulib ayush goel
  2016-08-15 14:26 ` Manuel López-Ibáñez
@ 2016-08-16 16:54 ` Pedro Alves
  2016-08-16 17:21   ` Joseph Myers
  2016-08-20 10:22   ` ayush goel
  1 sibling, 2 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-16 16:54 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

Hi there,

On 08/15/2016 01:50 PM, ayush goel wrote:

> +# Where to find the gnulib library
> +LIBGNU = ../gnulib/import/libgnu.a
> +BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
> +INCGNU = -I$(srcdir)/../gnulib/import
> +

I may be missing something, but I don't understand how can this be
right.  AFAICS, this is still not pointing the include directory search
path at the "gnulib/import/" subdirectory found inside the gnulib
build directory.

If gnulib decides to create a replacement header for e.g., unistd.h,
then any '#include <unistd.h>' throughout gcc's sources (except
target libraries) should result in gnulib's replacement header
being included.

We're talking about a one-line change, but this is absolutely
crucial and central to use of gnulib.  Until this is correct,
any previous host-specific testing is invalid, unfortunately.

In the previous revision, you had:

 INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import

and I was expecting to see in the new revision something
like:

 INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import

or perhaps even better:

 INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import

Try hacking one of the generated replacement headers, one that gcc
is sure to include, to cause a compilation error.  E.g. add an #error call
to the generated gnulib/import/unistd.h.  If a gcc build, from scratch since
there are no Makefile dependencies, still compiles with that, then we're
still not picking the right headers.

> Index: src/gcc/mkconfig.sh
> ===================================================================
> --- src/gcc/mkconfig.sh	(revision 237184)
> +++ src/gcc/mkconfig.sh	(working copy)
> @@ -43,6 +43,7 @@
>  # A special test to ensure that build-time files don't blindly use
>  # config.h.
>  if test x"$output" = x"config.h"; then
> +  echo '#include "../gnulib/config.h"' >> ${output}T
>    echo "#ifdef GENERATOR_FILE" >> ${output}T
>    echo "#error config.h is for the host, not build, machine." >> ${output}T
>    echo "#endif" >> ${output}T

Hmm, this looks incorrect/incomplete, for not considering the generator
programs that are built for the "build" machine.  AFAICS, those include
"bconfig.h" instead of "config.h".  Note the GENERATOR_FILE check above.  

My recollection is that those build-machine programs link with libiberty
too today, and should thus switch to gnulib as well, right?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-16 16:54 ` Pedro Alves
@ 2016-08-16 17:21   ` Joseph Myers
  2016-08-20 10:22   ` ayush goel
  1 sibling, 0 replies; 33+ messages in thread
From: Joseph Myers @ 2016-08-16 17:21 UTC (permalink / raw)
  To: Pedro Alves
  Cc: ayush goel, Manuel López-Ibáñez, Gcc Patch List, Jeff Law

On Tue, 16 Aug 2016, Pedro Alves wrote:

> My recollection is that those build-machine programs link with libiberty
> too today, and should thus switch to gnulib as well, right?

Yes.  For host programs the include path for the $host build of gnulib 
must be used, and for build programs the include path for the $build build 
of gnulib must be used.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-16 16:54 ` Pedro Alves
  2016-08-16 17:21   ` Joseph Myers
@ 2016-08-20 10:22   ` ayush goel
  2016-08-20 15:22     ` Manuel López-Ibáñez
  2016-08-21 19:41     ` Pedro Alves
  1 sibling, 2 replies; 33+ messages in thread
From: ayush goel @ 2016-08-20 10:22 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Pedro Alves, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

>
> We're talking about a one-line change, but this is absolutely
> crucial and central to use of gnulib. Until this is correct,
> any previous host-specific testing is invalid, unfortunately.
>
> In the previous revision, you had:
>
> INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>
> and I was expecting to see in the new revision something
> like:
>
> INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import
>
> or perhaps even better:
>
> INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import
>
> Try hacking one of the generated replacement headers, one that gcc
> is sure to include, to cause a compilation error. E.g. add an #error call
> to the generated gnulib/import/unistd.h. If a gcc build, from scratch since
> there are no Makefile dependencies, still compiles with that, then we're
> still not picking the right headers.

So your concern seems valid, however the build process seems to pick
the correct headers.
I did try to raise an error from the gnulib generated header unitstd.h
and it gives me a compile time error:

--------------------------------------------------------------
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT exitfail.o -MD -MP -MF .deps/exitfail.Tpo -c -o
exitfail.o /Users/ayushgoel/gsoc/src/gnulib/import/exitfail.c
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT unistd.o -MD -MP -MF .deps/unistd.Tpo -c -o unistd.o
/Users/ayushgoel/gsoc/src/gnulib/import/unistd.c
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT obstack.o -MD -MP -MF .deps/obstack.Tpo -c -o obstack.o
/Users/ayushgoel/gsoc/src/gnulib/import/obstack.c
In file included from /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c:3:
./unistd.h:18:2: error: “Unistd header file being invoked"
#error “unistd from gnulib being invoked"
 ^
config.status: creating config.h
1 error generated.
make[5]: *** [unistd.o] Error 1

Also, I’m sure of the fact that gnulib headers are being used because
all the functions that I’ve replaced from libiberty, I locally removed
both the .c and .h files from libiberty to confirm that the gnulib’s
version is indeed being used, and it compiled just fine.

I’m not really sure how else it is being able to figure out where to
look for the header files however just to be on the safer side I’ve
made the change that you’ve mentioned.

>
> > Index: src/gcc/mkconfig.sh
> > ===================================================================
> > --- src/gcc/mkconfig.sh (revision 237184)
> > +++ src/gcc/mkconfig.sh (working copy)
> > @@ -43,6 +43,7 @@
> > # A special test to ensure that build-time files don't blindly use
> > # config.h.
> > if test x"$output" = x"config.h"; then
> > + echo '#include "../gnulib/config.h"' >> ${output}T
> > echo "#ifdef GENERATOR_FILE" >> ${output}T
> > echo "#error config.h is for the host, not build, machine." >> ${output}T
> > echo "#endif" >> ${output}T
>
> Hmm, this looks incorrect/incomplete, for not considering the generator
> programs that are built for the "build" machine. AFAICS, those include
> "bconfig.h" instead of "config.h". Note the GENERATOR_FILE check above.
>
> My recollection is that those build-machine programs link with libiberty
> too today, and should thus switch to gnulib as well, right?
>

So my understanding of this is that the gnulib.h is also required to
be included inside bconfig.h?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-20 10:22   ` ayush goel
@ 2016-08-20 15:22     ` Manuel López-Ibáñez
  2016-08-21 11:36       ` ayush goel
  2016-08-21 19:41     ` Pedro Alves
  1 sibling, 1 reply; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-08-20 15:22 UTC (permalink / raw)
  To: ayush goel; +Cc: Pedro Alves, Joseph Myers, Gcc Patch List, Jeff Law

On 20 August 2016 at 11:22, ayush goel <ayushgoel1610@gmail.com> wrote:
>>
>> We're talking about a one-line change, but this is absolutely
>> crucial and central to use of gnulib. Until this is correct,
>> any previous host-specific testing is invalid, unfortunately.
>>
>> In the previous revision, you had:
>>
>> INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>>
>> and I was expecting to see in the new revision something
>> like:
>>
>> INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import
>>
>> or perhaps even better:
>>
>> INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import
>>
>> Try hacking one of the generated replacement headers, one that gcc
>> is sure to include, to cause a compilation error. E.g. add an #error call
>> to the generated gnulib/import/unistd.h. If a gcc build, from scratch since
>> there are no Makefile dependencies, still compiles with that, then we're
>> still not picking the right headers.
>
> So your concern seems valid, however the build process seems to pick
> the correct headers.
> I did try to raise an error from the gnulib generated header unitstd.h
> and it gives me a compile time error:

Perhaps adding #error is not the best way to test this, since gnulib
may still pick the correct headers, but gcc the wrong ones and the
error you showed happens when building gnulib. A better way, perhaps,
would be to add to unitsdt.h something like

#define unitstd_h_gnulib

then in some gcc/ file that includes this header, like gcov-tool.c or
system.h, you can do just after the #include

#ifndef unitstd_h_gnulib
#error "unitstd_h_gnulib not defined"
#endif

Test that it fails when not having the correct INCGNU and that it
works when having it. This should settle it, I hope.

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-20 15:22     ` Manuel López-Ibáñez
@ 2016-08-21 11:36       ` ayush goel
  0 siblings, 0 replies; 33+ messages in thread
From: ayush goel @ 2016-08-21 11:36 UTC (permalink / raw)
  To: Manuel López-Ibáñez
  Cc: Pedro Alves, Joseph Myers, Jeff Law, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 5120 bytes --]

Bootstrapped with multiple languages and multilib enabled for maximum coverage.
Regression tested on x86_64-apple-darwin15.5.0 and x86_64-linux

PFA the patch





2016-08-21 Ayush Goel <ayushgoel1610@gmail.com>

* Makefile.def: Added gnulib as build & host library and dependency of
all-gcc on gnulib
* Makefile.in: regenerated
* configure.ac: Added gnulib as build and host library
* configure: regenerated
* gcc/Makefile.in: Added path to gnulib static library (libgnu.a) and
gnulib header files
* gcc/mkconfig.sh: Included gnulib’s config.h
* gcc/doc/sourcebuild.texi: Added gnulib and how to use the update
script to update/import gnu lib modules
* gnulib: created directory
* gnulib/Makefile.in: new file
* gnulib/configure.ac: new file
* gnulib/update-gnulib.sh: script to import gnulib modules using gnulib-tool
* gnulib/import: created by update-gnulib.sh
* gnulib/import/Makefile.in: imported from gnulib
* gnulib/import/alignof.h: Imported from gnulib
* gnulib/import/exitfail.c: Imported from gnulib
* gnulib/import/exitfail.h: Imported from gnulib
* gnulib/import/extra: Imported from gnulib
* gnulib/import/extra/snippet: Imported from gnulib
* gnulib/import/extra/snippet/_Noreturn.h: Imported from gnulib
* gnulib/import/extra/snippet/arg-nonnull.h: Imported from gnulib
* gnulib/import/extra/snippet/c++defs.h: Imported from gnulib
* gnulib/import/extra/snippet/warn-on-use.h: Imported from gnulib
* gnulib/import/gettext.h: Imported from gnulib
* gnulib/import/m4: Imported from gnulib
* gnulib/import/m4/00gnulib.m4: Imported from gnulib
* gnulib/import/m4/absolute-header.m4: Imported from gnulib
* gnulib/import/m4/extern-inline.m4: Imported from gnulib
* gnulib/import/m4/gnulib-cache.m4: Imported from gnulib
* gnulib/import/m4/gnulib-common.m4: Imported from gnulib
* gnulib/import/m4/gnulib-comp.m4: Imported from gnulib
* gnulib/import/m4/gnulib-tool.m4: Imported from gnulib
* gnulib/import/m4/include_next.m4: Imported from gnulib
* gnulib/import/m4/longlong.m4: Imported from gnulib
* gnulib/import/m4/multiarch.m4: Imported from gnulib
* gnulib/import/m4/obstack.m4: Imported from gnulib
* gnulib/import/m4/off_t.m4: Imported from gnulib
* gnulib/import/m4/ssize_t.m4: Imported from gnulib
* gnulib/import/m4/stddef_h.m4: Imported from gnulib
* gnulib/import/m4/stdint.m4: Imported from gnulib
* gnulib/import/m4/stdlib_h.m4: Imported from gnulib
* gnulib/import/m4/sys_types_h.m4: Imported from gnulib
* gnulib/import/m4/unistd_h.m4: Imported from gnulib
* gnulib/import/m4/warn-on-use.m4: Imported from gnulib
* gnulib/import/m4/wchar_t.m4: Imported from gnulib
* gnulib/import/obstack.c: Imported from gnulib
* gnulib/import/obstack.h: Imported from gnulib
* gnulib/import/stddef.in.h: Imported from gnulib
* gnulib/import/stdint.in.h: Imported from gnulib
* gnulib/import/stdlib.in.h: Imported from gnulib
* gnulib/import/sys: Imported from gnulib
* gnulib/import/sys_types.in.h: Imported from gnulib
* gnulib/import/unistd.c: Imported from gnulib
* gnulib/import/unistd.in.h: Imported from gnulib
* gnulib/stamp-h1: generated


-Ayush

On 20 August 2016 at 8:52:56 PM, Manuel López-Ibáñez
(lopezibanez@gmail.com) wrote:
> On 20 August 2016 at 11:22, ayush goel wrote:
> >>
> >> We're talking about a one-line change, but this is absolutely
> >> crucial and central to use of gnulib. Until this is correct,
> >> any previous host-specific testing is invalid, unfortunately.
> >>
> >> In the previous revision, you had:
> >>
> >> INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
> >>
> >> and I was expecting to see in the new revision something
> >> like:
> >>
> >> INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import
> >>
> >> or perhaps even better:
> >>
> >> INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import
> >>
> >> Try hacking one of the generated replacement headers, one that gcc
> >> is sure to include, to cause a compilation error. E.g. add an #error call
> >> to the generated gnulib/import/unistd.h. If a gcc build, from scratch since
> >> there are no Makefile dependencies, still compiles with that, then we're
> >> still not picking the right headers.
> >
> > So your concern seems valid, however the build process seems to pick
> > the correct headers.
> > I did try to raise an error from the gnulib generated header unitstd.h
> > and it gives me a compile time error:
>
> Perhaps adding #error is not the best way to test this, since gnulib
> may still pick the correct headers, but gcc the wrong ones and the
> error you showed happens when building gnulib. A better way, perhaps,
> would be to add to unitsdt.h something like
>
> #define unitstd_h_gnulib
>
> then in some gcc/ file that includes this header, like gcov-tool.c or
> system.h, you can do just after the #include
>
> #ifndef unitstd_h_gnulib
> #error "unitstd_h_gnulib not defined"
> #endif
>
> Test that it fails when not having the correct INCGNU and that it
> works when having it. This should settle it, I hope.
>
> Cheers,
>
> Manuel.
>

[-- Attachment #2: importgnulib_8_21.patch --]
[-- Type: application/octet-stream, Size: 22386 bytes --]

Index: src/Makefile.def
===================================================================
--- src/Makefile.def	(revision 237184)
+++ src/Makefile.def	(working copy)
@@ -25,6 +25,7 @@
 // that recursive target in its Makefile.
 
 build_modules= { module= libiberty; };
+build_modules= { module= gnulib; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
@@ -112,6 +113,8 @@
 host_modules= { module= zlib; no_install=true; no_check=true;
 		bootstrap=true;
 	        extra_configure_flags='@extra_host_zlib_configure_flags@';};
+host_modules= { module= gnulib;
+              bootstrap=true; };
 host_modules= { module= gdb; };
 host_modules= { module= expect; };
 host_modules= { module= guile; };
@@ -342,6 +345,8 @@
 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-gnulib; hard=true; };
+dependencies = { module=all-gcc; on=all-build-gnulib; };
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 237184)
+++ src/configure.ac	(working copy)
@@ -125,7 +125,7 @@
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty build-libcpp"
+build_libs="build-libiberty build-libcpp build-gnulib"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
@@ -132,7 +132,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv gnulib"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
Index: src/gcc/Makefile.in
===================================================================
--- src/gcc/Makefile.in	(revision 237184)
+++ src/gcc/Makefile.in	(working copy)
@@ -484,12 +484,14 @@
 
 # Where to find some libiberty headers.
 HASHTAB_H   = $(srcdir)/../include/hashtab.h
-OBSTACK_H   = $(srcdir)/../include/obstack.h
 SPLAY_TREE_H= $(srcdir)/../include/splay-tree.h
 MD5_H	    = $(srcdir)/../include/md5.h
 XREGEX_H    = $(srcdir)/../include/xregex.h
 FNMATCH_H   = $(srcdir)/../include/fnmatch.h
 
+# GNULIB headers
+OBSTACK_H   = $(srcdir)/../gnulib/import/obstack.h
+
 # Linker plugin API headers
 LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 
@@ -1022,18 +1024,23 @@
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
+# Where to find the gnulib library
+LIBGNU = ../gnulib/import/libgnu.a
+BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
+INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import 
+
 # Dependencies on the intl and portability libraries.
-LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
+LIBDEPS= libcommon.a $(CPPLIB) $(LIBGNU) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
 	$(LIBDECNUMBER) $(LIBBACKTRACE)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+BUILD_LIBDEPS= $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
-	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+	$(LIBGNU) $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
 BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
@@ -1048,7 +1055,7 @@
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBS = $(BUILD_LIBIBERTY)
+BUILD_LIBS = $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
 	    build/vec.o build/min-insn-modes.o build/gensupport.o \
@@ -1066,7 +1073,7 @@
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
-	   $(ISLINC)
+	   $(ISLINC) $(INCGNU)
 
 COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
 ifeq ($(CXXDEPMODE),depmode=gcc3)
Index: src/gcc/mkconfig.sh
===================================================================
--- src/gcc/mkconfig.sh (revision 237184)
+++ src/gcc/mkconfig.sh (working copy)
@@ -36,6 +36,10 @@
 hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,'
 header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
 
+if test x"$output" = x"bconfig.h"; then
+  echo '#include "../gnulib/config.h"' >> ${output}T
+fi
+
 # Add multiple inclusion protection guard, part one.
 echo "#ifndef ${header_guard}" >> ${output}T
 echo "#define ${header_guard}" >> ${output}T
@@ -46,6 +50,7 @@
   echo "#ifdef GENERATOR_FILE" >> ${output}T
   echo "#error config.h is for the host, not build, machine." >> ${output}T
   echo "#endif" >> ${output}T
+  echo '#include "../gnulib/config.h"' >> ${output}T
 fi
 
 # Define TARGET_CPU_DEFAULT if the system wants one. 
Index: src/gnulib/Makefile.in
===================================================================
--- src/gnulib/Makefile.in	(nonexistent)
+++ src/gnulib/Makefile.in	(working copy)
@@ -0,0 +1,290 @@
+# Copyright (C) 1989-2016 Free Software Foundation, Inc.
+
+# This file is part of GCC.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+localedir = @localedir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+includedir = @includedir@
+
+SHELL = @SHELL@
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DESTDIR =
+
+AR = @AR@
+AR_FLAGS = qv
+RANLIB = @RANLIB@
+DLLTOOL = @DLLTOOL@
+
+SUBDIRS = import
+CLEANDIRS = $(SUBDIRS)
+REQUIRED_SUBDIRS = $(SUBDIRS)
+
+# If you are compiling with GCC, make sure that either 1) You have the
+# fixed include files where GCC can reach them, or 2) You use the
+# -traditional flag.  Otherwise the ioctl calls in inflow.c
+# will be incorrectly compiled.  The "fixincludes" script in the gcc
+# distribution will fix your include files up.
+CC=@CC@
+
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC_LD=$(CC)
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+
+FLAGS_TO_PASS = \
+	"prefix=$(prefix)" \
+	"exec_prefix=$(exec_prefix)" \
+	"infodir=$(infodir)" \
+	"datarootdir=$(datarootdir)" \
+	"docdir=$(docdir)" \
+	"htmldir=$(htmldir)" \
+	"pdfdir=$(pdfdir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
+	"against=$(against)" \
+	"DESTDIR=$(DESTDIR)" \
+	"AR=$(AR)" \
+	"AR_FLAGS=$(AR_FLAGS)" \
+	"CC=$(CC)" \
+	"CFLAGS=$(CFLAGS)" \
+	"CXX=$(CXX)" \
+	"CXXFLAGS=$(CXXFLAGS)" \
+	"DLLTOOL=$(DLLTOOL)" \
+	"LDFLAGS=$(LDFLAGS)" \
+	"RANLIB=$(RANLIB)" \
+	"MAKEINFO=$(MAKEINFO)" \
+	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
+	"MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \
+	"MAKEHTML=$(MAKEHTML)" \
+	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
+	"INSTALL=$(INSTALL)" \
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+	"INSTALL_DATA=$(INSTALL_DATA)" \
+	"RUNTEST=$(RUNTEST)" \
+	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
+
+all installcheck check info install-info clean-info dvi pdf install-pdf html install-html: force
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all
+	@$(MAKE) $(FLAGS_TO_PASS) install-only
+
+install-only: $(CONFIG_INSTALL)
+	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+uninstall: force $(CONFIG_UNINSTALL)
+	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+# Convenience rule to handle recursion.
+$(LIBGNU) $(GNULIB_H): all-lib
+all-lib: import/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=import subdir_do
+.PHONY: all-lib
+
+clean mostlyclean: $(CONFIG_CLEAN)
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
+
+distclean: clean
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
+	rm -f config.status config.h stamp-h
+	rm -f config.log config.cache
+	rm -f Makefile
+	rm -rf $(DEPDIR)
+
+maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
+realclean: maintainer-clean
+
+local-maintainer-clean:
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f config.status
+
+do-maintainer-clean:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
+		subdir_do
+
+subdir_do: force
+	@for i in $(DODIRS); do \
+		case $$i in \
+		$(REQUIRED_SUBDIRS)) \
+			if [ ! -f ./$$i/Makefile ] ; then \
+				echo "Missing $$i/Makefile" >&2 ; \
+				exit 1 ; \
+			fi ;; \
+		esac ; \
+		if [ -f ./$$i/Makefile ] ; then \
+			if (cd ./$$i; \
+				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
+			else exit 1 ; fi ; \
+		else true ; fi ; \
+	done
+
+Makefile: Makefile.in config.status
+	# Regenerate the Makefile.
+	CONFIG_FILES="Makefile" \
+	  CONFIG_COMMANDS= \
+	  CONFIG_HEADERS= \
+	  $(SHELL) config.status
+
+gnulib/Makefile: gnulib/Makefile.in config.status
+	CONFIG_FILES="gnulib/Makefile" \
+	  CONFIG_COMMANDS="depfiles" \
+	  CONFIG_HEADERS= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.h: stamp-h ; @true
+stamp-h: $(srcdir)/config.in config.status
+	CONFIG_HEADERS=config.h:config.in \
+	  CONFIG_COMMANDS="default depdir" \
+	  CONFIG_FILES= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.status: $(srcdir)/configure
+	$(SHELL) config.status --recheck
+
+ACLOCAL = aclocal
+ACLOCAL_AMFLAGS = -I import/m4 -I ../../config
+aclocal_m4_deps = \
+	configure.ac \
+	import/m4/00gnulib.m4 \
+	import/m4/alloca.m4 \
+	import/m4/codeset.m4 \
+	import/m4/configmake.m4 \
+	import/m4/extensions.m4 \
+	import/m4/fcntl-o.m4 \
+	import/m4/fnmatch.m4 \
+	import/m4/glibc21.m4 \
+	import/m4/gnulib-cache.m4 \
+	import/m4/gnulib-common.m4 \
+	import/m4/gnulib-comp.m4 \
+	import/m4/gnulib-tool.m4 \
+	import/m4/include_next.m4 \
+	import/m4/inttypes-pri.m4 \
+	import/m4/inttypes.m4 \
+	import/m4/localcharset.m4 \
+	import/m4/locale-fr.m4 \
+	import/m4/locale-ja.m4 \
+	import/m4/locale-zh.m4 \
+	import/m4/longlong.m4 \
+	import/m4/mbrtowc.m4 \
+	import/m4/mbsinit.m4 \
+	import/m4/mbsrtowcs.m4 \
+	import/m4/mbstate_t.m4 \
+	import/m4/memchr.m4 \
+	import/m4/memmem.m4 \
+	import/m4/mmap-anon.m4 \
+	import/m4/multiarch.m4 \
+	import/m4/off_t.m4 \
+	import/m4/pathmax.m4 \
+	import/m4/ssize_t.m4 \
+	import/m4/stdbool.m4 \
+	import/m4/stddef_h.m4 \
+	import/m4/stdint.m4 \
+	import/m4/obstack.m4 \
+	import/m4/strtok_r.m4 \
+	import/m4/sys_types_h.m4 \
+	import/m4/unistd_h.m4 \
+	import/m4/warn-on-use.m4 \
+	import/m4/wchar_h.m4 \
+	import/m4/wchar_t.m4 \
+	import/m4/wctype_h.m4 \
+	import/m4/wint_t.m4
+
+$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+AUTOCONF = autoconf
+configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+
+AUTOHEADER = autoheader
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h
+	touch $@
+
+# automatic rebuilding in automake-generated Makefiles requires
+# this rule in the toplevel Makefile, which, with GNU make, causes
+# the desired updates through the implicit regeneration of the Makefile
+# and all of its prerequisites.
+am--refresh:
+	@:
+
+force:
+
+force_update:
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+### end of the libgnu Makefile.in.
Index: src/gnulib/configure.ac
===================================================================
--- src/gnulib/configure.ac	(nonexistent)
+++ src/gnulib/configure.ac	(working copy)
@@ -0,0 +1,60 @@
+dnl Autoconf configure script for GCC.
+dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.64)dnl
+AC_INIT()
+AC_CONFIG_HEADER(config.h:config.in)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
+gl_EARLY
+AM_PROG_CC_STDC
+
+AC_CONFIG_AUX_DIR(..)
+AC_CANONICAL_SYSTEM
+
+gl_INIT
+
+# Gnulib uses automake.  This line lets gcc generate
+# its Makefile.in.
+AM_INIT_AUTOMAKE(libgnu, UNUSED-VERSION, [no-define])
+
+# --------------------- #
+# Checks for programs.  #
+# --------------------- #
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+
+AC_CHECK_TOOL(AR, ar)
+
+# ---------------------- #
+# Checks for libraries.  #
+# ---------------------- #
+
+AC_OUTPUT(Makefile import/Makefile,
+[
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
+
+exit 0
Index: src/gnulib/update-gnulib.sh
===================================================================
--- src/gnulib/update-gnulib.sh	(nonexistent)
+++ src/gnulib/update-gnulib.sh	(working copy)
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Copyright (C) 2011-2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-gnulib.sh <path-to-gnulib-repository>
+# Update our import of gnulib in the GCC source tree.
+#
+# This script assumes that it is being called from the gcc/gnulib
+# subdirectory.
+#
+# This script will also make a number of other verifications:
+#   . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
+#   . The correct versions of the auto-tools that are used to
+#     regenerate the various scripts and Makefiles are on the PATH.
+
+# The list of gnulib modules we are importing in GCC.
+IMPORTED_GNULIB_MODULES="\
+    obstack \
+"
+
+# The gnulib commit ID to use for the update.
+GNULIB_COMMIT_SHA1="1029a8112290f6eee9d7878a391c49db42c999bd"
+
+# The expected version number for the various auto tools we will
+# use after the import.
+AUTOCONF_VERSION="2.69"
+AUTOMAKE_VERSION="1.15"
+ACLOCAL_VERSION="$AUTOMAKE_VERSION"
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to gnulib repository missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
+   exit 1
+fi
+gnulib_prefix=$1
+
+gnulib_tool="$gnulib_prefix/gnulib-tool"
+
+# Verify that the gnulib directory does exist...
+if [ ! -f "$gnulib_tool" ]; then
+   echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
+   echo "       ($gnulib_tool)."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the right version of gnulib...
+gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
+if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
+   echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
+   echo "       (we expected it to be $GNULIB_COMMIT_SHA1)"
+   echo "Aborting."
+   exit 1
+fi
+
+ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOCONF_VERSION" ]; then
+   echo "Error: Wrong autoconf version: $ver. Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of automake.
+ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
+   echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of aclocal.
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$ACLOCAL_VERSION" ]; then
+   echo "Error: Wrong aclocal version: $ver. Aborting."
+   exit 1
+fi
+
+# Update our gnulib import.
+$gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
+  --source-base=import --m4-base=import/m4 --doc-base=doc \
+  --tests-base=tests --aux-dir=import/extra \
+  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
+  --no-vc-files \
+  $IMPORTED_GNULIB_MODULES
+if [ $? -ne 0 ]; then
+   echo "Error: gnulib import failed.  Aborting."
+   exit 1
+fi
+
+# Regenerate all necessary files...
+aclocal -Iimport/m4 &&
+autoconf &&
+autoheader &&
+automake
+if [ $? -ne 0 ]; then
+   echo "Error: Failed to regenerate Makefiles and configure scripts."
+   exit 1
+fi
+

Property changes on: src/gnulib/update-gnulib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/gcc/doc/sourcebuild.texi
===================================================================
--- src/gcc/doc/sourcebuild.texi	(revision 237184)
+++ src/gcc/doc/sourcebuild.texi	(working copy)
@@ -97,6 +97,22 @@
 Introduction, libiberty, @sc{gnu} libiberty}, for more information
 about this library.
 
+@item libgnu
+Gnulib - The GNU portability library
+To facilitate the update/import of gnulib, a script called @file{update-gnulib.sh} (resides at src/gnulib/update-gnulib.sh ) has been created to automate the process.
+@smallexample
+Usage: update-gnulib.sh <path-to-gnulib-repository>
+@end smallexample

+The script maintains the two key pieces of information from which the import is created as constants defined inside the script:
+@itemize @bullet
+@item
+@var{GNULIB_COMMIT_SHA1} is the commit from the gnulib respository  to be used for the import. In order to update gnulib, replace this value with that of the newer version and run the script.
+
+@item
+@var{IMPORTED_GNULIB_MODULES} specifies which modules to import from gnulib. Add a new module to this list in order to import it to GCC and run the script. 
+
+@end itemize
+When updating the import, please only modify one element at a time. For instance, if you want to import a new module only defined in a later version of @code{gnulib}, please first update the import to use the newer commit as a first patch, and then update the import to include the new module as a second patch.
+
 @item libitm
 The runtime support library for transactional memory.
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-20 10:22   ` ayush goel
  2016-08-20 15:22     ` Manuel López-Ibáñez
@ 2016-08-21 19:41     ` Pedro Alves
  2016-08-22 16:36       ` ayush goel
  1 sibling, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-21 19:41 UTC (permalink / raw)
  To: ayush goel, Manuel López-Ibáñez, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

On 08/20/2016 11:22 AM, ayush goel wrote:

> So your concern seems valid, however the build process seems to pick
> the correct headers.

I tried it now and it does _not_ pick the correct headers.  My concern
is definitely valid.  More below.

> I did try to raise an error from the gnulib generated header unitstd.h
> and it gives me a compile time error:
> 
> --------------------------------------------------------------
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT exitfail.o -MD -MP -MF .deps/exitfail.Tpo -c -o
> exitfail.o /Users/ayushgoel/gsoc/src/gnulib/import/exitfail.c
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT unistd.o -MD -MP -MF .deps/unistd.Tpo -c -o unistd.o
> /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c
> gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
>     -g -O2 -MT obstack.o -MD -MP -MF .deps/obstack.Tpo -c -o obstack.o
> /Users/ayushgoel/gsoc/src/gnulib/import/obstack.c
> In file included from /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c:3:
> ./unistd.h:18:2: error: “Unistd header file being invoked"
> #error “unistd from gnulib being invoked"
>  ^

This is building _gnulib_ itself, which has its own configure/Makefile.

We're talking about gcc/Makefile.in, and the need to confirm that
we're picking the gnulib replacement headers when building _gcc/_ sources.

I just tried it myself now.  And as I was saying, the '-I../gnulib/import'
really _is_ necessary.  With the corrected:

  INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import 

... hacking the generated gnulib/import/unistd.h and then
compiling any gcc/ file (simply cd gcc; make) errors out with:

 $ make
 g++ -fno-PIE -c  -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -g3  -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -Ic-family -I/home/pedro/src/gcc/src/gcc -I/home/pedro/src/gcc/src/gcc/c-family -I/home/pedro/src/gcc/src/gcc/../include -I/home/pedro/src/gcc/src/gcc/../libcpp/include -I/home/pedro/brno/pedro/src/gcc/build/./gmp -I/home/pedro/src/gcc/src/gmp -I/home/pedro/brno/pedro/src/gcc/build/./mpfr/src -I/home/pedro/src/gcc/src/mpfr/src -I/home/pedro/src/gcc/src/mpc/src  -I/home/pedro/src/gcc/src/gcc/../libdecnumber -I/home/pedro/src/gcc/src/gcc/../libdecnumber/bid -I../libdecnumber -I/home/pedro/src/gcc/src/gcc/../libbacktrace  -I../gnulib/import -I/home/pedro/src/gcc/src/gcc/../gnulib/import   -o c-family/c-omp.o -MT c-family/c-omp.o -MMD -MP -MF c-family/.deps/c-omp.TPo /home/pedro/src/gcc/src/gcc/c-family/c-omp.c
 In file included from /home/pedro/src/gcc/src/gcc/system.h:294:0,
                  from /home/pedro/src/gcc/src/gcc/c-family/c-omp.c:25:
 ../gnulib/import/unistd.h:1:2: error: #error gnulib header included
  #error gnulib header included
   ^
 Makefile:1104: recipe for target 'c-family/c-omp.o' failed
 make: *** [c-family/c-omp.o] Error 1

... which is good.

However, with the original (incorrect):

  INCGNU = -I$(srcdir)/../gnulib/import

(i.e., only point at the srcdir, and not at the generated headers)

... the #error doesn't trigger, and the gcc/ build finishes,
meaning the system unistd.h was included directly, which is incorrect.

BTW, a branch somewhere with the configure etc. regenerated plus gnulib/import
already imported would have made it _so_ much easier for me to try this.
Can you do that?  As I explained before, that should make it easier
for other people to try on others hosts as well.

> config.status: creating config.h
> 1 error generated.
> make[5]: *** [unistd.o] Error 1
> 
> Also, I’m sure of the fact that gnulib headers are being used because
> all the functions that I’ve replaced from libiberty, I locally removed
> both the .c and .h files from libiberty to confirm that the gnulib’s
> version is indeed being used, and it compiled just fine.

That's most probably because you're replacing libiberty's obstack.h
with gnulib's, and that gnulib header is found in gnulib's _source_
directory, not in the gnulib build directory.

With your current patch, these are the files that are being
generated, and that weren't picked up in the include path (but must be):

 $ find build/gnulib/import/ -name "*.h"
 build/gnulib/import/sys/types.h
 build/gnulib/import/stdlib.h
 build/gnulib/import/arg-nonnull.h
 build/gnulib/import/warn-on-use.h
 build/gnulib/import/c++defs.h
 build/gnulib/import/unistd.h

as more gnulib modules get imported, more headers will appear
here.

> So my understanding of this is that the gnulib.h is also required to
> be included inside bconfig.h?
> 

Yes.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-21 19:41     ` Pedro Alves
@ 2016-08-22 16:36       ` ayush goel
  2016-08-22 16:43         ` Pedro Alves
                           ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: ayush goel @ 2016-08-22 16:36 UTC (permalink / raw)
  To: Joseph Myers, Pedro Alves, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 3062 bytes --]

Updating the patch, contains only changes to the documentation.


PFA the patch





2016-08-22 Ayush Goel <ayushgoel1610@gmail.com>

* Makefile.def: Added gnulib as build & host library and dependency of
all-gcc on gnulib
* Makefile.in: regenerated
* configure.ac: Added gnulib as build and host library
* configure: regenerated
* gcc/Makefile.in: Added path to gnulib static library (libgnu.a) and
gnulib header files
* gcc/mkconfig.sh: Included gnulib’s config.h
* gcc/doc/sourcebuild.texi: Added gnulib and how to use the update
script to update/import gnu lib modules
* gnulib: created directory
* gnulib/Makefile.in: new file
* gnulib/configure.ac: new file
* gnulib/update-gnulib.sh: script to import gnulib modules using gnulib-tool
* gnulib/import: created by update-gnulib.sh
* gnulib/import/Makefile.in: imported from gnulib
* gnulib/import/alignof.h: Imported from gnulib
* gnulib/import/exitfail.c: Imported from gnulib
* gnulib/import/exitfail.h: Imported from gnulib
* gnulib/import/extra: Imported from gnulib
* gnulib/import/extra/snippet: Imported from gnulib
* gnulib/import/extra/snippet/_Noreturn.h: Imported from gnulib
* gnulib/import/extra/snippet/arg-nonnull.h: Imported from gnulib
* gnulib/import/extra/snippet/c++defs.h: Imported from gnulib
* gnulib/import/extra/snippet/warn-on-use.h: Imported from gnulib
* gnulib/import/gettext.h: Imported from gnulib
* gnulib/import/m4: Imported from gnulib
* gnulib/import/m4/00gnulib.m4: Imported from gnulib
* gnulib/import/m4/absolute-header.m4: Imported from gnulib
* gnulib/import/m4/extern-inline.m4: Imported from gnulib
* gnulib/import/m4/gnulib-cache.m4: Imported from gnulib
* gnulib/import/m4/gnulib-common.m4: Imported from gnulib
* gnulib/import/m4/gnulib-comp.m4: Imported from gnulib
* gnulib/import/m4/gnulib-tool.m4: Imported from gnulib
* gnulib/import/m4/include_next.m4: Imported from gnulib
* gnulib/import/m4/longlong.m4: Imported from gnulib
* gnulib/import/m4/multiarch.m4: Imported from gnulib
* gnulib/import/m4/obstack.m4: Imported from gnulib
* gnulib/import/m4/off_t.m4: Imported from gnulib
* gnulib/import/m4/ssize_t.m4: Imported from gnulib
* gnulib/import/m4/stddef_h.m4: Imported from gnulib
* gnulib/import/m4/stdint.m4: Imported from gnulib
* gnulib/import/m4/stdlib_h.m4: Imported from gnulib
* gnulib/import/m4/sys_types_h.m4: Imported from gnulib
* gnulib/import/m4/unistd_h.m4: Imported from gnulib
* gnulib/import/m4/warn-on-use.m4: Imported from gnulib
* gnulib/import/m4/wchar_t.m4: Imported from gnulib
* gnulib/import/obstack.c: Imported from gnulib
* gnulib/import/obstack.h: Imported from gnulib
* gnulib/import/stddef.in.h: Imported from gnulib
* gnulib/import/stdint.in.h: Imported from gnulib
* gnulib/import/stdlib.in.h: Imported from gnulib
* gnulib/import/sys: Imported from gnulib
* gnulib/import/sys_types.in.h: Imported from gnulib
* gnulib/import/unistd.c: Imported from gnulib
* gnulib/import/unistd.in.h: Imported from gnulib
* gnulib/stamp-h1: generated

-Ayush

[-- Attachment #2: importgnulib_8_22.patch --]
[-- Type: application/octet-stream, Size: 22856 bytes --]

Index: src/Makefile.def
===================================================================
--- src/Makefile.def	(revision 237184)
+++ src/Makefile.def	(working copy)
@@ -25,6 +25,7 @@
 // that recursive target in its Makefile.
 
 build_modules= { module= libiberty; };
+build_modules= { module= gnulib; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
@@ -83,6 +84,7 @@
 host_modules= { module= libcpp; bootstrap=true; };
 host_modules= { module= libdecnumber; bootstrap=true; };
 host_modules= { module= libgui; };
+host_modules= { module= gnulib; bootstrap=true; };
 host_modules= { module= libiberty; bootstrap=true;
            extra_configure_flags='@extra_host_libiberty_configure_flags@';};
 // Linker plugins may need their own build of libiberty; see
@@ -338,6 +340,7 @@
 dependencies = { module=all-gcc; on=all-build-texinfo; };
 dependencies = { module=all-gcc; on=all-build-bison; };
 dependencies = { module=all-gcc; on=all-build-flex; };
+dependencies = { module=all-gcc; on=all-build-gnulib; };
 dependencies = { module=all-gcc; on=all-build-libiberty; };
 dependencies = { module=all-gcc; on=all-build-fixincludes; };
 dependencies = { module=all-gcc; on=all-build-libcpp; };
@@ -345,6 +348,7 @@
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
+dependencies=  { module=all-gcc; on=all-gnulib; hard=true; };
 dependencies = { module=all-gcc; on=all-libiberty; };
 dependencies = { module=all-gcc; on=all-fixincludes; };
 dependencies = { module=all-gcc; on=all-lto-plugin; };
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 237184)
+++ src/configure.ac	(working copy)
@@ -125,7 +125,7 @@
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty build-libcpp"
+build_libs="build-libiberty build-libcpp build-gnulib"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
@@ -132,7 +132,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv gnulib"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
Index: src/gcc/Makefile.in
===================================================================
--- src/gcc/Makefile.in	(revision 237184)
+++ src/gcc/Makefile.in	(working copy)
@@ -484,12 +484,14 @@
 
 # Where to find some libiberty headers.
 HASHTAB_H   = $(srcdir)/../include/hashtab.h
-OBSTACK_H   = $(srcdir)/../include/obstack.h
 SPLAY_TREE_H= $(srcdir)/../include/splay-tree.h
 MD5_H	    = $(srcdir)/../include/md5.h
 XREGEX_H    = $(srcdir)/../include/xregex.h
 FNMATCH_H   = $(srcdir)/../include/fnmatch.h
 
+# GNULIB headers
+OBSTACK_H   = $(srcdir)/../gnulib/import/obstack.h
+
 # Linker plugin API headers
 LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 
@@ -1022,18 +1024,23 @@
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
+# Where to find the gnulib library
+LIBGNU = ../gnulib/import/libgnu.a
+BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
+INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import 
+
 # Dependencies on the intl and portability libraries.
-LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
+LIBDEPS= libcommon.a $(CPPLIB) $(LIBGNU) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
 	$(LIBDECNUMBER) $(LIBBACKTRACE)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+BUILD_LIBDEPS= $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
-	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+	$(LIBGNU) $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
 BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
@@ -1048,7 +1055,7 @@
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBS = $(BUILD_LIBIBERTY)
+BUILD_LIBS = $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
 	    build/vec.o build/min-insn-modes.o build/gensupport.o \
@@ -1066,7 +1073,7 @@
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
-	   $(ISLINC)
+	   $(ISLINC) $(INCGNU)
 
 COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
 ifeq ($(CXXDEPMODE),depmode=gcc3)
Index: src/gcc/mkconfig.sh
===================================================================
--- src/gcc/mkconfig.sh (revision 237184)
+++ src/gcc/mkconfig.sh (working copy)
@@ -36,6 +36,10 @@
 hg_sed_expr='y,abcdefghijklmnopqrstuvwxyz./,ABCDEFGHIJKLMNOPQRSTUVWXYZ__,'
 header_guard=GCC_`echo ${output} | sed -e ${hg_sed_expr}`
 
+if test x"$output" = x"bconfig.h"; then
+  echo '#include "../gnulib/config.h"' >> ${output}T
+fi
+
 # Add multiple inclusion protection guard, part one.
 echo "#ifndef ${header_guard}" >> ${output}T
 echo "#define ${header_guard}" >> ${output}T
@@ -46,6 +50,7 @@
   echo "#ifdef GENERATOR_FILE" >> ${output}T
   echo "#error config.h is for the host, not build, machine." >> ${output}T
   echo "#endif" >> ${output}T
+  echo '#include "../gnulib/config.h"' >> ${output}T
 fi
 
 # Define TARGET_CPU_DEFAULT if the system wants one. 
Index: src/gnulib/Makefile.in
===================================================================
--- src/gnulib/Makefile.in	(nonexistent)
+++ src/gnulib/Makefile.in	(working copy)
@@ -0,0 +1,290 @@
+# Copyright (C) 1989-2016 Free Software Foundation, Inc.
+
+# This file is part of GCC.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+localedir = @localedir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+includedir = @includedir@
+
+SHELL = @SHELL@
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DESTDIR =
+
+AR = @AR@
+AR_FLAGS = qv
+RANLIB = @RANLIB@
+DLLTOOL = @DLLTOOL@
+
+SUBDIRS = import
+CLEANDIRS = $(SUBDIRS)
+REQUIRED_SUBDIRS = $(SUBDIRS)
+
+# If you are compiling with GCC, make sure that either 1) You have the
+# fixed include files where GCC can reach them, or 2) You use the
+# -traditional flag.  Otherwise the ioctl calls in inflow.c
+# will be incorrectly compiled.  The "fixincludes" script in the gcc
+# distribution will fix your include files up.
+CC=@CC@
+
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC_LD=$(CC)
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+
+FLAGS_TO_PASS = \
+	"prefix=$(prefix)" \
+	"exec_prefix=$(exec_prefix)" \
+	"infodir=$(infodir)" \
+	"datarootdir=$(datarootdir)" \
+	"docdir=$(docdir)" \
+	"htmldir=$(htmldir)" \
+	"pdfdir=$(pdfdir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
+	"against=$(against)" \
+	"DESTDIR=$(DESTDIR)" \
+	"AR=$(AR)" \
+	"AR_FLAGS=$(AR_FLAGS)" \
+	"CC=$(CC)" \
+	"CFLAGS=$(CFLAGS)" \
+	"CXX=$(CXX)" \
+	"CXXFLAGS=$(CXXFLAGS)" \
+	"DLLTOOL=$(DLLTOOL)" \
+	"LDFLAGS=$(LDFLAGS)" \
+	"RANLIB=$(RANLIB)" \
+	"MAKEINFO=$(MAKEINFO)" \
+	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
+	"MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \
+	"MAKEHTML=$(MAKEHTML)" \
+	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
+	"INSTALL=$(INSTALL)" \
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+	"INSTALL_DATA=$(INSTALL_DATA)" \
+	"RUNTEST=$(RUNTEST)" \
+	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
+
+all installcheck check info install-info clean-info dvi pdf install-pdf html install-html: force
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all
+	@$(MAKE) $(FLAGS_TO_PASS) install-only
+
+install-only: $(CONFIG_INSTALL)
+	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+uninstall: force $(CONFIG_UNINSTALL)
+	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+# Convenience rule to handle recursion.
+$(LIBGNU) $(GNULIB_H): all-lib
+all-lib: import/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=import subdir_do
+.PHONY: all-lib
+
+clean mostlyclean: $(CONFIG_CLEAN)
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
+
+distclean: clean
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
+	rm -f config.status config.h stamp-h
+	rm -f config.log config.cache
+	rm -f Makefile
+	rm -rf $(DEPDIR)
+
+maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
+realclean: maintainer-clean
+
+local-maintainer-clean:
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f config.status
+
+do-maintainer-clean:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
+		subdir_do
+
+subdir_do: force
+	@for i in $(DODIRS); do \
+		case $$i in \
+		$(REQUIRED_SUBDIRS)) \
+			if [ ! -f ./$$i/Makefile ] ; then \
+				echo "Missing $$i/Makefile" >&2 ; \
+				exit 1 ; \
+			fi ;; \
+		esac ; \
+		if [ -f ./$$i/Makefile ] ; then \
+			if (cd ./$$i; \
+				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
+			else exit 1 ; fi ; \
+		else true ; fi ; \
+	done
+
+Makefile: Makefile.in config.status
+	# Regenerate the Makefile.
+	CONFIG_FILES="Makefile" \
+	  CONFIG_COMMANDS= \
+	  CONFIG_HEADERS= \
+	  $(SHELL) config.status
+
+gnulib/Makefile: gnulib/Makefile.in config.status
+	CONFIG_FILES="gnulib/Makefile" \
+	  CONFIG_COMMANDS="depfiles" \
+	  CONFIG_HEADERS= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.h: stamp-h ; @true
+stamp-h: $(srcdir)/config.in config.status
+	CONFIG_HEADERS=config.h:config.in \
+	  CONFIG_COMMANDS="default depdir" \
+	  CONFIG_FILES= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.status: $(srcdir)/configure
+	$(SHELL) config.status --recheck
+
+ACLOCAL = aclocal
+ACLOCAL_AMFLAGS = -I import/m4 -I ../../config
+aclocal_m4_deps = \
+	configure.ac \
+	import/m4/00gnulib.m4 \
+	import/m4/alloca.m4 \
+	import/m4/codeset.m4 \
+	import/m4/configmake.m4 \
+	import/m4/extensions.m4 \
+	import/m4/fcntl-o.m4 \
+	import/m4/fnmatch.m4 \
+	import/m4/glibc21.m4 \
+	import/m4/gnulib-cache.m4 \
+	import/m4/gnulib-common.m4 \
+	import/m4/gnulib-comp.m4 \
+	import/m4/gnulib-tool.m4 \
+	import/m4/include_next.m4 \
+	import/m4/inttypes-pri.m4 \
+	import/m4/inttypes.m4 \
+	import/m4/localcharset.m4 \
+	import/m4/locale-fr.m4 \
+	import/m4/locale-ja.m4 \
+	import/m4/locale-zh.m4 \
+	import/m4/longlong.m4 \
+	import/m4/mbrtowc.m4 \
+	import/m4/mbsinit.m4 \
+	import/m4/mbsrtowcs.m4 \
+	import/m4/mbstate_t.m4 \
+	import/m4/memchr.m4 \
+	import/m4/memmem.m4 \
+	import/m4/mmap-anon.m4 \
+	import/m4/multiarch.m4 \
+	import/m4/off_t.m4 \
+	import/m4/pathmax.m4 \
+	import/m4/ssize_t.m4 \
+	import/m4/stdbool.m4 \
+	import/m4/stddef_h.m4 \
+	import/m4/stdint.m4 \
+	import/m4/obstack.m4 \
+	import/m4/strtok_r.m4 \
+	import/m4/sys_types_h.m4 \
+	import/m4/unistd_h.m4 \
+	import/m4/warn-on-use.m4 \
+	import/m4/wchar_h.m4 \
+	import/m4/wchar_t.m4 \
+	import/m4/wctype_h.m4 \
+	import/m4/wint_t.m4
+
+$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+AUTOCONF = autoconf
+configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+
+AUTOHEADER = autoheader
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h
+	touch $@
+
+# automatic rebuilding in automake-generated Makefiles requires
+# this rule in the toplevel Makefile, which, with GNU make, causes
+# the desired updates through the implicit regeneration of the Makefile
+# and all of its prerequisites.
+am--refresh:
+	@:
+
+force:
+
+force_update:
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+### end of the libgnu Makefile.in.
Index: src/gnulib/configure.ac
===================================================================
--- src/gnulib/configure.ac	(nonexistent)
+++ src/gnulib/configure.ac	(working copy)
@@ -0,0 +1,60 @@
+dnl Autoconf configure script for GCC.
+dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.64)dnl
+AC_INIT()
+AC_CONFIG_HEADER(config.h:config.in)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
+gl_EARLY
+AM_PROG_CC_STDC
+
+AC_CONFIG_AUX_DIR(..)
+AC_CANONICAL_SYSTEM
+
+gl_INIT
+
+# Gnulib uses automake.  This line lets gcc generate
+# its Makefile.in.
+AM_INIT_AUTOMAKE(libgnu, UNUSED-VERSION, [no-define])
+
+# --------------------- #
+# Checks for programs.  #
+# --------------------- #
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+
+AC_CHECK_TOOL(AR, ar)
+
+# ---------------------- #
+# Checks for libraries.  #
+# ---------------------- #
+
+AC_OUTPUT(Makefile import/Makefile,
+[
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
+
+exit 0
Index: src/gnulib/update-gnulib.sh
===================================================================
--- src/gnulib/update-gnulib.sh	(nonexistent)
+++ src/gnulib/update-gnulib.sh	(working copy)
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Copyright (C) 2011-2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-gnulib.sh <path-to-gnulib-repository>
+# Update our import of gnulib in the GCC source tree.
+#
+# This script assumes that it is being called from the gcc/gnulib
+# subdirectory.
+#
+# This script will also make a number of other verifications:
+#   . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
+#   . The correct versions of the auto-tools that are used to
+#     regenerate the various scripts and Makefiles are on the PATH.
+
+# The list of gnulib modules we are importing in GCC.
+IMPORTED_GNULIB_MODULES="\
+    obstack \
+"
+
+# The gnulib commit ID to use for the update.
+GNULIB_COMMIT_SHA1="1029a8112290f6eee9d7878a391c49db42c999bd"
+
+# The expected version number for the various auto tools we will
+# use after the import.
+AUTOCONF_VERSION="2.69"
+AUTOMAKE_VERSION="1.15"
+ACLOCAL_VERSION="$AUTOMAKE_VERSION"
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to gnulib repository missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
+   exit 1
+fi
+gnulib_prefix=$1
+
+gnulib_tool="$gnulib_prefix/gnulib-tool"
+
+# Verify that the gnulib directory does exist...
+if [ ! -f "$gnulib_tool" ]; then
+   echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
+   echo "       ($gnulib_tool)."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the right version of gnulib...
+gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
+if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
+   echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
+   echo "       (we expected it to be $GNULIB_COMMIT_SHA1)"
+   echo "Aborting."
+   exit 1
+fi
+
+ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOCONF_VERSION" ]; then
+   echo "Error: Wrong autoconf version: $ver. Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of automake.
+ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
+   echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of aclocal.
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$ACLOCAL_VERSION" ]; then
+   echo "Error: Wrong aclocal version: $ver. Aborting."
+   exit 1
+fi
+
+# Update our gnulib import.
+$gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
+  --source-base=import --m4-base=import/m4 --doc-base=doc \
+  --tests-base=tests --aux-dir=import/extra \
+  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
+  --no-vc-files \
+  $IMPORTED_GNULIB_MODULES
+if [ $? -ne 0 ]; then
+   echo "Error: gnulib import failed.  Aborting."
+   exit 1
+fi
+
+# Regenerate all necessary files...
+aclocal -Iimport/m4 &&
+autoconf &&
+autoheader &&
+automake
+if [ $? -ne 0 ]; then
+   echo "Error: Failed to regenerate Makefiles and configure scripts."
+   exit 1
+fi
+

Property changes on: src/gnulib/update-gnulib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/gcc/doc/sourcebuild.texi
===================================================================
--- src/gcc/doc/sourcebuild.texi	(revision 237184)
+++ src/gcc/doc/sourcebuild.texi	(working copy)
@@ -97,6 +97,22 @@
 Introduction, libiberty, @sc{gnu} libiberty}, for more information
 about this library.
 
+@item libgnu
+Gnulib - The GNU portability library
+To facilitate the update/import of gnulib, a script called 
+@file{update-gnulib.sh} (resides at @file{src/gnulib/update-gnulib.sh} ) has 
+been created to automate the process.
+@smallexample
+Usage: update-gnulib.sh @var{path-to-gnulib-repository} 
+@end smallexample

+The script maintains the two key pieces of information from which the import is
+created as constants defined inside the script:
+@itemize @bullet
+@item
+@var{GNULIB_COMMIT_SHA1} is the commit from the @code{gnulib} respository  to 
+be used for the import. In order to update gnulib, replace this value with that 
+of the newer version and run the script.
+
+@item
+@var{IMPORTED_GNULIB_MODULES} specifies which modules to import from gnulib. 
+Add a new module to this list in order to import it to GCC and run the script. 
+
+@end itemize
+When updating the import, please only modify one element at a time. For 
+instance, if you want to import a new module only defined in a later version of
+@code{gnulib}, please first update the import to use the newer commit as a first 
+patch, and then update the import to include the new module as a second patch.
+
 @item libitm
 The runtime support library for transactional memory.
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-22 16:36       ` ayush goel
@ 2016-08-22 16:43         ` Pedro Alves
  2016-08-28 18:55           ` ayush goel
  2016-08-22 17:41         ` Joseph Myers
  2016-08-22 18:48         ` Pedro Alves
  2 siblings, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-22 16:43 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 08/22/2016 05:36 PM, ayush goel wrote:
> +# The expected version number for the various auto tools we will
> +# use after the import.
> +AUTOCONF_VERSION="2.69"
> +AUTOMAKE_VERSION="1.15"
> +ACLOCAL_VERSION="$AUTOMAKE_VERSION"
> +

Is there a reason these need to be different from what the rest
of the toolchain uses?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-22 16:36       ` ayush goel
  2016-08-22 16:43         ` Pedro Alves
@ 2016-08-22 17:41         ` Joseph Myers
  2016-08-22 18:48         ` Pedro Alves
  2 siblings, 0 replies; 33+ messages in thread
From: Joseph Myers @ 2016-08-22 17:41 UTC (permalink / raw)
  To: ayush goel
  Cc: Pedro Alves, Manuel López-Ibáñez, Gcc Patch List,
	Jeff Law

You appear to be including ../gnulib/config.h for both host and build.  
That can't be right when host and build are different.  In that case you 
need to include config.h from the correct build directory in each case.  
You also need to arrange for BUILD_CPPFLAGS to have the right -I options 
for gnulib for the build system.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-22 16:36       ` ayush goel
  2016-08-22 16:43         ` Pedro Alves
  2016-08-22 17:41         ` Joseph Myers
@ 2016-08-22 18:48         ` Pedro Alves
  2 siblings, 0 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-22 18:48 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

I noticed that libcpp/include/symtab.h includes
obstack.h and puts a struct obstack in an exported structure:

/* An identifier hash table for cpplib and the front ends.  */
struct ht
{
  /* Identifiers are allocated from here.  */
  struct obstack stack;
[...]
typedef struct ht cpp_hash_table;
[...]

and then this structure is used in both libcpp/ and 
gcc/ (i.e., not opaque to gcc).  E.g.,:

../gcc/stringpool.c:66:  ident_hash = ht_create (14);
../gcc/stringpool.c:67:  ident_hash->alloc_node = alloc_node;
../gcc/stringpool.c:68:  ident_hash->alloc_subobject = stringpool_ggc_alloc;


Since libcpp is configure/built as a separate library, and, it
uses libiberty, this looks like a potential binary incompatibility.
I.e., gcc/ sees one obstack definition, while libcpp sees another.

I think that in practice the definitions end up being the same
currently, as IIRC, Alan made sure to sync obstack.h between
glibc / libiberty / gnulib's when he added the 64-bit support
a while ago.

In any case, it's quite possible that other incompatibilities will
happen with other modules.  I think the proper fix would be to
adjust libcpp/Makefile.in to include headers from gnulib too sooner
than later.

libcc1/ is probably on the same boat.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-22 16:43         ` Pedro Alves
@ 2016-08-28 18:55           ` ayush goel
  2016-08-29 11:30             ` Joseph Myers
  0 siblings, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-08-28 18:55 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Pedro Alves, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

-Ayush

On 22 August 2016 at 10:13:40 PM, Pedro Alves (palves@redhat.com) wrote:
> On 08/22/2016 05:36 PM, ayush goel wrote:
> > +# The expected version number for the various auto tools we will
> > +# use after the import.
> > +AUTOCONF_VERSION="2.69"
> > +AUTOMAKE_VERSION="1.15"
> > +ACLOCAL_VERSION="$AUTOMAKE_VERSION"
> > +
>
> Is there a reason these need to be different from what the rest
> of the toolchain uses?

Not really, these were just the newer version.
On the other hand is there a specific reason we are using older
versions of these tools, despite newer versions being available.
>
> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-28 18:55           ` ayush goel
@ 2016-08-29 11:30             ` Joseph Myers
  0 siblings, 0 replies; 33+ messages in thread
From: Joseph Myers @ 2016-08-29 11:30 UTC (permalink / raw)
  To: ayush goel
  Cc: Manuel López-Ibáñez, Pedro Alves, Gcc Patch List,
	Jeff Law

On Sun, 28 Aug 2016, ayush goel wrote:

> > > +AUTOCONF_VERSION="2.69"
> > > +AUTOMAKE_VERSION="1.15"
> > > +ACLOCAL_VERSION="$AUTOMAKE_VERSION"
> > > +
> >
> > Is there a reason these need to be different from what the rest
> > of the toolchain uses?
> 
> Not really, these were just the newer version.
> On the other hand is there a specific reason we are using older
> versions of these tools, despite newer versions being available.

Upgrading and testing in a range of different configurations, for all the 
packages sharing the toplevel code, is quite tricky (though it's libtool 
that's the most problematic and where we know that on any upgrade we need 
to revert a libtool change for sysroot handling that conflicts with GCC 
sysroot handling).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 17:51                           ` ayush goel
@ 2016-08-10 17:58                             ` Pedro Alves
  0 siblings, 0 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 17:58 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 08/10/2016 06:51 PM, ayush goel wrote:
> On 10 August 2016 at 11:19:42 PM, Pedro Alves (palves@redhat.com) wrote:
>> On 08/10/2016 06:33 PM, ayush goel wrote:
>>
>>> I can see mkconfig.sh being invoked inside gcc/Makefile.in with
>>> different arguments to create the gcc header files (config.h etc).
>>> So I guess IÂ’ll copy all the definitions from gnulib/config.h inside
>>> mkconfig.sh and try and test the system.
>>
>> What do you mean by "copy all the definitions" ?
>>
>> All you should need is add '#include "gnulib/config.h"' to
>> the generated gcc/config.h.
>>
> Yes copy the file containing the definitions*

That's a funny and confusing definition of copy.  :-)

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 17:49                         ` Pedro Alves
@ 2016-08-10 17:51                           ` ayush goel
  2016-08-10 17:58                             ` Pedro Alves
  0 siblings, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-08-10 17:51 UTC (permalink / raw)
  To: Joseph Myers, Pedro Alves, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 10 August 2016 at 11:19:42 PM, Pedro Alves (palves@redhat.com) wrote:
> On 08/10/2016 06:33 PM, ayush goel wrote:
>
> > I can see mkconfig.sh being invoked inside gcc/Makefile.in with
> > different arguments to create the gcc header files (config.h etc).
> > So I guess I’ll copy all the definitions from gnulib/config.h inside
> > mkconfig.sh and try and test the system.
>
> What do you mean by "copy all the definitions" ?
>
> All you should need is add '#include "gnulib/config.h"' to
> the generated gcc/config.h.
>
Yes copy the file containing the definitions*

> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 17:33                       ` ayush goel
@ 2016-08-10 17:49                         ` Pedro Alves
  2016-08-10 17:51                           ` ayush goel
  0 siblings, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 17:49 UTC (permalink / raw)
  To: ayush goel, Manuel López-Ibáñez, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

On 08/10/2016 06:33 PM, ayush goel wrote:

> I can see mkconfig.sh being invoked inside gcc/Makefile.in with
> different arguments to create the gcc header files (config.h etc).
> So I guess IÂ’ll copy all the definitions from gnulib/config.h inside
> mkconfig.sh and try and test the system.

What do you mean by "copy all the definitions" ?

All you should need is add '#include "gnulib/config.h"' to
the generated gcc/config.h.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 16:52                     ` Pedro Alves
@ 2016-08-10 17:33                       ` ayush goel
  2016-08-10 17:49                         ` Pedro Alves
  0 siblings, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-08-10 17:33 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Pedro Alves, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

> # auto-host.h is the file containing items generated by autoconf and is
> # the first file included by config.h.
> # If host=build, it is correct to have bconfig include auto-host.h
> # as well. If host!=build, we are in error and need to do more
> # work to find out the build config parameters.
> if test x$host = x$build
> then
> build_auto=auto-host.h
> else
>
> So it sounds like you could include gnulib's config.h from within
> gcc's config.h directly. Looks like that file is generated
> by src/gcc/mkconfig.sh, so that's what you'd patch.

Thanks for the pointers, really insightful.

I can see mkconfig.sh being invoked inside gcc/Makefile.in with
different arguments to create the gcc header files (config.h etc).
So I guess I’ll copy all the definitions from gnulib/config.h inside
mkconfig.sh and try and test the system.

>
> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 16:31                   ` ayush goel
@ 2016-08-10 16:52                     ` Pedro Alves
  2016-08-10 17:33                       ` ayush goel
  0 siblings, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 16:52 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 08/10/2016 05:31 PM, ayush goel wrote:
> On 10 August 2016 at 7:36:41 PM, Pedro Alves (palves@redhat.com) wrote:

> So I was getting the exact same error as above and that is precisely
> why I included "-I../gnulib” in the include path. I figured the
> compiler wasnÂ’t able to find config.h and hence has to be pointed to
> the right path.
> 
> Excuse my limited understanding of the system, but the compiler seems
> to already require config.h while building, and therefore doesnÂ’t
> having “-I../gnulib” solve the problem?
> Why should I remove this from the path and instead have “#include
> config.h” inside every function of gcc using gnulib.
> Any explanation would be sincerely appreciated.

Puzzling how that didn't cause other problems for you.

Because:

- we end up with two different config.h files:

  build/gcc/config.h
  build/gnulib/config.h

- #include "config.h"' will pick one or the other, but not both.

- we need to include both.


Now, now that I look at gcc's config.h, it doesn't look like that
is the standard config.h file autogenerated from config.in at all.
Ah.  It's a custom file.  The one generated from gcc/config.in is
build/gcc/auto-host.h.  From configure.ac:

 # auto-host.h is the file containing items generated by autoconf and is
 # the first file included by config.h.
 # If host=build, it is correct to have bconfig include auto-host.h
 # as well.  If host!=build, we are in error and need to do more 
 # work to find out the build config parameters.
 if test x$host = x$build
 then
 	build_auto=auto-host.h
 else

So it sounds like you could include gnulib's config.h from within
gcc's config.h directly.  Looks like that file is generated
by src/gcc/mkconfig.sh, so that's what you'd patch.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 14:06                 ` Pedro Alves
  2016-08-10 14:25                   ` Pedro Alves
@ 2016-08-10 16:31                   ` ayush goel
  2016-08-10 16:52                     ` Pedro Alves
  1 sibling, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-08-10 16:31 UTC (permalink / raw)
  To: Joseph Myers, Pedro Alves, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 10 August 2016 at 7:36:41 PM, Pedro Alves (palves@redhat.com) wrote:
> On 08/10/2016 02:40 PM, ayush goel wrote:
> > On 9 August 2016 at 2:20:59 PM, Pedro Alves (palves@redhat.com) wrote:
>
> > I wasn’t aware of this. Thanks for pointing this out.
> > It’s strange however, I didn’t see anything failing while
> > building/testing my system.
>
> If I comment out the include on gdb, here's what I get:
>
> g++ -g3 -O0 -I. -I/home/pedro/gdb/mygit/src/gdb -I/home/pedro/gdb/mygit/src/gdb/common
> -I/home/pedro/gdb/mygit/src/gdb/config -DLOCALEDIR="\"/opt/gdb/share/locale\""
> -DHAVE_CONFIG_H -I/home/pedro/gdb/mygit/src/gdb/../include/opcode -I/home/pedro/gdb/mygit/src/gdb/../opcodes/..
> -I/home/pedro/gdb/mygit/src/gdb/../readline/.. -I/home/pedro/gdb/mygit/src/gdb/../zlib
> -I../bfd -I/home/pedro/gdb/mygit/src/gdb/../bfd -I/home/pedro/gdb/mygit/src/gdb/../include
> -I../libdecnumber -I/home/pedro/gdb/mygit/src/gdb/../libdecnumber -I/home/pedro/gdb/mygit/src/gdb/gnulib/import
> -Ibuild-gnulib/import -DTUI=1 -pthread -I/usr/include/guile/2.0 -I/usr/include/python3.4m
> -I/usr/include/python3.4m -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function
> -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable
> -Wno-sign-compare -Wno-write-strings -Wno-narrowing -Wformat-nonliteral -Werror
> -c -o gdb.o -MT gdb.o -MMD -MP -MF .deps/gdb.Tpo /home/pedro/gdb/mygit/src/gdb/gdb.c
> In file included from /home/pedro/gdb/mygit/src/gdb/gnulib/import/pathmax.h:42:0,
> from /home/pedro/gdb/mygit/src/gdb/common/common-defs.h:67,
> from /home/pedro/gdb/mygit/src/gdb/defs.h:28,
> from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
> build-gnulib/import/unistd.h:135:3: error: #error "Please include config.h first."
> #error "Please include config.h first."
> ^
> In file included from /home/pedro/gdb/mygit/src/gdb/gdb_wchar.h:53:0,
> from /home/pedro/gdb/mygit/src/gdb/defs.h:51,
> from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
> build-gnulib/import/wctype.h:66:3: error: #error "Please include config.h first."
> #error "Please include config.h first."
> ^
> In file included from /home/pedro/gdb/mygit/src/gdb/gnulib/import/pathmax.h:42:0,
> from /home/pedro/gdb/mygit/src/gdb/common/common-defs.h:67,
> from /home/pedro/gdb/mygit/src/gdb/defs.h:28,
> from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
> build-gnulib/import/unistd.h:137:1: error: ‘_GL_INLINE_HEADER_BEGIN’ does not
> name a type
> _GL_INLINE_HEADER_BEGIN
> ^
> build-gnulib/import/unistd.h:1894:1: error: ‘_GL_INLINE_HEADER_END’ does not
> name a type
> _GL_INLINE_HEADER_END
> ^
> In file included from /home/pedro/gdb/mygit/src/gdb/gdb_wchar.h:53:0,
> from /home/pedro/gdb/mygit/src/gdb/defs.h:51,
> from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
> build-gnulib/import/wctype.h:68:1: error: ‘_GL_INLINE_HEADER_BEGIN’ does not
> name a type
> _GL_INLINE_HEADER_BEGIN
> ^
>
> > It’s strange however, I didn’t see anything failing while
> > building/testing my system.
>
> You're pulling in the unistd.h replacement module, and from above,
> we see that that replacement header should trip on this.
>
> I think the reason you don't trip on this, is here:
>
> > +INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>
> Specifically, the "-I../gnulib" part. That looks wrong.
>
> Here's what the gnulib build directory looks like on a gdb
> build:
>
> $ cd build/gdb/build-gnulib
> $ ls
> import config.cache config.h config.log config.status Makefile stamp-h1
> $ ls import/
> sys dirent.h math.h string.h wchar.h
> alloca.h dirname-lgpl.o math.o stripslash.o wctype.h
> arg-nonnull.h inttypes.h ref-add.sed strnlen1.o wctype-h.o
> basename-lgpl.o libgnu.a ref-del.sed time.h
> c++defs.h localcharset.o signal.h unistd.h
> charset.alias Makefile stdio.h unistd.o
> configmake.h malloca.o stdlib.h warn-on-use.h
>
> So you want to point -I at these generated, replacement headers, not
> the gnulib build dir root, which in gcc is simply gnulib/ instead of
> build-gnulib/.
>
> So again, here:
>
> > +INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>
> "-I../gnulib" should instead be "-I../gnulib/import" to put gnulib's
> generated replacement headers in the include path.
>
> And then you should trip on the problem. And you'll make gnulib's
> replacement headers actually replace something. :-)
>
> Assuming I'm right, that is.

So I was getting the exact same error as above and that is precisely
why I included "-I../gnulib” in the include path. I figured the
compiler wasn’t able to find config.h and hence has to be pointed to
the right path.

Excuse my limited understanding of the system, but the compiler seems
to already require config.h while building, and therefore doesn’t
having “-I../gnulib” solve the problem?
Why should I remove this from the path and instead have “#include
config.h” inside every function of gcc using gnulib.
Any explanation would be sincerely appreciated.
> > Can gcc also adopt a similar approach? Include gnulib’s config.h in a
> > single header file instead of including it in every function that uses
> > it.
> > Which header file would be the most suitable for this purpose(probably
> > which is generically included by almost all the gcc functions)?
>
> I think "system.h" would be the most suitable. It's already included
> everywhere first thing. The gen* stuff might need something special.
>
> Since you're problably going to use sed to patch the files, including
> some new file instead of config.h should be about the same work.
>
> Up to gcc maintainers to decide.
I’ll try the above changes and test my system.
>
> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 14:06                 ` Pedro Alves
@ 2016-08-10 14:25                   ` Pedro Alves
  2016-08-10 16:31                   ` ayush goel
  1 sibling, 0 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 14:25 UTC (permalink / raw)
  To: Pedro Alves, ayush goel, Manuel López-Ibáñez,
	Joseph Myers
  Cc: Gcc Patch List, Jeff Law

On 08/10/2016 03:06 PM, Pedro Alves wrote:

> Since you're problably going to use sed to patch the files, including
> some new file instead of config.h should be about the same work.

Note, above I was assuming that if you include the gnulib config.h file
in system.h, then you're going to move the inclusion of gcc's own
config.h to system.h as well, to keep the inclusions nicely together, like
gdb does.  Obviously if you leave gcc's config.h inclusions where
they are, then it's a smaller patch.  Maybe start with just changing
system.h, and leave removing all the current config.h inclusions
to a separate pass later (but not never).

> Up to gcc maintainers to decide.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 14:05                 ` Manuel López-Ibáñez
@ 2016-08-10 14:14                   ` Pedro Alves
  0 siblings, 0 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 14:14 UTC (permalink / raw)
  To: Manuel López-Ibáñez, ayush goel
  Cc: Joseph Myers, Gcc Patch List, Jeff Law

On 08/10/2016 03:05 PM, Manuel López-Ibáñez wrote:
> On 10 August 2016 at 14:40, ayush goel <ayushgoel1610@gmail.com> wrote:
>> On 9 August 2016 at 2:20:59 PM, Pedro Alves (palves@redhat.com) wrote:
>>> the scheme of configuring gnulib in a separate directory as borrowed from gdb
>>> requires including two config.h headers -- the gnulib client's, and gnulib's.
> 
> Isn't this also true for libiberty's config.h ? I have no idea
> when/how is that included.

Nope.  For libiberty, the current scheme is that all clients of libiberty
duplicate the necessary autoconf checks on their own, so the client's
config.h file ends up with a copy the necessary HAVE_FOOs.

For libiberty, I've tried to factor out the autoconf checks, here:

 https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00580.html

Ended up being gdb-only:

 https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01712.html

src/intl takes yet another approach.  See src/intl/config.intl.in.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 13:40               ` ayush goel
  2016-08-10 14:05                 ` Manuel López-Ibáñez
@ 2016-08-10 14:06                 ` Pedro Alves
  2016-08-10 14:25                   ` Pedro Alves
  2016-08-10 16:31                   ` ayush goel
  1 sibling, 2 replies; 33+ messages in thread
From: Pedro Alves @ 2016-08-10 14:06 UTC (permalink / raw)
  To: ayush goel, Manuel López-Ibáñez, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

On 08/10/2016 02:40 PM, ayush goel wrote:
> On 9 August 2016 at 2:20:59 PM, Pedro Alves (palves@redhat.com) wrote:

> I wasn’t aware of this. Thanks for pointing this out.
> It’s strange however, I didn’t see anything failing while
> building/testing my system.

If I comment out the include on gdb, here's what I get:

g++ -g3 -O0   -I. -I/home/pedro/gdb/mygit/src/gdb -I/home/pedro/gdb/mygit/src/gdb/common -I/home/pedro/gdb/mygit/src/gdb/config -DLOCALEDIR="\"/opt/gdb/share/locale\"" -DHAVE_CONFIG_H -I/home/pedro/gdb/mygit/src/gdb/../include/opcode -I/home/pedro/gdb/mygit/src/gdb/../opcodes/.. -I/home/pedro/gdb/mygit/src/gdb/../readline/.. -I/home/pedro/gdb/mygit/src/gdb/../zlib -I../bfd -I/home/pedro/gdb/mygit/src/gdb/../bfd -I/home/pedro/gdb/mygit/src/gdb/../include -I../libdecnumber -I/home/pedro/gdb/mygit/src/gdb/../libdecnumber  -I/home/pedro/gdb/mygit/src/gdb/gnulib/import -Ibuild-gnulib/import   -DTUI=1   -pthread -I/usr/include/guile/2.0  -I/usr/include/python3.4m -I/usr/include/python3.4m -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-write-strings -Wno-narrowing -Wformat-nonliteral -Werror -c -o gdb.o -MT gdb.o -MMD -MP -MF .deps/gdb.Tpo /home/pedro/gdb/mygit/src/gdb/gdb.c
In file included from /home/pedro/gdb/mygit/src/gdb/gnulib/import/pathmax.h:42:0,
                 from /home/pedro/gdb/mygit/src/gdb/common/common-defs.h:67,
                 from /home/pedro/gdb/mygit/src/gdb/defs.h:28,
                 from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
build-gnulib/import/unistd.h:135:3: error: #error "Please include config.h first."
  #error "Please include config.h first."
   ^
In file included from /home/pedro/gdb/mygit/src/gdb/gdb_wchar.h:53:0,
                 from /home/pedro/gdb/mygit/src/gdb/defs.h:51,
                 from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
build-gnulib/import/wctype.h:66:3: error: #error "Please include config.h first."
  #error "Please include config.h first."
   ^
In file included from /home/pedro/gdb/mygit/src/gdb/gnulib/import/pathmax.h:42:0,
                 from /home/pedro/gdb/mygit/src/gdb/common/common-defs.h:67,
                 from /home/pedro/gdb/mygit/src/gdb/defs.h:28,
                 from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
build-gnulib/import/unistd.h:137:1: error: ‘_GL_INLINE_HEADER_BEGIN’ does not name a type
 _GL_INLINE_HEADER_BEGIN
 ^
build-gnulib/import/unistd.h:1894:1: error: ‘_GL_INLINE_HEADER_END’ does not name a type
 _GL_INLINE_HEADER_END
 ^
In file included from /home/pedro/gdb/mygit/src/gdb/gdb_wchar.h:53:0,
                 from /home/pedro/gdb/mygit/src/gdb/defs.h:51,
                 from /home/pedro/gdb/mygit/src/gdb/gdb.c:19:
build-gnulib/import/wctype.h:68:1: error: ‘_GL_INLINE_HEADER_BEGIN’ does not name a type
 _GL_INLINE_HEADER_BEGIN
 ^

> It’s strange however, I didn’t see anything failing while
> building/testing my system.

You're pulling in the unistd.h replacement module, and from above,
we see that that replacement header should trip on this.

I think the reason you don't trip on this, is here:

> +INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import

Specifically, the "-I../gnulib" part.  That looks wrong.

Here's what the gnulib build directory looks like on a gdb
build:

$ cd build/gdb/build-gnulib
$ ls
import  config.cache  config.h  config.log  config.status  Makefile  stamp-h1
$ ls import/
sys              dirent.h        math.h       string.h       wchar.h
alloca.h         dirname-lgpl.o  math.o       stripslash.o   wctype.h
arg-nonnull.h    inttypes.h      ref-add.sed  strnlen1.o     wctype-h.o
basename-lgpl.o  libgnu.a        ref-del.sed  time.h
c++defs.h        localcharset.o  signal.h     unistd.h
charset.alias    Makefile        stdio.h      unistd.o
configmake.h     malloca.o       stdlib.h     warn-on-use.h

So you want to point -I at these generated, replacement headers, not
the gnulib build dir root, which in gcc is simply gnulib/ instead of
build-gnulib/.

So again, here:

> +INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import

"-I../gnulib" should instead be "-I../gnulib/import" to put gnulib's
generated replacement headers in the include path.

And then you should trip on the problem.  And you'll make gnulib's
replacement headers actually replace something.  :-)

Assuming I'm right, that is.

> Can gcc also adopt a similar approach? Include gnulib’s config.h in a
> single header file instead of including it in every function that uses
> it.
> Which header file would be the most suitable for this purpose(probably
> which is generically included by almost all the gcc functions)?

I think "system.h" would be the most suitable.  It's already included
everywhere first thing.  The gen* stuff might need something special.

Since you're problably going to use sed to patch the files, including
some new file instead of config.h should be about the same work.

Up to gcc maintainers to decide.

Thanks,
Pedro Alves


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-10 13:40               ` ayush goel
@ 2016-08-10 14:05                 ` Manuel López-Ibáñez
  2016-08-10 14:14                   ` Pedro Alves
  2016-08-10 14:06                 ` Pedro Alves
  1 sibling, 1 reply; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-08-10 14:05 UTC (permalink / raw)
  To: ayush goel; +Cc: Pedro Alves, Joseph Myers, Gcc Patch List, Jeff Law

On 10 August 2016 at 14:40, ayush goel <ayushgoel1610@gmail.com> wrote:
> On 9 August 2016 at 2:20:59 PM, Pedro Alves (palves@redhat.com) wrote:
>> the scheme of configuring gnulib in a separate directory as borrowed from gdb
>> requires including two config.h headers -- the gnulib client's, and gnulib's.

Isn't this also true for libiberty's config.h ? I have no idea
when/how is that included.

>> Did you do something different that avoids needing that somehow?
>
> I wasn’t aware of this. Thanks for pointing this out.
> It’s strange however, I didn’t see anything failing while
> building/testing my system.
>>
>> In gdb, .c files don't include "config.h" directly. Instead all .c files
>> include a "defs.h" file first thing, and that in turn (after another indirection)
>> is what includes both gdb's "config.h" and gnulib's "config.h”:
>
> Can gcc also adopt a similar approach? Include gnulib’s config.h in a
> single header file instead of including it in every function that uses
> it.
> Which header file would be the most suitable for this purpose(probably
> which is generically included by almost all the gcc functions)?

Unfortunately, gcc/*.c include config.h directly. Sorry, I'm not
really sure how this is supposed to work and how it was working for
libiberty's config.h but I'd suggest to copy that if possible.

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-09  8:51             ` Pedro Alves
@ 2016-08-10 13:40               ` ayush goel
  2016-08-10 14:05                 ` Manuel López-Ibáñez
  2016-08-10 14:06                 ` Pedro Alves
  0 siblings, 2 replies; 33+ messages in thread
From: ayush goel @ 2016-08-10 13:40 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Pedro Alves, Joseph Myers
  Cc: Gcc Patch List, Jeff Law

On 9 August 2016 at 2:20:59 PM, Pedro Alves (palves@redhat.com) wrote:
> On 08/06/2016 05:34 AM, ayush goel wrote:
> > On 5 August 2016 at 4:09:00 AM, Pedro Alves (palves@redhat.com) wrote:
> >> On 08/02/2016 12:38 AM, Manuel López-Ibáñez wrote:
> >>>
> >>> If there is something wrong or missing, ideally we would like to know
> >>> so that Ayush can work on fixing it before the Summer of Code is over
> >>> in less than two weeks.
> >>
> >> I couldn't see anywhere gnulib's config.h file is included.
> >>
> >> gnulib's replacement headers and (and .c files) depend on
> >> that being included.
> >>
> >> Did I simply miss it?
> >>
> >
> > gnulib’s config.h is created on compile time. After building the
> > library it is present inside gnulib build folder.
>
> Sure, but that was not the question. The question is how are
> the gcc files including that new config.h file.
>
> E.g., how come you're not getting this:
>
> gcc/foo.c
> -> #include "config.h" (pick up gcc's config.h not the new gnulib one)
> -> #include (e.g., #include )
> -> trip on #error in gnulib replacement header:
> #ifndef _GL_INLINE_HEADER_BEGIN
> #error "Please include config.h first."
> #endif
>
> As explained here:
>
> https://gcc.gnu.org/ml/gcc/2016-06/msg00144.html
>
> and here in more detail:
>
> https://sourceware.org/ml/gdb-patches/2012-04/msg00426.html
>
> the scheme of configuring gnulib in a separate directory as borrowed from gdb
> requires including two config.h headers -- the gnulib client's, and gnulib's.
>
> Did you do something different that avoids needing that somehow?

I wasn’t aware of this. Thanks for pointing this out.
It’s strange however, I didn’t see anything failing while
building/testing my system.
>
> In gdb, .c files don't include "config.h" directly. Instead all .c files
> include a "defs.h" file first thing, and that in turn (after another indirection)
> is what includes both gdb's "config.h" and gnulib's "config.h”:

Can gcc also adopt a similar approach? Include gnulib’s config.h in a
single header file instead of including it in every function that uses
it.
Which header file would be the most suitable for this purpose(probably
which is generically included by almost all the gcc functions)?
>
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/common/common-defs.h;h=2c9411704531b510d176a4a22a718ae8313294e7;hb=HEAD#l23
>
> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-06  4:34           ` ayush goel
@ 2016-08-09  8:51             ` Pedro Alves
  2016-08-10 13:40               ` ayush goel
  0 siblings, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-09  8:51 UTC (permalink / raw)
  To: ayush goel, Joseph Myers, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 08/06/2016 05:34 AM, ayush goel wrote:
> On 5 August 2016 at 4:09:00 AM, Pedro Alves (palves@redhat.com) wrote:
>> On 08/02/2016 12:38 AM, Manuel López-Ibáñez wrote:
>>>
>>> If there is something wrong or missing, ideally we would like to know
>>> so that Ayush can work on fixing it before the Summer of Code is over
>>> in less than two weeks.
>>
>> I couldn't see anywhere gnulib's config.h file is included.
>>
>> gnulib's replacement headers and (and .c files) depend on
>> that being included.
>>
>> Did I simply miss it?
>>
> 
> gnulib’s config.h is created on compile time. After building the
> library it is present inside gnulib build folder.

Sure, but that was not the question.  The question is how are
the gcc files including that new config.h file.

E.g., how come you're not getting this:

 gcc/foo.c
   -> #include "config.h" (pick up gcc's config.h not the new gnulib one)
   -> #include <whatever-gnu-lib-replacement-header.h> (e.g., #include <unistd.h>)
     -> trip on #error in gnulib replacement header:
        #ifndef _GL_INLINE_HEADER_BEGIN
         #error "Please include config.h first."
        #endif

As explained here:

  https://gcc.gnu.org/ml/gcc/2016-06/msg00144.html

and here in more detail:

  https://sourceware.org/ml/gdb-patches/2012-04/msg00426.html

the scheme of configuring gnulib in a separate directory as borrowed from gdb
requires including two config.h headers -- the gnulib client's, and gnulib's.

Did you do something different that avoids needing that somehow?

In gdb, .c files don't include "config.h" directly.  Instead all .c files
include a "defs.h" file first thing, and that in turn (after another indirection)
is what includes both gdb's "config.h" and gnulib's "config.h":

 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/common/common-defs.h;h=2c9411704531b510d176a4a22a718ae8313294e7;hb=HEAD#l23

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-04 22:39         ` Pedro Alves
@ 2016-08-06  4:34           ` ayush goel
  2016-08-09  8:51             ` Pedro Alves
  0 siblings, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-08-06  4:34 UTC (permalink / raw)
  To: Joseph Myers, Pedro Alves, Manuel López-Ibáñez
  Cc: Gcc Patch List, Jeff Law

On 5 August 2016 at 4:09:00 AM, Pedro Alves (palves@redhat.com) wrote:
> On 08/02/2016 12:38 AM, Manuel López-Ibáñez wrote:
> >
> > If there is something wrong or missing, ideally we would like to know
> > so that Ayush can work on fixing it before the Summer of Code is over
> > in less than two weeks.
>
> I couldn't see anywhere gnulib's config.h file is included.
>
> gnulib's replacement headers and (and .c files) depend on
> that being included.
>
> Did I simply miss it?
>

gnulib’s config.h is created on compile time. After building the
library it is present inside gnulib build folder.

> Thanks,
> Pedro Alves
>
>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-08-01 23:39       ` Manuel López-Ibáñez
@ 2016-08-04 22:39         ` Pedro Alves
  2016-08-06  4:34           ` ayush goel
  0 siblings, 1 reply; 33+ messages in thread
From: Pedro Alves @ 2016-08-04 22:39 UTC (permalink / raw)
  To: Manuel López-Ibáñez, Joseph Myers
  Cc: ayush goel, Gcc Patch List, Jeff Law

On 08/02/2016 12:38 AM, Manuel López-Ibáñez wrote:
> 
> If there is something wrong or missing, ideally we would like to know
> so that Ayush can work on fixing it before the Summer of Code is over
> in less than two weeks.

I couldn't see anywhere gnulib's config.h file is included.

gnulib's replacement headers and (and .c files) depend on
that being included.

Did I simply miss it?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-07-29 16:56     ` Manuel López-Ibáñez
@ 2016-08-01 23:39       ` Manuel López-Ibáñez
  2016-08-04 22:39         ` Pedro Alves
  0 siblings, 1 reply; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-08-01 23:39 UTC (permalink / raw)
  To: Joseph Myers; +Cc: ayush goel, Gcc Patch List, Jeff Law

On 29 July 2016 at 17:55, Manuel López-Ibáñez <lopezibanez@gmail.com> wrote:
> On 29 July 2016 at 17:51, Joseph Myers <joseph@codesourcery.com> wrote:
>> On Wed, 20 Jul 2016, Manuel López-Ibáñez wrote:
>>
>>> On 20 July 2016 at 19:21, ayush goel <ayushgoel1610@gmail.com> wrote:
>>> > Hey,
>>> > As a first step of my GSOC project
>>> > (https://gcc.gnu.org/wiki/replacelibibertywithgnulib) I have imported
>>> > the gnulib library inside the gcc tree. I have created gnulib as a top
>>> > level directory which contains the necessary scripts to import the
>>> > modules. It also contains the necessary Makefile.in and configure.ac
>>> > files.
>>>
>>> Looks good to me, but I cannot approve it. Joseph, what do you think?
>>
>> That this would best be reviewed by a build-system maintainer.
>
> Sure, who could that be?

Jeff, as a global reviewer, how can we move this forward? You have
said in the past: "I suspect we'll probably want to go with direct use
of gnulib obstack at some point." Well, here it is.

If there is something wrong or missing, ideally we would like to know
so that Ayush can work on fixing it before the Summer of Code is over
in less than two weeks.

Cheers,

Manuel.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-07-29 16:51   ` Joseph Myers
@ 2016-07-29 16:56     ` Manuel López-Ibáñez
  2016-08-01 23:39       ` Manuel López-Ibáñez
  0 siblings, 1 reply; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-07-29 16:56 UTC (permalink / raw)
  To: Joseph Myers; +Cc: ayush goel, Gcc Patch List

On 29 July 2016 at 17:51, Joseph Myers <joseph@codesourcery.com> wrote:
> On Wed, 20 Jul 2016, Manuel López-Ibáñez wrote:
>
>> On 20 July 2016 at 19:21, ayush goel <ayushgoel1610@gmail.com> wrote:
>> > Hey,
>> > As a first step of my GSOC project
>> > (https://gcc.gnu.org/wiki/replacelibibertywithgnulib) I have imported
>> > the gnulib library inside the gcc tree. I have created gnulib as a top
>> > level directory which contains the necessary scripts to import the
>> > modules. It also contains the necessary Makefile.in and configure.ac
>> > files.
>>
>> Looks good to me, but I cannot approve it. Joseph, what do you think?
>
> That this would best be reviewed by a build-system maintainer.

Sure, who could that be?

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-07-20 19:56 ` Manuel López-Ibáñez
@ 2016-07-29 16:51   ` Joseph Myers
  2016-07-29 16:56     ` Manuel López-Ibáñez
  0 siblings, 1 reply; 33+ messages in thread
From: Joseph Myers @ 2016-07-29 16:51 UTC (permalink / raw)
  To: Manuel López-Ibáñez; +Cc: ayush goel, Gcc Patch List

[-- Attachment #1: Type: text/plain, Size: 665 bytes --]

On Wed, 20 Jul 2016, Manuel López-Ibáñez wrote:

> On 20 July 2016 at 19:21, ayush goel <ayushgoel1610@gmail.com> wrote:
> > Hey,
> > As a first step of my GSOC project
> > (https://gcc.gnu.org/wiki/replacelibibertywithgnulib) I have imported
> > the gnulib library inside the gcc tree. I have created gnulib as a top
> > level directory which contains the necessary scripts to import the
> > modules. It also contains the necessary Makefile.in and configure.ac
> > files.
> 
> Looks good to me, but I cannot approve it. Joseph, what do you think?

That this would best be reviewed by a build-system maintainer.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH build/doc] Replacing libiberty with gnulib
  2016-07-20 18:21 ayush goel
@ 2016-07-20 19:56 ` Manuel López-Ibáñez
  2016-07-29 16:51   ` Joseph Myers
  0 siblings, 1 reply; 33+ messages in thread
From: Manuel López-Ibáñez @ 2016-07-20 19:56 UTC (permalink / raw)
  To: ayush goel; +Cc: Gcc Patch List, Joseph S. Myers

On 20 July 2016 at 19:21, ayush goel <ayushgoel1610@gmail.com> wrote:
> Hey,
> As a first step of my GSOC project
> (https://gcc.gnu.org/wiki/replacelibibertywithgnulib) I have imported
> the gnulib library inside the gcc tree. I have created gnulib as a top
> level directory which contains the necessary scripts to import the
> modules. It also contains the necessary Makefile.in and configure.ac
> files.

Looks good to me, but I cannot approve it. Joseph, what do you think?

Minor nit: It should be as follows (you can also use the script contrib/mklog )

2016-07-20 Ayush Goel <ayushgoel1610@gmail.com>

* Makefile.def: Add gnulib as build & host library and dependency of
all-gcc on gnulib.
...

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH build/doc] Replacing libiberty with gnulib
@ 2016-07-20 18:21 ayush goel
  2016-07-20 19:56 ` Manuel López-Ibáñez
  0 siblings, 1 reply; 33+ messages in thread
From: ayush goel @ 2016-07-20 18:21 UTC (permalink / raw)
  To: Gcc Patch List; +Cc: Manuel López-Ibáñez

[-- Attachment #1: Type: text/plain, Size: 4282 bytes --]

Hey,
As a first step of my GSOC project
(https://gcc.gnu.org/wiki/replacelibibertywithgnulib) I have imported
the gnulib library inside the gcc tree. I have created gnulib as a top
level directory which contains the necessary scripts to import the
modules. It also contains the necessary Makefile.in and configure.ac
files.
I have made the corresponding changes in the Makefile.def and
configure.ac files, adding gnulib both as a build and host library,
and subsequently regenerated the Makefile.in and configure files.

In order to show the setup works, I’ve replaced libiberty’s version by
obstack by gnulib’s. This was made possible by replacing the
corresponding header file and then including gnulib headers and gnulib
static library in the build path required to compile gcc files.
Also, in order to ensure that the setup works fine, I locally removed
obstack.[ch] from libiberty so that the setup uses the corresponding
files from gnulib

Used gdb’s scripts to import gnulib
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree;f=gdb/gnulib;h=cdf326774716ae427dc4fb47c9a410fcdf715563;hb=HEAD

Bootstrapped with multiple languages and multilib enabled for maximum coverage.
Regression tested on x86_64-apple-darwin15.5.0 and x86_64-linux




20-7-16 Ayush Goel <ayushgoel1610@gmail.com>

 Makefile.def: Added gnulib as build & host library and dependency of
all-gcc on gnulib
* Makefile.in: regenerated
* configure.ac: Added gnulib as build and host library
* configure: regenerated
* gcc/Makefile.in: Added path to gnulib static library (libgnu.a) and
gnulib header files
* gcc/doc/sourcebuild.texi: Added gnulib and how to use the update
script to update/import gnu lib modules
* gnulib: created directory
* gnulib/Makefile.in: new file
* gnulib/configure.ac: new file
* gnulib/update-gnulib.sh: script to import gnulib modules using gnulib-tool
* gnulib/import: created by update-gnulib.sh
* gnulib/import/Makefile.in: imported from gnulib
* gnulib/import/alignof.h: Imported from gnulib
* gnulib/import/exitfail.c: Imported from gnulib
* gnulib/import/exitfail.h: Imported from gnulib
* gnulib/import/extra: Imported from gnulib
* gnulib/import/extra/snippet: Imported from gnulib
* gnulib/import/extra/snippet/_Noreturn.h: Imported from gnulib
* gnulib/import/extra/snippet/arg-nonnull.h: Imported from gnulib
* gnulib/import/extra/snippet/c++defs.h: Imported from gnulib
* gnulib/import/extra/snippet/warn-on-use.h: Imported from gnulib
* gnulib/import/gettext.h: Imported from gnulib
* gnulib/import/m4: Imported from gnulib
* gnulib/import/m4/00gnulib.m4: Imported from gnulib
* gnulib/import/m4/absolute-header.m4: Imported from gnulib
* gnulib/import/m4/extern-inline.m4: Imported from gnulib
* gnulib/import/m4/gnulib-cache.m4: Imported from gnulib
* gnulib/import/m4/gnulib-common.m4: Imported from gnulib
* gnulib/import/m4/gnulib-comp.m4: Imported from gnulib
* gnulib/import/m4/gnulib-tool.m4: Imported from gnulib
* gnulib/import/m4/include_next.m4: Imported from gnulib
* gnulib/import/m4/longlong.m4: Imported from gnulib
* gnulib/import/m4/multiarch.m4: Imported from gnulib
* gnulib/import/m4/obstack.m4: Imported from gnulib
* gnulib/import/m4/off_t.m4: Imported from gnulib
* gnulib/import/m4/ssize_t.m4: Imported from gnulib
* gnulib/import/m4/stddef_h.m4: Imported from gnulib
* gnulib/import/m4/stdint.m4: Imported from gnulib
* gnulib/import/m4/stdlib_h.m4: Imported from gnulib
* gnulib/import/m4/sys_types_h.m4: Imported from gnulib
* gnulib/import/m4/unistd_h.m4: Imported from gnulib
* gnulib/import/m4/warn-on-use.m4: Imported from gnulib
* gnulib/import/m4/wchar_t.m4: Imported from gnulib
* gnulib/import/obstack.c: Imported from gnulib
* gnulib/import/obstack.h: Imported from gnulib
* gnulib/import/stddef.in.h: Imported from gnulib
* gnulib/import/stdint.in.h: Imported from gnulib
* gnulib/import/stdlib.in.h: Imported from gnulib
* gnulib/import/sys: Imported from gnulib
* gnulib/import/sys_types.in.h: Imported from gnulib
* gnulib/import/unistd.c: Imported from gnulib
* gnulib/import/unistd.in.h: Imported from gnulib
* gnulib/stamp-h1: generated

Also note that I have a copyright assignment in place already.

-Ayush Goel

[-- Attachment #2: importgnulib_7_20.patch --]
[-- Type: application/octet-stream, Size: 21453 bytes --]

Index: src/Makefile.def
===================================================================
--- src/Makefile.def	(revision 237184)
+++ src/Makefile.def	(working copy)
@@ -25,6 +25,7 @@
 // that recursive target in its Makefile.
 
 build_modules= { module= libiberty; };
+build_modules= { module= gnulib; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
 build_modules= { module= m4; };
@@ -112,6 +113,8 @@
 host_modules= { module= zlib; no_install=true; no_check=true;
 		bootstrap=true;
 	        extra_configure_flags='@extra_host_zlib_configure_flags@';};
+host_modules= { module= gnulib;
+              bootstrap=true; };
 host_modules= { module= gdb; };
 host_modules= { module= expect; };
 host_modules= { module= guile; };
@@ -342,6 +345,8 @@
 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-gnulib; hard=true; };
+dependencies = { module=all-gcc; on=all-build-gnulib; };
 dependencies = { module=all-gcc; on=all-libbacktrace; hard=true; };
 dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
 dependencies = { module=all-gcc; on=all-libdecnumber; hard=true; };
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 237184)
+++ src/configure.ac	(working copy)
@@ -125,7 +125,7 @@
 # these library is used by various programs built for the build
 # environment
 #
-build_libs="build-libiberty build-libcpp"
+build_libs="build-libiberty build-libcpp build-gnulib"
 
 # these tools are built for the build environment
 build_tools="build-texinfo build-flex build-bison build-m4 build-fixincludes"
@@ -132,7 +132,7 @@
 
 # these libraries are used by various programs built for the host environment
 #f
-host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv"
+host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktrace libcpp libdecnumber gmp mpfr mpc isl libelf libiconv gnulib"
 
 # these tools are built for the host environment
 # Note, the powerpc-eabi build depends on sim occurring before gdb in order to
Index: src/gcc/Makefile.in
===================================================================
--- src/gcc/Makefile.in	(revision 237184)
+++ src/gcc/Makefile.in	(working copy)
@@ -484,12 +484,14 @@
 
 # Where to find some libiberty headers.
 HASHTAB_H   = $(srcdir)/../include/hashtab.h
-OBSTACK_H   = $(srcdir)/../include/obstack.h
 SPLAY_TREE_H= $(srcdir)/../include/splay-tree.h
 MD5_H	    = $(srcdir)/../include/md5.h
 XREGEX_H    = $(srcdir)/../include/xregex.h
 FNMATCH_H   = $(srcdir)/../include/fnmatch.h
 
+# GNULIB headers
+OBSTACK_H   = $(srcdir)/../gnulib/import/obstack.h
+
 # Linker plugin API headers
 LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h
 
@@ -1022,18 +1024,23 @@
 BUILD_LIBIBERTY = $(build_libobjdir)/libiberty/libiberty.a
 endif
 
+# Where to find the gnulib library
+LIBGNU = ../gnulib/import/libgnu.a
+BUILD_LIBGNU= $(build_libobjdir)/gnulib/import/libgnu.a
+INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
+
 # Dependencies on the intl and portability libraries.
-LIBDEPS= libcommon.a $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
+LIBDEPS= libcommon.a $(CPPLIB) $(LIBGNU) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) \
 	$(LIBDECNUMBER) $(LIBBACKTRACE)
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
+BUILD_LIBDEPS= $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 # How to link with both our special library facilities
 # and the system's installed libraries.
 LIBS = @LIBS@ libcommon.a $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBBACKTRACE) \
-	$(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
+	$(LIBGNU) $(LIBIBERTY) $(LIBDECNUMBER) $(HOST_LIBS)
 BACKENDLIBS = $(ISLLIBS) $(GMPLIBS) $(PLUGINLIBS) $(HOST_LIBS) \
 	$(ZLIB)
 # Any system libraries needed just for GNAT.
@@ -1048,7 +1055,7 @@
 
 # Likewise, for use in the tools that must run on this machine
 # even if we are cross-building GCC.
-BUILD_LIBS = $(BUILD_LIBIBERTY)
+BUILD_LIBS = $(BUILD_LIBGNU) $(BUILD_LIBIBERTY)
 
 BUILD_RTL = build/rtl.o build/read-rtl.o build/ggc-none.o \
 	    build/vec.o build/min-insn-modes.o build/gensupport.o \
@@ -1066,7 +1073,7 @@
 INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
 	   -I$(srcdir)/../include @INCINTL@ \
 	   $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \
-	   $(ISLINC)
+	   $(ISLINC) $(INCGNU)
 
 COMPILE.base = $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -o $@
 ifeq ($(CXXDEPMODE),depmode=gcc3)
Index: src/gnulib/Makefile.in
===================================================================
--- src/gnulib/Makefile.in	(nonexistent)
+++ src/gnulib/Makefile.in	(working copy)
@@ -0,0 +1,290 @@
+# Copyright (C) 1989-2016 Free Software Foundation, Inc.
+
+# This file is part of GCC.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+host_alias = @host_alias@
+target_alias = @target_alias@
+program_transform_name = @program_transform_name@
+bindir = @bindir@
+libdir = @libdir@
+tooldir = $(libdir)/$(target_alias)
+
+datadir = @datadir@
+localedir = @localedir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+man2dir = $(mandir)/man2
+man3dir = $(mandir)/man3
+man4dir = $(mandir)/man4
+man5dir = $(mandir)/man5
+man6dir = $(mandir)/man6
+man7dir = $(mandir)/man7
+man8dir = $(mandir)/man8
+man9dir = $(mandir)/man9
+infodir = @infodir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+htmldir = @htmldir@
+pdfdir = @pdfdir@
+includedir = @includedir@
+
+SHELL = @SHELL@
+EXEEXT = @EXEEXT@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+DESTDIR =
+
+AR = @AR@
+AR_FLAGS = qv
+RANLIB = @RANLIB@
+DLLTOOL = @DLLTOOL@
+
+SUBDIRS = import
+CLEANDIRS = $(SUBDIRS)
+REQUIRED_SUBDIRS = $(SUBDIRS)
+
+# If you are compiling with GCC, make sure that either 1) You have the
+# fixed include files where GCC can reach them, or 2) You use the
+# -traditional flag.  Otherwise the ioctl calls in inflow.c
+# will be incorrectly compiled.  The "fixincludes" script in the gcc
+# distribution will fix your include files up.
+CC=@CC@
+
+# Directory containing source files.
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+CC_LD=$(CC)
+
+# CFLAGS is specifically reserved for setting from the command line
+# when running make.  I.E.  "make CFLAGS=-Wmissing-prototypes".
+CFLAGS = @CFLAGS@
+
+# LDFLAGS is specifically reserved for setting from the command line
+# when running make.
+LDFLAGS = @LDFLAGS@
+
+FLAGS_TO_PASS = \
+	"prefix=$(prefix)" \
+	"exec_prefix=$(exec_prefix)" \
+	"infodir=$(infodir)" \
+	"datarootdir=$(datarootdir)" \
+	"docdir=$(docdir)" \
+	"htmldir=$(htmldir)" \
+	"pdfdir=$(pdfdir)" \
+	"libdir=$(libdir)" \
+	"mandir=$(mandir)" \
+	"datadir=$(datadir)" \
+	"includedir=$(includedir)" \
+	"against=$(against)" \
+	"DESTDIR=$(DESTDIR)" \
+	"AR=$(AR)" \
+	"AR_FLAGS=$(AR_FLAGS)" \
+	"CC=$(CC)" \
+	"CFLAGS=$(CFLAGS)" \
+	"CXX=$(CXX)" \
+	"CXXFLAGS=$(CXXFLAGS)" \
+	"DLLTOOL=$(DLLTOOL)" \
+	"LDFLAGS=$(LDFLAGS)" \
+	"RANLIB=$(RANLIB)" \
+	"MAKEINFO=$(MAKEINFO)" \
+	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
+	"MAKEINFO_EXTRA_FLAGS=$(MAKEINFO_EXTRA_FLAGS)" \
+	"MAKEHTML=$(MAKEHTML)" \
+	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
+	"INSTALL=$(INSTALL)" \
+	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
+	"INSTALL_DATA=$(INSTALL_DATA)" \
+	"RUNTEST=$(RUNTEST)" \
+	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
+
+all installcheck check info install-info clean-info dvi pdf install-pdf html install-html: force
+	@$(MAKE) $(FLAGS_TO_PASS) DO=$@ "DODIRS=$(SUBDIRS)" subdir_do
+
+# Traditionally "install" depends on "all".  But it may be useful
+# not to; for example, if the user has made some trivial change to a
+# source file and doesn't care about rebuilding or just wants to save the
+# time it takes for make to check that all is up to date.
+# install-only is intended to address that need.
+install: all
+	@$(MAKE) $(FLAGS_TO_PASS) install-only
+
+install-only: $(CONFIG_INSTALL)
+	@$(MAKE) DO=install "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+uninstall: force $(CONFIG_UNINSTALL)
+	@$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do
+
+# Convenience rule to handle recursion.
+$(LIBGNU) $(GNULIB_H): all-lib
+all-lib: import/Makefile
+	@$(MAKE) $(FLAGS_TO_PASS) DO=all DODIRS=import subdir_do
+.PHONY: all-lib
+
+clean mostlyclean: $(CONFIG_CLEAN)
+	@$(MAKE) $(FLAGS_TO_PASS) DO=clean "DODIRS=$(CLEANDIRS)" subdir_do
+
+distclean: clean
+	@$(MAKE) $(FLAGS_TO_PASS) DO=distclean "DODIRS=$(CLEANDIRS)" subdir_do
+	rm -f config.status config.h stamp-h
+	rm -f config.log config.cache
+	rm -f Makefile
+	rm -rf $(DEPDIR)
+
+maintainer-clean: local-maintainer-clean do-maintainer-clean distclean
+realclean: maintainer-clean
+
+local-maintainer-clean:
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+	rm -f config.status
+
+do-maintainer-clean:
+	@$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(CLEANDIRS)" \
+		subdir_do
+
+subdir_do: force
+	@for i in $(DODIRS); do \
+		case $$i in \
+		$(REQUIRED_SUBDIRS)) \
+			if [ ! -f ./$$i/Makefile ] ; then \
+				echo "Missing $$i/Makefile" >&2 ; \
+				exit 1 ; \
+			fi ;; \
+		esac ; \
+		if [ -f ./$$i/Makefile ] ; then \
+			if (cd ./$$i; \
+				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
+			else exit 1 ; fi ; \
+		else true ; fi ; \
+	done
+
+Makefile: Makefile.in config.status
+	# Regenerate the Makefile.
+	CONFIG_FILES="Makefile" \
+	  CONFIG_COMMANDS= \
+	  CONFIG_HEADERS= \
+	  $(SHELL) config.status
+
+gnulib/Makefile: gnulib/Makefile.in config.status
+	CONFIG_FILES="gnulib/Makefile" \
+	  CONFIG_COMMANDS="depfiles" \
+	  CONFIG_HEADERS= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.h: stamp-h ; @true
+stamp-h: $(srcdir)/config.in config.status
+	CONFIG_HEADERS=config.h:config.in \
+	  CONFIG_COMMANDS="default depdir" \
+	  CONFIG_FILES= \
+	  CONFIG_LINKS= \
+	  $(SHELL) config.status
+
+config.status: $(srcdir)/configure
+	$(SHELL) config.status --recheck
+
+ACLOCAL = aclocal
+ACLOCAL_AMFLAGS = -I import/m4 -I ../../config
+aclocal_m4_deps = \
+	configure.ac \
+	import/m4/00gnulib.m4 \
+	import/m4/alloca.m4 \
+	import/m4/codeset.m4 \
+	import/m4/configmake.m4 \
+	import/m4/extensions.m4 \
+	import/m4/fcntl-o.m4 \
+	import/m4/fnmatch.m4 \
+	import/m4/glibc21.m4 \
+	import/m4/gnulib-cache.m4 \
+	import/m4/gnulib-common.m4 \
+	import/m4/gnulib-comp.m4 \
+	import/m4/gnulib-tool.m4 \
+	import/m4/include_next.m4 \
+	import/m4/inttypes-pri.m4 \
+	import/m4/inttypes.m4 \
+	import/m4/localcharset.m4 \
+	import/m4/locale-fr.m4 \
+	import/m4/locale-ja.m4 \
+	import/m4/locale-zh.m4 \
+	import/m4/longlong.m4 \
+	import/m4/mbrtowc.m4 \
+	import/m4/mbsinit.m4 \
+	import/m4/mbsrtowcs.m4 \
+	import/m4/mbstate_t.m4 \
+	import/m4/memchr.m4 \
+	import/m4/memmem.m4 \
+	import/m4/mmap-anon.m4 \
+	import/m4/multiarch.m4 \
+	import/m4/off_t.m4 \
+	import/m4/pathmax.m4 \
+	import/m4/ssize_t.m4 \
+	import/m4/stdbool.m4 \
+	import/m4/stddef_h.m4 \
+	import/m4/stdint.m4 \
+	import/m4/obstack.m4 \
+	import/m4/strtok_r.m4 \
+	import/m4/sys_types_h.m4 \
+	import/m4/unistd_h.m4 \
+	import/m4/warn-on-use.m4 \
+	import/m4/wchar_h.m4 \
+	import/m4/wchar_t.m4 \
+	import/m4/wctype_h.m4 \
+	import/m4/wint_t.m4
+
+$(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
+	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+
+AUTOCONF = autoconf
+configure_deps = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
+$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOCONF)
+
+AUTOHEADER = autoheader
+$(srcdir)/config.in: @MAINTAINER_MODE_TRUE@ $(configure_deps)
+	cd $(srcdir) && $(AUTOHEADER)
+	rm -f stamp-h
+	touch $@
+
+# automatic rebuilding in automake-generated Makefiles requires
+# this rule in the toplevel Makefile, which, with GNU make, causes
+# the desired updates through the implicit regeneration of the Makefile
+# and all of its prerequisites.
+am--refresh:
+	@:
+
+force:
+
+force_update:
+
+# GNU Make has an annoying habit of putting *all* the Makefile variables
+# into the environment, unless you include this target as a circumvention.
+# Rumor is that this will be fixed (and this target can be removed)
+# in GNU Make 4.0.
+.NOEXPORT:
+
+# GNU Make 3.63 has a different problem: it keeps tacking command line
+# overrides onto the definition of $(MAKE).  This variable setting
+# will remove them.
+MAKEOVERRIDES=
+
+### end of the libgnu Makefile.in.
Index: src/gnulib/configure.ac
===================================================================
--- src/gnulib/configure.ac	(nonexistent)
+++ src/gnulib/configure.ac	(working copy)
@@ -0,0 +1,60 @@
+dnl Autoconf configure script for GCC.
+dnl Copyright (C) 1995-2016 Free Software Foundation, Inc.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.64)dnl
+AC_INIT()
+AC_CONFIG_HEADER(config.h:config.in)
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_USE_SYSTEM_EXTENSIONS
+gl_EARLY
+AM_PROG_CC_STDC
+
+AC_CONFIG_AUX_DIR(..)
+AC_CANONICAL_SYSTEM
+
+gl_INIT
+
+# Gnulib uses automake.  This line lets gcc generate
+# its Makefile.in.
+AM_INIT_AUTOMAKE(libgnu, UNUSED-VERSION, [no-define])
+
+# --------------------- #
+# Checks for programs.  #
+# --------------------- #
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_RANLIB
+
+AC_CHECK_TOOL(AR, ar)
+
+# ---------------------- #
+# Checks for libraries.  #
+# ---------------------- #
+
+AC_OUTPUT(Makefile import/Makefile,
+[
+case x$CONFIG_HEADERS in
+xconfig.h:config.in)
+echo > stamp-h ;;
+esac
+])
+
+exit 0
Index: src/gnulib/update-gnulib.sh
===================================================================
--- src/gnulib/update-gnulib.sh	(nonexistent)
+++ src/gnulib/update-gnulib.sh	(working copy)
@@ -0,0 +1,129 @@
+#! /bin/sh
+
+# Copyright (C) 2011-2016 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Usage: update-gnulib.sh <path-to-gnulib-repository>
+# Update our import of gnulib in the GCC source tree.
+#
+# This script assumes that it is being called from the gcc/gnulib
+# subdirectory.
+#
+# This script will also make a number of other verifications:
+#   . The gnulib version (it should match $GNULIB_COMMIT_SHA1).
+#   . The correct versions of the auto-tools that are used to
+#     regenerate the various scripts and Makefiles are on the PATH.
+
+# The list of gnulib modules we are importing in GCC.
+IMPORTED_GNULIB_MODULES="\
+    obstack \
+"
+
+# The gnulib commit ID to use for the update.
+GNULIB_COMMIT_SHA1="1029a8112290f6eee9d7878a391c49db42c999bd"
+
+# The expected version number for the various auto tools we will
+# use after the import.
+AUTOCONF_VERSION="2.69"
+AUTOMAKE_VERSION="1.15"
+ACLOCAL_VERSION="$AUTOMAKE_VERSION"
+
+if [ $# -ne 1 ]; then
+   echo "Error: Path to gnulib repository missing. Aborting."
+   echo "Usage: update-gnulib.sh <path-to-gnulib-repository>"
+   exit 1
+fi
+gnulib_prefix=$1
+
+gnulib_tool="$gnulib_prefix/gnulib-tool"
+
+# Verify that the gnulib directory does exist...
+if [ ! -f "$gnulib_tool" ]; then
+   echo "Error: Invalid gnulib directory. Cannot find gnulib tool"
+   echo "       ($gnulib_tool)."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the right version of gnulib...
+gnulib_head_sha1=`cd $gnulib_prefix && git rev-parse HEAD`
+if [ "$gnulib_head_sha1" != "$GNULIB_COMMIT_SHA1" ]; then
+   echo "Error: Wrong version of gnulib: $gnulib_head_sha1"
+   echo "       (we expected it to be $GNULIB_COMMIT_SHA1)"
+   echo "Aborting."
+   exit 1
+fi
+
+ver=`autoconf --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOCONF_VERSION" ]; then
+   echo "Error: Wrong autoconf version: $ver. Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of automake.
+ver=`automake --version 2>&1 | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$AUTOMAKE_VERSION" ]; then
+   echo "Error: Wrong automake version ($ver), we need $AUTOMAKE_VERSION."
+   echo "Aborting."
+   exit 1
+fi
+
+# Verify that we have the correct version of aclocal.
+#
+# The grep below is needed because Perl >= 5.16 dumps a "called too
+# early to check prototype" warning when running aclocal 1.11.1.  This
+# causes trouble below, because the warning is the first line output
+# by aclocal, resulting in:
+#
+# $ sh ./update-gnulib.sh ~/src/gnulib/src/
+# Error: Wrong aclocal version: called too early to check prototype at /opt/automake-1.11.1/bin/aclocal line 617.. Aborting.
+#
+# Some distros carry an automake patch for that:
+#  https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=aclocal-function-prototypes.debdiff;att=1;bug=752784
+#
+# But since we prefer pristine FSF versions of autotools, work around
+# the issue here.  This can be removed later when we bump the required
+# automake version.
+#
+ver=`aclocal --version 2>&1 | grep -v "called too early to check prototype" | head -1 | sed 's/.*) //'`
+if [ "$ver" != "$ACLOCAL_VERSION" ]; then
+   echo "Error: Wrong aclocal version: $ver. Aborting."
+   exit 1
+fi
+
+# Update our gnulib import.
+$gnulib_prefix/gnulib-tool --import --dir=. --lib=libgnu \
+  --source-base=import --m4-base=import/m4 --doc-base=doc \
+  --tests-base=tests --aux-dir=import/extra \
+  --no-conditional-dependencies --no-libtool --macro-prefix=gl \
+  --no-vc-files \
+  $IMPORTED_GNULIB_MODULES
+if [ $? -ne 0 ]; then
+   echo "Error: gnulib import failed.  Aborting."
+   exit 1
+fi
+
+# Regenerate all necessary files...
+aclocal -Iimport/m4 &&
+autoconf &&
+autoheader &&
+automake
+if [ $? -ne 0 ]; then
+   echo "Error: Failed to regenerate Makefiles and configure scripts."
+   exit 1
+fi
+

Property changes on: src/gnulib/update-gnulib.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: src/gcc/doc/sourcebuild.texi
===================================================================
--- src/gcc/doc/sourcebuild.texi	(revision 237184)
+++ src/gcc/doc/sourcebuild.texi	(working copy)
@@ -97,6 +97,22 @@
 Introduction, libiberty, @sc{gnu} libiberty}, for more information
 about this library.
 
+@item libgnu
+Gnulib - The GNU portability library
+To facilitate the update/import of gnulib, a script called update-gnulib.sh (resides inside path/to/gcc-src/gcc/gnulib) has been created to automate the process.
+Usage: update-gnulib.sh <path-to-gnulib-repository>
+
+The script maintains the two key pieces of information from which the import is created as constants defined inside the script:
+@itemize @bullet
+@item
+GNULIB_COMMIT_SHA1 - which commit from the gnulib respository is to be used for the import; So in order to update gnulib, replace this value with that of the newer version and run the script.
+
+@item
+IMPORTED_GNULIB_MODULES - which modules to import from gnulib. Add a new module to this list in order to import it to gcc and run the script. 
+
+@end itemize
+When updating the import, please only modify one element at a time. For instance, if you want to import a new module only defined in a later version of gnulib, please first update the import to use the newer commit as a first patch, and then update the import to include the new module as a second patch.
+
 @item libitm
 The runtime support library for transactional memory.
 

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2016-08-29 11:30 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-15 12:51 [PATCH build/doc] Replacing libiberty with gnulib ayush goel
2016-08-15 14:26 ` Manuel López-Ibáñez
2016-08-16 16:54 ` Pedro Alves
2016-08-16 17:21   ` Joseph Myers
2016-08-20 10:22   ` ayush goel
2016-08-20 15:22     ` Manuel López-Ibáñez
2016-08-21 11:36       ` ayush goel
2016-08-21 19:41     ` Pedro Alves
2016-08-22 16:36       ` ayush goel
2016-08-22 16:43         ` Pedro Alves
2016-08-28 18:55           ` ayush goel
2016-08-29 11:30             ` Joseph Myers
2016-08-22 17:41         ` Joseph Myers
2016-08-22 18:48         ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2016-07-20 18:21 ayush goel
2016-07-20 19:56 ` Manuel López-Ibáñez
2016-07-29 16:51   ` Joseph Myers
2016-07-29 16:56     ` Manuel López-Ibáñez
2016-08-01 23:39       ` Manuel López-Ibáñez
2016-08-04 22:39         ` Pedro Alves
2016-08-06  4:34           ` ayush goel
2016-08-09  8:51             ` Pedro Alves
2016-08-10 13:40               ` ayush goel
2016-08-10 14:05                 ` Manuel López-Ibáñez
2016-08-10 14:14                   ` Pedro Alves
2016-08-10 14:06                 ` Pedro Alves
2016-08-10 14:25                   ` Pedro Alves
2016-08-10 16:31                   ` ayush goel
2016-08-10 16:52                     ` Pedro Alves
2016-08-10 17:33                       ` ayush goel
2016-08-10 17:49                         ` Pedro Alves
2016-08-10 17:51                           ` ayush goel
2016-08-10 17:58                             ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).