public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Building a host-isolated gcc without faking cross-compiling
@ 2021-09-10 16:54 Anthony de Almeida Lopes
  2021-09-10 17:46 ` Lance Fredrickson
  0 siblings, 1 reply; 7+ messages in thread
From: Anthony de Almeida Lopes @ 2021-09-10 16:54 UTC (permalink / raw)
  To: gcc-help

I'd like to build gcc for a chroot on my current system. Linux From
Scratch uses a method of faking a cross compiler by modifying the vendor
field of the target string. For example, changing x86_64-pc-linux-gnu to
x86_64-lfs-linux-gnu. I'd like to know if there's a way of avoiding
this. While GCC builds fine for my host natively and it builds fine with
the LFS method, I have so far been unable to build a host isolated copy
any other way.

I understand the recommended order is to build binutils and gcc first,
then build glibc with them and finally rebuild gcc against that glibc.

# I built binutils like this

../configure   \
    --prefix=$DISTRO/root/bootstrap \
    --with-sysroot=$DISTRO  \
    --disable-nls \
    --disable-werror

&& make -j6 && make -j1 install

# Then I tried to build gcc like this

../configure                                       \
     --prefix=$DISTRO/tools                         \
     --with-glibc-version=2.11                      \
     --with-sysroot=$DISTRO                         \
     --with-newlib                                  \
     --without-headers                              \
     --enable-initfini-array                        \
     --disable-nls                                  \
     --disable-shared                               \
     --disable-multilib                             \
     --disable-decimal-float                        \
     --disable-threads                              \
     --disable-libatomic                            \
     --disable-libgomp                              \
     --disable-libquadmath                          \
     --disable-libssp                               \
     --disable-libvtv                               \
     --disable-libstdcxx                            \
     --enable-languages=c,c++

&& make -j6 && make -j1 install

But this fails with a bunch of undefined references to the ZSTD
namespace such as ZSTD_getErrorName from gcc/lto-compress.c. I assume
this means that ./configure has detected that my host system has libzstd
but it's trying to look for them in the sysroot, where it obviously
can't find them. This happens even if I use --disable-lto.

Build System (Arch Linux): linux 5.13.13, glibc 2.33, binutils 2.36.1,
gcc 11.1.0
Target System: linux 5.13.12, glibc 2.34, binutils 2.37, gcc 11.2.0

So I'd like to know if I should continue like this, and if so how, or if
there is a better (maybe canonical) way of building a host-isolated
compiler?

- Anthony



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

end of thread, other threads:[~2021-09-13 14:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 16:54 Building a host-isolated gcc without faking cross-compiling Anthony de Almeida Lopes
2021-09-10 17:46 ` Lance Fredrickson
2021-09-10 18:21   ` Anthony de Almeida Lopes
2021-09-10 18:42     ` Lance Fredrickson
2021-09-11  4:55       ` Anthony de Almeida Lopes
2021-09-11  8:32         ` Xi Ruoyao
2021-09-13 14:06           ` Anthony de Almeida Lopes

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