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

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

 



Alright, progress. I'm still researching the next problems that I ran
into but I thought I'd post an update. First, I ran into
GCC_NO_EXECUTABLES while the build was in configure-stage2-zlib and in
anticipating what Lance might say to that, I checked and there doesn't
seem to be a --without-zlib although I did test that just in case and it
did nothing. The best explanation for what GCC_NO_EXECUTABLES is that I
found so far is in a post to the list about a similar problem:

https://gcc.gnu.org/legacy-ml/gcc/2008-03/msg00515.html

I went ahead and built it anyway with --disable-bootstrap. glibc
compiled but not too surprisingly running ldd or /usr/lib/libc.so.6 with
LD_LIBRARY_PATH to $DISTRO/usr/lib just segfaults, so it seems like it
wasn't really a sane build of gcc after all.

Ignoring that problem, configuring libstdc++-v3 after having glibc fails
which is kind of obvious since the host glibc differs in version from
the target version. You know, the typical "version `GLIBC_2.34' not
found" errors. This seems like a proper motivating reason for using the
fake cross-compiling trick but I'm determined to figure out if there's a
way around that.

../configure \
      --prefix=$DISTRO/root/bootstrap \
      --with-glibc-version=2.11 \
      --with-sysroot=$DISTRO \
     --with-native-system-header-dir=$DISTRO/usr/include \
     --without-zstd \
      --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++

....


