From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from elaine.keithp.com (home.keithp.com [63.227.221.253]) by sourceware.org (Postfix) with ESMTPS id ED36E38582BF for ; Fri, 23 Sep 2022 18:40:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ED36E38582BF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=keithp.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=keithp.com Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id B74163F333CF for ; Fri, 23 Sep 2022 11:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1663958452; bh=K/Jn9OSyoMadXMWTF1Ymhzlc2wc5zygsRDL0jmCA60c=; h=From:To:Subject:In-Reply-To:References:Date:From; b=fidMFQMdWJ+8bKw3NiKK2elVIDc+Fn7O2ugw223Yd9nP+ka+H1I1rB1xZTc6t3gNW Sb/g9FToRfzKAXGDhstnqe7iSVzGphcscTq4VeAK/BQXQCAO+Ioeqj98J+/cgmRcjv Pmh+huoy48fjo+kdbkzLKk/LBd/NGTBNm7e7YDUE0uXdsWwZMdu9gOKnM79T3fZDco Xs/8L7QNvn75WLc5pBJhsnpbpBxmfjo1j/iYk13WaQvRY6OP6dBMhy4eJrH37o4gMD QduRP3d/7XeOCHVdOCzEC/FTY8KB65jXIoz0+AX7n3BFw4V6HBRZ9Elltcqw7DKMkV YFCc1Dbv2RaYA== X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id q-6acT_cat4X for ; Fri, 23 Sep 2022 11:40:52 -0700 (PDT) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id 3F2D73F333C0 for ; Fri, 23 Sep 2022 11:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1663958452; bh=K/Jn9OSyoMadXMWTF1Ymhzlc2wc5zygsRDL0jmCA60c=; h=From:To:Subject:In-Reply-To:References:Date:From; b=fidMFQMdWJ+8bKw3NiKK2elVIDc+Fn7O2ugw223Yd9nP+ka+H1I1rB1xZTc6t3gNW Sb/g9FToRfzKAXGDhstnqe7iSVzGphcscTq4VeAK/BQXQCAO+Ioeqj98J+/cgmRcjv Pmh+huoy48fjo+kdbkzLKk/LBd/NGTBNm7e7YDUE0uXdsWwZMdu9gOKnM79T3fZDco Xs/8L7QNvn75WLc5pBJhsnpbpBxmfjo1j/iYk13WaQvRY6OP6dBMhy4eJrH37o4gMD QduRP3d/7XeOCHVdOCzEC/FTY8KB65jXIoz0+AX7n3BFw4V6HBRZ9Elltcqw7DKMkV YFCc1Dbv2RaYA== Received: by keithp.com (Postfix, from userid 1000) id E5FC21E601D6; Fri, 23 Sep 2022 11:40:51 -0700 (PDT) From: Keith Packard To: gcc-patches@gcc.gnu.org Subject: Making gcc toolchain installs relocatable In-Reply-To: <20220827051422.1023580-1-keithp@keithp.com> References: <20220827051422.1023580-1-keithp@keithp.com> Date: Fri, 23 Sep 2022 11:40:51 -0700 Message-ID: <877d1ux7bg.fsf@keithp.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,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: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. 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. 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 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 patch makes it possible for the .specs file fragment to provide the default path as a fallback for a missing environment variable so that, instead of exiting, the correct value will be substituted instead. By doing this, I can create portable .specs file fragments which work wherever the toolchain is installed. This patch seemed like the least invasive approach to solving this problem, but there are two other approaches that could work, and which would make the .specs files simpler: 1. Always set the GCC_EXEC_PREFIX environment variable, even if GCC is executed from the expected location. 2. Make %R in .specs files expand to the appropriate value even if there is no sysroot defined. I'd be happy to provide an implementation of either of those if that would be more acceptable. =2D-=20 =2Dkeith --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw4O3eCVWE9/bQJ2R2yIaaQAAABEFAmMt/bMACgkQ2yIaaQAA ABHjlhAAiC6BT6DANx/lJsQlAdfWgsMdBDzJGS6Kr3zqeP37hp6UEfH5epP8xaBN sgPIRwLGAY4tOHCTWVAaPGSZrbQpdUC3h35Fa5oU1Inbkl+c2lQufhguvYUXehiA Xvfaxqwdg1NtwrIFT0osLY3RO5uAGlkbacR65GZBhqeciha7yAsCnVDI+dMN2fay TF3LrEqeJiziB3T9u1/p52LXy7iuzoeF35Xt94aBeIP00lAYmX4dFfl9jJIJvWP8 nqJLPXyythE+hm0jpAp4FECf/DZ1yp0j3FufHe5hQgjKcuPVwbMyLOZczmuax1eg 0sMa370WzCieb32V6uZN0on+d32Fxus+U+rG1dGnir3ZoOAfLzlqNELDHfBRanj+ HQCgJW6ndXSCKQpVbPMeX9cUzJM47QPUnUEO7qfDc7XCwRXIw2wnBJ1qPsW0XKkm HqtHcReGtKfk0wNV3cDtNQdVNQMtScCTWWwtxC9ADGV/FiA6a5mV+7UTqa26zCNZ fnZ1enZ34X13tJQsrFz+DUvmxbs+Q/IglLiwy1XwfbWzfEH5kA6hyLpMzsPQxToA 4Gr24twkCAeD6O+ak2lM5kV8z1XBdJIsJTmh2n3zweTvgvO8h6zM7f9ZCP2p1Y+7 yd+J7XMxCkHG5ls4wB60yiezgg6YrcQLbI+ZfiCN+tiAMpkMjEI= =aL+/ -----END PGP SIGNATURE----- --=-=-=--