Mark Mitchell - PATCH: getenv specs function, use for VxWorks (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Mark Mitchell
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Feb 2007 15:48:51 -0800
- Subject: PATCH: getenv specs function, use for VxWorks
- Reply-to: mark at codesourcery dot com
When building software for VxWorks, you start by running a script that comes with VxWorks to set up your shell. It sets some environment variables that point at the VxWorks installation. Most VxWorks tools -- except GCC -- then look at those environment variables to locate the VxWorks headers and libraries.
The current FSF version of config/vxworks.h hard-codes a CodeSourcery-specific path to search for headers and libraries (which is not even a default location for installing VxWorks) which is clearly wrong. Shipping VxWorks compilers use the approach in this patch, which honors the environment variables.
In particular, this patch adds a new builtin spec function ("getenv") which returns the value of an environment variable. So, the specs can get the destination patch.
I tested this patch by building a VxWorks-targeted compiler from FSF mainline and playing with the driver. The compiler itself doesn't fully work, but I could verify the driver was doing the right thing.
Committed to mainline.
-- Mark Mitchell CodeSourcery mark@codesourcery.com (650) 331-3385 x713
2007-02-22 Mark Mitchell mark@codesourcery.com
* gcc.c (getenv_spec_function): New function.
(static_spec_functions): Add it.
* config/vxworks.h (VXWORKS_TARGET_DIR): Remove.
(VXWORKS_ADDITIONAL_CPP_SPEC): Use getenv to find the VxWorks
header files.
Index: gcc.c
--- gcc.c (revision 122239) +++ gcc.c (working copy) @@ -350,6 +350,7 @@ static void init_gcc_specs (struct obsta static const char *convert_filename (const char *, int, int); #endif +static const char *getenv_spec_function (int, const char **); static const char *if_exists_spec_function (int, const char **); static const char *if_exists_else_spec_function (int, const char **); static const char *replace_outfile_spec_function (int, const char **); @@ -1601,6 +1602,7 @@ static struct spec_list specs = (struct static const struct spec_function static_spec_functions[] = { + { "getenv", getenv_spec_function }, { "if-exists", if_exists_spec_function }, { "if-exists-else", if_exists_else_spec_function }, { "replace-outfile", replace_outfile_spec_function }, @@ -7645,6 +7647,27 @@ print_multilib_info (void) } } +/ getenv built-in spec function. + + Returns the value of the environment variable given by its first + argument, concatenated with the second argument. If the + environment variable is not defined, a fatal error is issued. */ + +static const char * +getenv_spec_function (int argc, const char **argv) +{ + char value; + + if (argc != 2) + return NULL; + + value = getenv (argv[0]); + if (!value) + fatal ("environment variable "%s" not defined", argv[0]); + + return concat (value, argv[1], NULL); +} + / if-exists built-in spec function. Checks to see if the file specified by the absolute pathname in Index: config/vxworks.h
--- config/vxworks.h (revision 122239) +++ config/vxworks.h (working copy) @@ -26,8 +26,11 @@ Software Foundation, 51 Franklin Street, like a traditional Unix, with more external files. Most of our specs must be aware of the difference. */
-/* The directory containing the VxWorks target headers. / -#define VXWORKS_TARGET_DIR "/home/tornado/base6/target" +/ We look for the VxWorks header files using the environment
- variables that are set in VxWorks to indicate the location of the
- system header files. We use -idirafter so that the GCC's own
- header-file directories (containing <stddef.h>, etc.) come before
- the VxWorks system header directories. */
/* Since we provide a default -isystem, expand -isystem on the command
line early. /
@@ -35,9 +38,9 @@ Software Foundation, 51 Franklin Street,
#define VXWORKS_ADDITIONAL_CPP_SPEC "
%{!nostdinc:%{isystem}}
%{mrtp: -D__RTP__=1
- %{!nostdinc:-isystem " VXWORKS_TARGET_DIR "/usr/h}}
+ %{!nostdinc:-idirafter %:getenv(WIND_USR /h)}}
%{!mrtp:-D_WRS_KERNEL=1
- %{!nostdinc:-isystem " VXWORKS_TARGET_DIR "/h}}"
%{!nostdinc:-idirafter %:getenv(WIND_BASE /target/h)}}"
/* The references to __init and __fini will be satisfied by libc_internal.a. */
- Follow-Ups:
- Re: PATCH: getenv specs function, use for VxWorks
* From: Ian Lance Taylor
- Re: PATCH: getenv specs function, use for VxWorks
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |