From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 1914A3851166 for ; Thu, 20 Oct 2022 10:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1914A3851166 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-x535.google.com with SMTP id e18so29241143edj.3 for ; Thu, 20 Oct 2022 03:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ykm/PZz5HA8aU9xkBXyftaI2cetK0ihH4kjR34FhsvA=; b=ohUKKQ9t1PeygRT2GyMCRU9VaIfzvKUsuveDzXqb6rtQjoQRaFXLfYRqWSg8iXcMOu YUkd9b5Cl3kCkpBJNHpFMrZ6sNYMj8VdXOkOzmtErQb0SkQ5FtjQmReyabRf6zW2DSAD iFSdwIrcmQuHAV0aiQxcCc3eV/bv5rIZc8s8ZinHg7tqEOyKEX9X6TYuZCRV2HtKfYxq mpmn+pd4rvEx5pUCWMOZKj/p2LsiX5Eo04aKqao1bBFrKtCOQA5pztZnPxYBQHXw3qmc iT09BoxPCeuiQi0HYtZt8Lx8PpCaYiZ3lB19UylbY+yS/zzH0jNo1Hp/L49X9IxOi1Xq BYsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ykm/PZz5HA8aU9xkBXyftaI2cetK0ihH4kjR34FhsvA=; b=lzDyJlhRCe4ZulxUt/Z9Gnmkkm9AXfAjtUQt5JeRTrSCKDM8kd9G1gwLj2HUeBzAWu h6L140RDywgjw260p8MIxlIFODSTjzUEZsBnUQmpKerjGst3de8uiWf3H2+EOMDOd7Vf wZIGcLPt9eiBiIDYI+cyNpDiaThSkT0FfyLvHs9oM0/Ds+vyqC6r4EPE1mvx9Udmpgsd +sK+cm+I+eWAt0kweqP88ORz6ZasGS4QZ7bSoUoUiQxkM1UGCHo9WvfI7y6mAElRNLfT 3H8DACrViZIWvlM0h/y4W54dwjDpCw3GDCzyxisudnfyq/CrNnP6skyzXJhU0djf1TT3 8UlQ== X-Gm-Message-State: ACrzQf0v/9jCsbi/QJhE2JVg3xSQ8H6rtfjBQI1bVZyJ044pfb16eryg bMi+U7PToOGQuxD1V8D4ooFBctUXqJ+ibdOZ4tU= X-Google-Smtp-Source: AMsMyM7ooKwwm6NDdKFVb12iKS2hUdHunss7t8XfvAJM4G3rQyU5YUnjB8/5cN3NgSbOxBXAdm1qTUKh4CxpDxcBNjs= X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr11352135edz.301.1666262388822; Thu, 20 Oct 2022 03:39:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Thu, 20 Oct 2022 11:39:37 +0100 Message-ID: Subject: Re: How to make sure GCC links only with old runtime that is supplied with the system To: olologin Cc: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 20 Oct 2022 at 11:35, olologin via Gcc-help 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.