This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Support installing headers for bootstrapping libgcc


One issue when bootstrapping cross tools including glibc is installing
headers for building parts of libgcc; the "install-headers" target
doesn't do quite the right thing for bootstrapping.  Specifically, it
omits to install gnu/stubs.h (which depends on all objects in the
library) and bits/stdio_lim.h.

To address this, I propose this patch, which adds an
install-bootstrap-headers=yes setting that can be used with the "make
install-headers" command to install the headers needed for
bootstrapping.  This causes a dummy version of gnu/stubs.h to be
installed - which is sufficient for building the parts of libgcc that
need library headers.

This setting can be used in a variety of bootstrap processes, such as
that at
<http://www.eglibc.org/cgi-bin/viewvc.cgi/trunk/libc/EGLIBC.cross-building?revision=2037>,
for which it was originally implemented, and that at
<http://www.tilera.com/scm/source.html> which Chris recently pointed
to (replacing the manual steps relating to headers in that process; my
previous patches have removed the need to set
libc_cv_forced_unwind=yes and libc_cv_c_cleanup=yes when
configuring).  Given the range of processes used, I didn't try to
document details of a particular process as a canonical supported one,
but just described the use of the new setting in a short section in
the manual.

Note that this patch, while it suffices to allow bootstrap builds
along the lines of the first process pointed to above to work, doesn't
finish making the results of such builds the same as those of native,
non-bootstrap builds.  There are still other configure tests needing
fixing to give the right results in bootstrap situations (but which do
not break the build when they give the wrong results), and some bits
that are not built and installed for cross builds that need fixes to
build and install them for cross builds.  The changes to
sunrpc/Makefile in this patch, since they are inside code that is
already disabled for cross compilation, are strictly only relevant in
the presence of such changes, but I think they logically belong to
this bootstrap improvements patch rather than to separate cross build
improvements patches.

Except for the changes to install.texi, these changes were originally
implemented by Jim Blandy when he was at CodeSourcery.

Tested x86_64 (both native and a bootstrapped cross from i686).

2012-03-08  Jim Blandy  <jimb@codesourcery.com>
	    Joseph Myers  <joseph@codesourcery.com>

	* Makefile [install-bootstrap-headers] (install-headers): Depend
	on $(inst_includedir)/gnu/stubs.h.
	[install-bootstrap-headers] (install-others): Don't include
	$(inst_includedir)/gnu/stubs.h.
	[install-bootstrap-headers] ($(inst_includedir)/gnu/stubs.h): New
	rule.
	[install-bootstrap-headers] (installed-stubs): Define to empty.
	[install-bootstrap-headers] (install-others-nosubdir): Do not
	depend on $(installed-stubs).
	* include/stubs-bootstrap.h: New file.
	* stdio-common/Makefile (install-others): Remove variable.
	(install-headers-nosubdir): Depend on
	$(inst_includedir)/bits/stdio_lim.h.
	* sunrpc/Makefile [install-bootstrap-headers] (headers): Don't
	include generated files.
	[install-bootstrap-headers] (extra-libs): Don't define variable.
	[install-bootstrap-headers] (extra-libs-others): Don't define
	variable.
	[install-bootstrap-headers] (librpcsvc-routines): Don't define
	variable.
	[install-bootstrap-headers] (librpcsvc-inhibit-o): Don't define
	variable.
	[install-bootstrap-headers] (omit-deps): Don't define variable.
	* sysdeps/unix/sysv/linux/Makefile (install-others): Remove
	variable.
	(install-headers-nosubdir): Depend on
	$(inst_includedir)/bits/syscall.h.
	* manual/install.texi (Bootstrapping): New section.
	* INSTALL: Regenerated.

diff --git a/Makefile b/Makefile
index 5a31adb..4553b2d 100644
--- a/Makefile
+++ b/Makefile
@@ -69,9 +69,18 @@ subdir-dirs = include
 vpath %.h $(subdir-dirs)
 
 # What to install.
-install-others = $(inst_includedir)/gnu/stubs.h
 install-bin-script =
 
+# If we're bootstrapping, install a dummy gnu/stubs.h along with the
+# other headers, so 'make install-headers' produces a useable include
+# tree.  Otherwise, install gnu/stubs.h later, after the rest of the
+# build is done.
+ifeq ($(install-bootstrap-headers),yes)
+install-headers: $(inst_includedir)/gnu/stubs.h
+else
+install-others = $(inst_includedir)/gnu/stubs.h
+endif
+
 ifeq (yes,$(build-shared))
 headers += gnu/lib-names.h
 endif
@@ -171,6 +180,16 @@ others: $(common-objpfx)testrun.sh
 
 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)$(dir)/stubs)
 
