From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 0FF753858D38 for ; Sun, 20 Nov 2022 18:34:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0FF753858D38 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-pl1-x632.google.com with SMTP id k7so8720134pll.6 for ; Sun, 20 Nov 2022 10:34:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cjnz3uDZRqIfgvZMZwG+z0brGdSQP/hBzsvYVztwHSI=; b=PA3YK4ckWxiHdcLpqikPbfXJPaRGZOVZamJy9aMqm9XrkU1/Mpap8L0eZZEUTvF+PM mO4hQtAjbVfbeKBLqosoZ0tn93tWJPQpgf2X/DNkRIoNIF+I+jzU3XwyigXSQH9VxNIf tsCLp2YGpyQd0sHGTcMbgqmWBTDttFIIHSo07JUpFtTumxVvNyl47YBLjXZnMNNMwOse I1sR5jtVhzSDZ6125FjQdCoscK2lIH5s/jIYrKAKxc3FDePtyBbE7SpvH7ag3v5WS6zY Sb/yogLf+7fu0ZqVozuX9zFJ1z+ZJY9aEciPmjrdWYPvUkNCYTpM2me7D8v9hm5+Hels mP/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cjnz3uDZRqIfgvZMZwG+z0brGdSQP/hBzsvYVztwHSI=; b=hxZaXGHEFIXCMefDmMEIlux2XgJkL3uMIveOgXKZP0vnJ5PddQqO+GQje08leogUks qrBf/8ni/IiKMP5KTMhkOsOMg8kboVc+SJDehh17MDT8lIbXfizki760UtRf3b12sYS1 19OntNMVvmWpqNQn+/svIa1BfGZYJrWE51xXKuw5X6CmgKHkSFIV2qKuVYQpBpq8ssb3 upcEjiC482y5CxgNBQGciFM+5U+EDQ7rF9KqizJQrpKH74KXNlbJiFnnsN7/Jjv2Xu24 O4NQc/nYkorVNjAsbbv9q3SYMeaub5JRZa3JT6H6UGOtYHQZYUPBrlj9BxdS8aa/1vys IWNA== X-Gm-Message-State: ANoB5pk5LU9O2Q2kzJ08v8b6Wr+PfE8a6D0jgoenSjC/bVCNuaby/O9N Xne8wp1wcTe6ykZYMci2OJ8= X-Google-Smtp-Source: AA0mqf6duioJRIfslQGpLRmes4h0eBBtAlOQM2AYyTFiWXQQQGq9t48MruUROfpGMk2MmKSFJ0QJvQ== X-Received: by 2002:a17:902:d510:b0:186:b137:4b42 with SMTP id b16-20020a170902d51000b00186b1374b42mr5837812plg.98.1668969293888; Sun, 20 Nov 2022 10:34:53 -0800 (PST) Received: from ?IPV6:2601:681:8600:13d0::f0a? ([2601:681:8600:13d0::f0a]) by smtp.gmail.com with ESMTPSA id g10-20020a63520a000000b004639c772878sm6068236pgb.48.2022.11.20.10.34.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 20 Nov 2022 10:34:53 -0800 (PST) Message-ID: <7d2ef3bc-a4bc-90a9-14bc-2974488f0f8c@gmail.com> Date: Sun, 20 Nov 2022 11:34:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: Making gcc toolchain installs relocatable Content-Language: en-US To: Keith Packard , gcc-patches@gcc.gnu.org References: <20220827051422.1023580-1-keithp@keithp.com> <877d1ux7bg.fsf@keithp.com> From: Jeff Law In-Reply-To: <877d1ux7bg.fsf@keithp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,NICE_REPLY_A,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 9/23/22 12:40, Keith Packard via Gcc-patches wrote: > I submitted the referenced patch to extend the 'getenv' .specs function > back in August and didn't see any response, so I wanted to provide a bit > more context to see if that would help people understand why I wrote > this. I think most folks generally loathe getting into specs and such. So as one of the reviewers of last resort, I'll see what I can do here. So we already have a goodly amount of infrastructure for relocateable toolchains and relocateable sysroots.  So the natural question that arises is what is it about your environment that is different and prevents those existing mechanisms from working. > > Here's a link to that message: > > https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600452.html > > I'm working with embedded toolchains where I want to distribute binary > versions of binutils, gcc and a suite of libraries in a tar file which > the user can unpack anywhere on their system. To make this work, I need > to create .spec file fragments that can locate the correct libraries > relative to the location where the toolchain was unpacked. So the first half of that paragraph describes what I do all the time.  I've got cross toolchain (gcc, binutils, various libraries & headers).  Those all go into a sysroot and I can relocate the toolchain to anywhere in the filesystem and it "just works". I do this for both bare metal tooclhains using newlib as well as linux-gnu toolchains using glibc. Now you mention you need to create .spec file fragments to locate the correct libraries.  But if the libraries are in the sysroot, then you shouldn't really need to do anything special.  Drop them into the right place and they should relocate just like glibc, newlib, etc. So maybe the problem is you're not using sysroots? > > An easy way to do this, which doesn't depend on a default sysroot value, > is to use the GCC_EXEC_PREFIX environment variable in the .specs Are you not using sysroots at all?  If so, why not? > file. Gcc sets that whenever it discovers that it hasn't been run from > the defined installation path. However, if the user does end up > installing gcc in the defined installation path, then that variable > isn't set at all. If a .specs file attempts to reference the variable, > gcc will emit a fatal error and exit. This is a good hint.  Have you considered building with a sysroot like /wontexist, installing everything into there, then moving the whole thing to a more sensible directory before tarring it up? What's useful about that is you always have a sysroot defined, but it generally won't exist at runtime.  so GCC_EXEC_PREFIX should always be set and everything should "just work" from that point onward. Jeff