public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Lance Fredrickson <lancethepants@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Re: Building a host-isolated gcc without faking cross-compiling
Date: Fri, 10 Sep 2021 12:42:23 -0600	[thread overview]
Message-ID: <1f4faf06-24ab-886b-d3db-a5fac2b34c15@gmail.com> (raw)
In-Reply-To: <97c0acc2-5be0-30f3-6f2f-4b60eef95cb9@falsifiable.net>

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@suse.cz>
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
>>>
>>>


  reply	other threads:[~2021-09-10 18:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 16:54 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 [this message]
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

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=1f4faf06-24ab-886b-d3db-a5fac2b34c15@gmail.com \
    --to=lancethepants@gmail.com \
    --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).