From: Benjamin Lovy <ben@tangram.dev>
To: gcc-help@gcc.gnu.org
Subject: Compile GCC using only tools isolated from host environment
Date: Mon, 14 Mar 2022 18:43:29 -0400 [thread overview]
Message-ID: <CAH9OHLJ_EnbTA6Ga8w77tGEijjHYadB8s_1dk4TLUH5oCGS5Ew@mail.gmail.com> (raw)
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
next reply other threads:[~2022-03-14 22:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 22:43 Benjamin Lovy [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH9OHLJ_EnbTA6Ga8w77tGEijjHYadB8s_1dk4TLUH5oCGS5Ew@mail.gmail.com \
--to=ben@tangram.dev \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).