public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kai Ruottu <kai.ruottu@wippies.com>
To: papadave <papadavecn@gmail.com>, gcc-help@gcc.gnu.org
Subject: Re: Cross build gcc failed.build=x86_64-freebsd target=x86_64-solaris
Date: Tue, 22 Sep 2020 18:37:27 +0300	[thread overview]
Message-ID: <a7b23484-b12e-123d-727f-96c5c879f066@wippies.com> (raw)
In-Reply-To: <CAGx1O9A8FNN9nsm5nKrBz4eqZBdEj3KKDHOrah3p5KBfEJzdYQ@mail.gmail.com>

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 <dir>" options
(the old order was changed in the 'gcc/cppdefaults.c' or something).


  reply	other threads:[~2020-09-22 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 14:41 papadave
2020-09-22 15:37 ` Kai Ruottu [this message]
2020-09-22 16:07   ` papadave

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=a7b23484-b12e-123d-727f-96c5c879f066@wippies.com \
    --to=kai.ruottu@wippies.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=papadavecn@gmail.com \
    /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).