Re: Building a host-isolated gcc without faking cross-compiling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you probably want |--with-native-system-header-dir

|
|--with-native-system-header-dir=dirname|

   Specifies thatdirnameis the directory that contains native system
   header files, rather than/usr/include. This option is most useful if
   you are creating a compiler that should be isolated from the system
   as much as possible. It is most commonly used with
   the--with-sysrootoption and will cause GCC to searchdirnameinside
   the system root specified by that option.

Lance

On 9/10/2021 10:54 AM, Anthony de Almeida Lopes via Gcc-help wrote:
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






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux