public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug driver/109627] New: [PATCH] driver: Extend 'getenv' function to allow default value
@ 2023-04-25 22:08 keithp at keithp dot com
  2023-04-25 22:10 ` [Bug driver/109627] " keithp at keithp dot com
  0 siblings, 1 reply; 2+ messages in thread
From: keithp at keithp dot com @ 2023-04-25 22:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109627

            Bug ID: 109627
           Summary: [PATCH] driver: Extend 'getenv' function to allow
                    default value
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: keithp at keithp dot com
  Target Milestone: ---

Created attachment 54918
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54918&action=edit
Patch implementing proposed change

Right now, a missing environment variable provided to the 'getenv'
function in a .specs file causes a fatal error. That makes writing a
spec file that uses the GCC_EXEC_PREFIX value difficult as that
variable is only set when the driver has been relocated, but not when
run from the defined location. This makes building a relocatable
toolchain difficult to extend to other ancilary pieces which use specs
files to locate header and library files adjacent to the toolchain.

This patch adds an optional third argument to the getenv function that
can be used to fall back to the standard installation path when the
driver hasn't set GCC_EXEC_PREFIX in the environment.

For example, if an alternate C library is installed in
${prefix}/extra, then this change allows the specs file to locate that
relative to the gcc directory, if gcc is located in the original
installation directory (which would leave GCC_EXEC_PREFIX unset), or
if the gcc tree has been moved to a different location (where gcc
would set GCC_EXEC_PREFIX itself):

*cpp:
-isystem %:getenv(GCC_EXEC_PREFIX ../../extra/include ${prefix}/extra/include)

I considered changing the behavior of either the %R sequence so that
it had a defined behavior when there was no sysroot defined, or making
the driver always set the GCC_EXEC_PREFIX environment variable and
decided that the approach of adding functionality to getenv where it
was previously invalid would cause the least potential for affecting
existing usage.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug driver/109627] [PATCH] driver: Extend 'getenv' function to allow default value
  2023-04-25 22:08 [Bug driver/109627] New: [PATCH] driver: Extend 'getenv' function to allow default value keithp at keithp dot com
@ 2023-04-25 22:10 ` keithp at keithp dot com
  0 siblings, 0 replies; 2+ messages in thread
From: keithp at keithp dot com @ 2023-04-25 22:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109627

--- Comment #1 from keithp at keithp dot com <keithp at keithp dot com> ---
This patch was submitted to the mailing list here:

https://gcc.gnu.org/pipermail/gcc-patches/2022-August/600452.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-25 22:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-25 22:08 [Bug driver/109627] New: [PATCH] driver: Extend 'getenv' function to allow default value keithp at keithp dot com
2023-04-25 22:10 ` [Bug driver/109627] " keithp at keithp dot com

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).