public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Oleg Smolsky <osmolsky@netskope.com>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Building gcc11 with sysroot
Date: Fri, 24 Sep 2021 14:13:42 -0700	[thread overview]
Message-ID: <CAAucFJcWy3xKgX9pMtrCXNNJiADFXnkxSx6bxuQoU9XDfewjiA@mail.gmail.com> (raw)
In-Reply-To: <CAAucFJfhtiTv_yNfF-d5vR22bPNKrhC4WwMZG3fkA2b2pAKB0w@mail.gmail.com>

...and the workaround for that issue was to add `--target=x86_64-linux-gnu`
which, as I understand it, switches the build into the cross-compiler mode.
I think there was some variance in the treatment of that flag in GCC
versions 7/10/11...

Curiously, `--target=x86_64-pc-linux-gnu` does not help... I am guessing
that matches the host... And also, the generated executable bundle only has
full names like `x86_64-linux-gnu-c++`, there are no `c++`, `cpp` etc.

Can anyone shed some light on this aspect of the build process please?



On Thu, Sep 23, 2021 at 6:42 PM Oleg Smolsky <osmolsky@netskope.com> wrote:

> Hello there! I'm trying to setup a GCC 11.2 using --with-sysroot=$sysroot
> (into which glibc is already installed). I get far enough to have `xgcc`
> executable (which works). The executable itself is configured to get glibc
> from sysroot (I did that via LDFLAGS):
>
> ```
> $ ldd ./gcc/xgcc
>         linux-vdso.so.1 (0x00007ffec27d7000)
>         libm.so.6 => /opt/sysroot/usr/lib/libm.so.6 (0x00007fc12463c000)
>         libc.so.6 => /opt/sysroot/usr/lib/libc.so.6 (0x00007fc124440000)
>         /opt/sysroot/usr/lib/ld-linux-x86-64.so.2 =>
> /lib64/ld-linux-x86-64.so.2 (0x00007fc124718000)
> ```
>
> where
> LDFLAGS="-Wl,--dynamic-linker,$sysroot/usr/lib/ld-linux-x86-64.so.2,--rpath,$sysroot/usr/lib"
>
> Things break a little further down the road when building libgomp:
>
> checking whether we are cross compiling... configure: error: in
> `.../gcc11sr/_obj/x86_64-pc-linux-gnu/libgomp':
> configure: error: cannot run C compiled programs.
>
> The issue here, it seems, is the absence of LDFLAGS that I had passed to
> the top-level `configure` script. We can see the compiler invocation in the
> log:
>
> configure:3996: .../gcc11sr/_obj/./gcc/xgcc -B.../gcc11sr/_obj/./gcc/
> -B/opt/gcc-11sr/x86_64-pc-linux-gnu/bin/
> -B/opt/gcc-11sr/x86_64-pc-linux-gnu/lib/ -isystem
> /opt/gcc-11sr/x86_64-pc-linux-gnu/include -isystem
> /opt/gcc-11sr/x86_64-pc-linux-gnu/sys-include    -o conftest -g -O2
> conftest.c  >&5
>
> The compiler yields a correctly-formed executable when I take that very
> command line and add LDFLAGS.
>
> So, finally my question: is this the right way to build a "sysrooted" GCC?
> IIRC this recipe worked in the GCC7 days...
>
> Thanks in advance,
> Oleg.
>

  reply	other threads:[~2021-09-24 21:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24  1:42 Oleg Smolsky
2021-09-24 21:13 ` Oleg Smolsky [this message]
2021-09-25 10:11   ` Xi Ruoyao
2021-09-28 16:09     ` [EXTERNAL] " Oleg Smolsky
2021-09-28 18:42       ` Segher Boessenkool
2021-09-28 21:34         ` Oleg Smolsky

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=CAAucFJcWy3xKgX9pMtrCXNNJiADFXnkxSx6bxuQoU9XDfewjiA@mail.gmail.com \
    --to=osmolsky@netskope.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).