prevent "undef var" errors on gcc --help or --version
Olivier Hainque
hainque@adacore.com
Fri Jan 8 13:23:00 GMT 2016
Hello,
self-specs setup with configure --with-specs are allowed to contain %:getenv
environment variable references. We are using this capability in a few cases
for cross ports.
In such configurations, gcc --help or gcc --version fail if the variables
aren't defined, like so:
gcc --version
Using built-in specs.
gcc: fatal error: environment variable ‘<VARIABLE_NAME_HERE>’ not defined
compilation terminated.
It is a bit annoying to have to define environment variables just to
be able to retrieve version info. We have been using a close variant of
the attached patch to address this on gcc-4.7 and 4.9 for a while now.
The patch was adjusted for mainline, I tested that it still operates
as intended and performed a regular bootstrap + testsuite cycle showing
no regression on x86_64-linux.
OK to commit ?
Thanks much in advance for your feedback,
With Kind Regards,
Olivier
2016-01-08 Olivier Hainque <hainque@adacore.com>
* gcc.c (spec_undefvar_allowed): New global.
(process_command): Set to true when running for --version or --help
alone, or together.
(getenv_spec_function): When the variable is not defined, use the
variable name as the variable value if we're allowed not to issue
a fatal error.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: spec-undefvar.diff
Type: application/octet-stream
Size: 2231 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160108/892b59ba/attachment.obj>
More information about the Gcc-patches
mailing list