http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47740
Summary: new specs function to avoid vxworks cross compiler requiring environment variable to compile Product: gcc Version: 4.4.5 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target AssignedTo: unassig...@gcc.gnu.org ReportedBy: richard_shar...@mitel.com Created attachment 23343 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23343 Patch for gcc/gcc.c gcc/config/vxworks.h gcc/doc/invoke.texi I built a cross compiler for the powerpc-wrs-vxworks target, configured as follows: ../configure \ --target=powerpc-wrs-vxworks \ --disable-multilib --with-endian=big \ --enable-languages="c,c++" \ -with-headers=$WIND_BASE/target/h \ --disable-multilib \ --enable-threads=vxworks This build copied the files specifed in the "-with-headers" to the directory /usr/local/powerpc-wrs-vxworks/sys-include where the are found by the cross compiler. However, what I found was that if I did *not* specify a value for the environment variable WIND_BASE when compiling the cross compiler failed. If I set the value to anything, including an invalid location such as /this/does/not/exist, then the compilation worked fine. The problem was that the specs file was outputting either -idirafter $(WIND_BASE )/target/h or -idirafter $(WIND_USR)/h depending on whether the -mrtp option was given. This might have been useful if the compiler had not already taken a copy of the includes but isn't very useful as it is. (It doesn't even allow the use to override the built-in files by setting WIND_BASE unless you also specify -nostdinc.) There were two possible fixes: 1. Disable the getenv part of the specs completely. (In retrospect I think that would have been a better solution. However, I went with #2.) 2. Add an alternate function that will substitute an environment variable if it exists but does not produce an error if it does not exist. Because the getenv function appears after the -idirafter I couldn't simply have the function produce nothing if the variable wasn't set, so I made the function have 3 arguments. There is a prefix string, the variable, and a suffix string. If the variable is not set there is no ouput. If the variable is set the output is the concatenation of the prefix string, the expanded variable and the suffix. This allows the -dirafter word to be specified as the prefix argument. With this change, the specs file changes from %{!nostdinc: %{isystem*} -idirafter %{mrtp: %:getenv(WIND_USR /h) ;: %:getenv(WIND_BASE /target/h)}} %{isystem*} %{mrtp: %:if-getenv(-idirafter\ WIND_USR /h) ;: %:if-getenv(-idirafter\ WIND_BASE /target/h)}} Attached is a context diff file. Richard.