public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compile GCC using only tools isolated from host environment
@ 2022-03-14 22:43 Benjamin Lovy
  2022-03-15  7:19 ` Xi Ruoyao
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Benjamin Lovy @ 2022-03-14 22:43 UTC (permalink / raw)
  To: gcc-help

Hello,

I am attempting to build GCC 11.2.0 in an isolated environment.  First, I
grabbed the Linux headers:

make headers_install \
ARCH=x86_64 \
INSTALL_HDR_PATH=/bootstrap/usr

Then, I built binutils:

mkdir binutils-build && \
  cd binutils-build &&
  /build/binutils-2.38/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--disable-nls \
--disable-werror && \
make -j16 && \
make install

Then, I built GCC using the host toolchain:

mkdir /build/gcc-build && \
  cd gcc-build &&
  /build/gcc-11.2.0/configure \
--prefix=/bootstrap/ \
--host=x86_64-pc-linux-gnu \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-decimal-float \
--disable-fixed-point \
--disable-libatomic \
--disable-libgomp \
--disable-libitm \
--disable-libmpx \
--disable-libquadmath \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls && \
make -j16 && \
make install

Then, I built glibc using this GCC:

mkdir glibc-build && \
  cd glibc-build && \
  /build/glibc-2.34/configure \
CC=/bootstrap/bin/gcc \
CFLAGS="-fno-stack-protector -O2" \
CPPFLAGS="-U_FORTIFY_SOURCE" \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--with-headers=/bootstrap/usr/include &&\
make -j16 && \
make install

This all works fine.  I then build the following software:

* GMP 6.21
* MPFR 4.10
* MPC 1.21
* tar 1.34
* bash 5.16
* coreutils 9.0
* curl 7.82
* zlib 1.2.11
* gzip 1.11
* sed 4.8
* grep 2.28
* gawk 5.11
* make 4.3
* xz 5.25

I use invocations similar to this for each entry on that list:

./configure \
CC=/bootstrap/bin/gcc \
CFLAGS="-Wl,-dynamic-linker=/bootstrap/lib/ld-linux-x86-64.so.2
-Wl,-rpath,/bootstrap/lib -I/bootstrap/include" \
--with-sysroot=/bootstrap \
--prefix=/bootstrap && \
make -j16 && \
make check && \
make install

Now, I would like to build a fresh GCC using the previously build GCC, this
glib, and the GMP/MPC/MPFR libraries I just built:

/build/gcc-11.2.0/configure \
CFLAGS="-Wl,-dynamic-linker=/lib/ld-linux-x86-64.so.2 -Wl,-rpath,/lib
-I/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include -I/usr/include
-I/usr/include/linux -I/lib/gcc/x86_64-pc-linux-gnu/11.2.0/include-fixed
-B/bin" \
  --prefix=/bootstrap/gcc \
--host=x86_64-pc-linux-gnu \
--with-sysroot=/bootstrap \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-decimal-float \
--disable-fixed-point \
--disable-libatomic \
--disable-libgomp \
--disable-libitm \
--disable-libmpx \
--disable-libquadmath \
--disable-libsanitizer \
--disable-libssp \
--disable-libvtv \
--disable-lto \
--disable-multilib \
--disable-nls && \
make -j16 && \
make install;

Configure fails, complaining it cannot find `gmp.h`.  In `config.log`, I
observe the configure process appears to actually read the contents of this
header from `/bootstrap/include/gmp.h`, but the preprocessor fails to
expand `stddef.h` and `limits.h`, both of which I've verified are present
in the provided include paths, along with gmp.h.

From my understanding, all the extra paths shouldn't be necessary if I'm
using `--with-sysroot`, but I have failed to find a set of options that
produces a working buiild.

Have I misconfigured this environment?  What steps am I missing to build
GCC using only tools present in my bootstrap directory tree?

If it's relevant, this build is happening in a fresh Ubuntu 20.04 docker
container.

Thanks in advance,
Ben

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

end of thread, other threads:[~2022-05-03 15:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 22:43 Compile GCC using only tools isolated from host environment Benjamin Lovy
2022-03-15  7:19 ` Xi Ruoyao
2022-03-16 16:06   ` Benjamin Lovy
2022-03-15  8:46 ` Jonathan Wakely
2022-05-03  8:26 ` Question related to -fPIC behaviour across architectures vincent Dupaquis
2022-05-03 10:24   ` Xi Ruoyao
2022-05-03 13:29     ` vincent Dupaquis
2022-05-03 14:29   ` Florian Weimer
2022-05-03 15:45     ` vincent Dupaquis

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).