From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id DF8F63858405 for ; Fri, 10 Sep 2021 17:45:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DF8F63858405 Received: by mail-pg1-x532.google.com with SMTP id k24so2479438pgh.8 for ; Fri, 10 Sep 2021 10:45:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=C8AZnvJCYrj7J514u3/XFHlxnott3fvk2B/an8VgcoQ=; b=n/YNPvqZxuuvymGJYScI67NrkHsaOz749sfnblGzvrTTgI05Imytc5p1iUjh78p6IF VwOE30OmwRFts58JZZkVnN3ARP8CpB5/ekKiBTh/dvTsmEBsU4jt6d725HdZQbk6RdnL 3sQPbcAYxxU0I9ywTnyhutizHg1qpb394xNHdJMrQYp5yQNbDNsDgrLIfQntBOMt76mw 9HjLhedu/YChx8f95V+99g/YIG3SVdt/eEUvqLiN4MC2qxXMTCRHMfeBKglVyjDFftPd zoUGS6eMOOhIyqepXp6JbRAIWblyibRpzaeirrkdhSqkiVCoNC0Z5FgxXiZ7oWe9WAX9 VdIw== X-Gm-Message-State: AOAM530OaI1ugxfj6vwKxPOuytObk+KrpzZZymrpQrkZvro+wd/028G5 WUgwZ+KGHQwquK7xs3VOGam4ZAniVT+yww== X-Google-Smtp-Source: ABdhPJzsIyZRFOahtKliKYUuY5MSqbFlupPugawAjAdnpi7IoqIkUpu4LeZNccs06VBrqR3RJ2eL/g== X-Received: by 2002:a63:df05:: with SMTP id u5mr8110886pgg.323.1631295914597; Fri, 10 Sep 2021 10:45:14 -0700 (PDT) Received: from [10.0.0.87] (96-82-249-149-static.hfc.comcastbusiness.net. [96.82.249.149]) by smtp.gmail.com with ESMTPSA id y5sm6052969pgs.27.2021.09.10.10.45.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Sep 2021 10:45:14 -0700 (PDT) Subject: Re: Building a host-isolated gcc without faking cross-compiling To: gcc-help@gcc.gnu.org References: From: Lance Fredrickson Message-ID: <86a5dbe8-28c1-3113-b585-4e195c3f6534@gmail.com> Date: Fri, 10 Sep 2021 11:46:44 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, HTML_OBFUSCATE_10_20, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Sep 2021 17:45:17 -0000 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 > >