From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fgw21-4.mail.saunalahti.fi (fgw21-4.mail.saunalahti.fi [62.142.5.108]) by sourceware.org (Postfix) with ESMTPS id 02EB13851C07 for ; Tue, 22 Sep 2020 15:37:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 02EB13851C07 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=wippies.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kai.ruottu@wippies.com Received: from [10.0.0.34] (mobile-access-5d6a5d-213.dhcp.inet.fi [93.106.93.213]) by fgw21.mail.saunalahti.fi (Halon) with ESMTPSA id 84bd6495-fce9-11ea-9eb8-005056bdd08f; Tue, 22 Sep 2020 18:37:27 +0300 (EEST) Subject: Re: Cross build gcc failed.build=x86_64-freebsd target=x86_64-solaris To: papadave , gcc-help@gcc.gnu.org References: From: Kai Ruottu Message-ID: Date: Tue, 22 Sep 2020 18:37:27 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: Tue, 22 Sep 2020 15:37:32 -0000 papadave via Gcc-help kirjoitti 22.9.2020 klo 17.41: > Hello, > Recently I was trying to cross build a latest gcc on FreeBSD amd64 ,and > target is x86_64 Solaris. I built the binutils with following configure: > > ../configure --build=x86_64-unknown-freebsd12 > --target=x86_64-unknown-solaris2.11 --prefix=/opt/toolchains > --sysconfdir=/etc --localstatedir=/var --libexecdir='${prefix}/lib' > --with-system-zlib --with-gmp=/usr/local --with-mpfr=/usr/local > --disable-rpath --enable-deterministic-archives --enable-nls --enable-gold > --enable-ld --enable-plugins > > Later I configured the gcc in a new subdirectory as follows: > > ../gcc-10.2.0/configure --build=x86_64-unknown-freebsd12 > --target=x86_64-unknown-solaris2.11 --disable-bootstrap > --enable-gnu-indirect-function --prefix=/opt/toolchains --sysconfdir=/etc > --localstatedir=/var --libexecdir='${prefix}/lib/gcc' --disable-rpath > --program-prefix=x86_64-unknown-solaris2.11- --program-suffix=-10.2 > --with-gnu-as --with-gnu-ld --with-gmp=/usr/local --with-pkgversion=Rivoreo > --with-system-zlib --enable-languages=c,c++,objc,fortran,obj-c++,go > --enable-multilib Ok, for a crosscompiler one needs just the same target C library stuff (here for x86_64-unknown-solaris2.11) as is needed in a native GCC build for the target. Usually it will be copied/unpacked into a chosen $sysroot on the host machine (here x86_64-unknown-freebsd12).  And a "--with-sysroot=$sysroot" option is given both in binutils and GCC configure commands to tell to "ld" and "gcc" where the target libraries and headers are.  In your case choosing the "/opt/toolchains/host-x86_64-unknown-solaris2.11" as the $sysroot could be one choice if your aim is to put more crosstoolchains for all kind of targets into the "/opt/toolchains".  And use the "/opt/toolchains/host-$target" as the standard for the install places for their C libraries. I remember the "native install" for Solaris2.x C library being quite complicated so using the default "$prefix/$target/include" and "$prefix/$target/lib" would need some scratching of one's head to get everything in the Solaris2.x C library being found there.  Much easier is to let it be similar to the native scheme in the $sysroot (the cross "/" is the $sysroot on the host system). > -B/opt/toolchains/x86_64-unknown-solaris2.11/bin/ > -B/opt/toolchains/x86_64-unknown-solaris2.11/lib/ > -isystem /opt/toolchains/x86_64-unknown-solaris2.11/include > -isystem /opt/toolchains/x86_64-unknown-solaris2.11/sys-include These tell where the target C library will be searched now. Please don't ask for what purpose the "sys-include" is there.  Just take it as a relic from the ancient time when someone maybe knew why he/she needed it :) The funny thing is that it will be searched before the "include" unless the order is the same as given in the "-isystem " options (the old order was changed in the 'gcc/cppdefaults.c' or something).