public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: olologin <olologin@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to make sure GCC links only with old runtime that is supplied with the system
Date: Thu, 20 Oct 2022 11:39:37 +0100	[thread overview]
Message-ID: <CAH6eHdR64=TQaaqj1-rx2z4EWeF9V93Jcz2LRb5TnDbKY5zvxA@mail.gmail.com> (raw)
In-Reply-To: <CAFJ2C7p14s-kkPbN7N5X-0b8oSxLvxJsyOzhgrLgLgFH1_J5ig@mail.gmail.com>

On Thu, 20 Oct 2022 at 11:35, olologin via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Hi everyone,
> I am kind of new to cross-compiling (if we can call my task like this), so
> maybe my question is kind of stupid.
>
> I need to build my project for old runtimes (libstdc++, libgcc_s, etc) that
> came with GCC 6, but I can build my sourcecode only with newest C++
> features, so I chose GCC 12 for this.
> Of course my API is old enough to support GCC 6. And of course I am aware
> of potential risks (like some implementations that can be missing in the
> old runtime).
>
> Currently I am doing this in a very hacky way, and build my project in a
> container that looks like this:
> https://gist.github.com/olologin/b4ba2db91fc5c526d625715b39ac4579
> As you can see, starting from line 73 it gets hacky because I could not
> find a better way to make sure GCC 12 links my code with GCC 6 runtime
> instead of GCC 12.
> So I decided that I should just get rid of all *.so, *.a and *.o files in
> GCC12 install directory, and later when I build my project I point GCC12 on
> GCC6 runtime with -Wl,-L.

This is very undefined and unsupported.

>
> Is there a better way to do this? Maybe I am missing something.
> Thanks in advance.

The GCC Developer Toolset on RHEL and CentOS solves this properly. The
new GCC in the toolset links to libstdc++_nonshared.a which provides
all the new symbols not present in the base version of libstdc++.so.6
from the system compiler. The new additions are statically linked, and
everything that's already present in the base libstdc++.so.6 gets used
from there.

Or you can just statically link your whole project.

      reply	other threads:[~2022-10-20 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 10:33 olologin
2022-10-20 10:39 ` Jonathan Wakely [this message]

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='CAH6eHdR64=TQaaqj1-rx2z4EWeF9V93Jcz2LRb5TnDbKY5zvxA@mail.gmail.com' \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=olologin@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).