checking whether the
/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/./prev-gcc/xgcc
-B/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/./prev-gcc/
-B/home/guerrilla/Projects/Boots/distro/root/bootstrap/x86_64-pc-linux-gnu/bin/
-B/home/guerrilla/Projects/Boots/distro/root/bootstrap/x86_64-pc-linux-gnu/bin/
-B/home/guerrilla/Projects/Boots/distro/root/bootstrap/x86_64-pc-linux-gnu/lib/
-isystem
/home/guerrilla/Projects/Boots/distro/root/bootstrap/x86_64-pc-linux-gnu/include
-isystem
/home/guerrilla/Projects/Boots/distro/root/bootstrap/x86_64-pc-linux-gnu/sys-include
-fno-checking linker (ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... configure: error: Link tests
are not allowed after GCC_NO_EXECUTABLES.
make[2]: *** [Makefile:16252: configure-stage2-zlib] Error 1
yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking whether byte ordering is bigendian... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for CET support... configure: error: Link tests are not allowed
after GCC_NO_EXECUTABLES.
make[2]: *** [Makefile:14566: configure-stage2-libiberty] Error 1
make[2]: Leaving directory
'/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build'
make[1]: *** [Makefile:23471: stage2-bubble] Error 2
make[1]: Leaving directory
'/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build'
make: *** [Makefile:954: all] Error 2






On 9/10/21 8:42 PM, Lance Fredrickson via Gcc-help wrote:
> Hmmm, well you can also try --without-zstd.  There was a commit last
> year to ensure this flags is respected.
>
> commit 0fb0240a051df91d3c24385d1d3c17548b266544
> Author: Martin Liska <mliska@xxxxxxx>
> Date:   Wed Mar 25 11:01:43 2020 +0100
>
>       Fix handling of --with{,out}-zstd option.
>
>               PR lto/94259
>               * configure.ac: Respect --without-zstd and report
>               error when we can't find header file with --with-zstd.
>               * configure: Regenerate.
>
> Lance
>
> On 9/10/2021 12:21 PM, Anthony de Almeida Lopes via Gcc-help wrote:
>> Thanks, I missed that, but it doesn't seem to help. I still get the
>> undefined references to ZSTD API calls.
>>
>> g++ -std=c++11 -no-pie   -g -O2 -DIN_GCC     -fno-exceptions -fno-rtti
>> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
>> -Wcast-qual -Wno-error=format-diag -Wno-format
>> -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long
>> -Wno-variadic-macros -Wno-overlength-strings -fno-common
>> -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o cc1plus \
>>          cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/class.o
>> cp/constexpr.o cp/constraint.o cp/coroutines.o cp/cp-gimplify.o
>> cp/cp-objcp-common.o cp/cp-ubsan.o cp/cvt.o cp/cxx-pretty-print.o
>> cp/decl.o cp/decl2.o cp/dump.o cp/error.o cp/except.o cp/expr.o
>> cp/friend.o cp/init.o cp/lambda.o cp/lex.o cp/logic.o cp/mangle.o
>> cp/mapper-client.o cp/mapper-resolver.o cp/method.o cp/module.o
>> cp/name-lookup.o cp/optimize.o cp/parser.o cp/pt.o cp/ptree.o cp/rtti.o
>> cp/search.o cp/semantics.o cp/tree.o cp/typeck.o cp/typeck2.o
>> cp/vtable-class-hierarchy.o attribs.o incpath.o c-family/c-common.o
>> c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o
>> c-family/c-gimplify.o c-family/c-indentation.o c-family/c-lex.o
>> c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o
>> c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o
>> c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o
>> c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o
>> c-family/c-spellcheck.o i386-c.o glibc-c.o cc1plus-checksum.o
>> libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a
>> ../libdecnumber/libdecnumber.a ../libcody/libcody.a  \
>>        libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a
>> ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a
>> -L/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/./gmp/.libs
>> -L/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/./mpfr/src/.libs
>> -L/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/./mpc/src/.libs
>> -lmpc -lmpfr -lgmp -rdynamic -ldl  -L./../zlib -lz
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_end_compression(lto_compression_stream*)':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:135:
>> undefined reference to `ZSTD_compressBound'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_compression_zstd':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:138:
>> undefined reference to `ZSTD_compress'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:141:
>> undefined reference to `ZSTD_isError'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_end_compression(lto_compression_stream*)':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:120:
>> undefined reference to `ZSTD_maxCLevel'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_normalized_zstd_level':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:121:
>> undefined reference to `ZSTD_maxCLevel'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_compression_zstd':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:142:
>> undefined reference to `ZSTD_getErrorName'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function
>> `lto_end_uncompression(lto_compression_stream*,
>> lto_compression)lto-compress.o':
>> : in function
>> `/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:161:
>> undefined reference to
>> `lto_end_compression(lto_compression_stream*)ZSTD_getFrameContentSize':
>> '
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:lto-compress.o:
>> in function `135lto_uncompression_zstd: undefined reference to `':
>> ZSTD_compressBound/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:'
>> 168: undefined reference to
>> `ZSTD_decompress/home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld'
>> :
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ldlto-compress.o:
>> : in function
>> `/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:lto_compression_zstd170':
>> : undefined reference to
>> `ZSTD_isError/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:'
>> 138: undefined reference to
>> `ZSTD_compress/home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld'
>> :
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c::
>> 171/home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c::
>> undefined reference to `141ZSTD_getErrorName: undefined reference to `'
>> ZSTD_isError'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_end_compression(lto_compression_stream*)':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:120:
>> undefined reference to `ZSTD_maxCLevel'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_normalized_zstd_level':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:121:
>> undefined reference to `ZSTD_maxCLevel'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_compression_zstd':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:142:
>> undefined reference to `ZSTD_getErrorName'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function
>> `lto_end_uncompression(lto_compression_stream*, lto_compression)':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:161:
>> undefined reference to `ZSTD_getFrameContentSize'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> lto-compress.o: in function `lto_uncompression_zstd':
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:168:
>> undefined reference to `ZSTD_decompress'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:170:
>> undefined reference to `ZSTD_isError'
>> /home/guerrilla/Projects/Boots/distro/root/bootstrap/bin/ld:
>> /home/guerrilla/Projects/Boots/src/gcc-11.2.0/build/gcc/../../gcc/lto-compress.c:171:
>> undefined reference to `ZSTD_getErrorName'
>> collect2: error: ld returned 1 exit status
>> make[3]: *** [../../gcc/c/Make-lang.in:87: cc1] Error 1
>> make[3]: *** Waiting for unfinished jobs....
>> collect2: error: ld returned 1 exit status
>> make[3]: *** [../../gcc/cp/Make-lang.in:136: cc1plus] Error 1
>>
>> On 9/10/21 7:46 PM, Lance Fredrickson via Gcc-help wrote:
>>> 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