+# gnu/stubs.h depends (via the subdir 'stubs' targets) on all the .o
+# files in glibc.  For bootstrapping a GCC/glibc pair, an empty
+# gnu/stubs.h is good enough.
+ifeq ($(install-bootstrap-headers),yes)
+$(inst_includedir)/gnu/stubs.h: include/stubs-bootstrap.h $(+force)
+	$(make-target-directory)
+	$(INSTALL_DATA) $< $@
+
+installed-stubs = 
+else 
 ifeq ($(biarch),no)
 installed-stubs = $(inst_includedir)/gnu/stubs.h
 else
@@ -182,6 +201,7 @@ $(inst_includedir)/gnu/stubs.h: include/stubs-biarch.h $(+force)
 
 install-others-nosubdir: $(installed-stubs)
 endif
+endif
 
 
 # Since stubs.h is never needed when building the library, we simplify the
diff --git a/include/stubs-bootstrap.h b/include/stubs-bootstrap.h
new file mode 100644
index 0000000..e7361d1
--- /dev/null
+++ b/include/stubs-bootstrap.h
@@ -0,0 +1,29 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
+
+   Placeholder stubs.h file for bootstrapping.
+
+   When bootstrapping a GCC/glibc pair, GCC requires that the glibc
+   headers be installed, but we can't fully build glibc without that
+   GCC.  So we run the command:
+
+      make install-headers install-bootstrap-headers=yes
+
+   to install the headers GCC needs, but avoid building certain
+   difficult headers.  The <gnu/stubs.h> header depends, via the
+   glibc subdir 'stubs' make targets, on every .o file in glibc, but
+   an empty stubs.h like this will do fine for GCC.  */
diff --git a/manual/install.texi b/manual/install.texi
index 00db2b8..dd803f9 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -26,6 +26,7 @@ GNU Make, and possibly others.  @xref{Tools for Compilation}, below.
  compiled.
 * Tools for Compilation::       You'll need these first.
 * Linux::                       Specific advice for GNU/Linux systems.
+* Bootstrapping::               Building cross toolchains with GNU libc.
 * Reporting Bugs::              So they'll get fixed.
 @end menu
 
@@ -385,6 +386,26 @@ GNU @code{gettext} 0.10.36 or later
 You may also need these packages if you upgrade your source tree using
 patches, although we try to avoid this.
 
+@node Bootstrapping
+@appendixsec Bootstrapping cross toolchains including @theglibc{}
+@cindex bootstrapping
+@cindex cross-compilation
+
+If you are building @theglibc{} using a cross compiler, and also
+building that cross compiler, and do not have a previously built
+version of @theglibc{}, the build process is more complicated because
+building the whole of GCC's libgcc library requires headers from
+@theglibc{}, while building @theglibc{} requires a previously built
+and installed libgcc shared library.
+
+To resolve these circular dependencies, @theglibc{} can be configured
+using a minimal build of GCC without shared libgcc.  Although it is
+not then possible to do a complete build of @theglibc{}, @code{make
+install-headers install-bootstrap-headers=yes} will install headers
+suitable for building libgcc.  (These headers will be replaced by the
+final @code{make install} when @theglibc{} is fully built using GCC
+with shared libgcc.)
+
 @node Linux
 @appendixsec Specific advice for @gnulinuxsystems{}
 @cindex kernel header files
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 266147e..ff02d74 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -39,10 +39,10 @@ routines	:=							      \
 	isoc99_vsscanf							      \
 	psiginfo
 
-install-others = $(inst_includedir)/bits/stdio_lim.h
-
 include ../Makeconfig
 
+install-headers-nosubdir: $(inst_includedir)/bits/stdio_lim.h
+
 aux	:= errlist siglist printf-parsemb printf-parsewc fxprintf
 
 tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 329d3f3..5145b39 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -102,6 +102,7 @@ otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
 endif
 
 ifeq (no,$(cross-compiling))
+ifneq (yes,$(install-bootstrap-headers))
 # We can only build this library if we can run the rpcgen we build.
 headers += $(rpcsvc:%.x=rpcsvc/%.h)
 extra-libs := librpcsvc
@@ -110,6 +111,7 @@ librpcsvc-routines = $(rpcsvc:%.x=x%)
 librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
 omit-deps = $(librpcsvc-routines)
 endif
+endif
 
 include ../Rules
 
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 458658d..739b986 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -35,7 +35,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \
 		  sys/timerfd.h sys/fanotify.h bits/eventfd.h bits/inotify.h \
 		  bits/signalfd.h bits/timerfd.h bits/epoll.h
 
-install-others += $(inst_includedir)/bits/syscall.h
+install-headers-nosubdir: $(inst_includedir)/bits/syscall.h
 
 tests += tst-clone
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]