From: Rainer Orth Date: Thu, 22 Jun 2017 14:37:17 +0000 (+0000) Subject: Support $SYSROOT for = in -I etc. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a055692a25c10bcd8fd90825cc39709f455335b2;p=gcc.git Support $SYSROOT for = in -I etc. * incpath.c (add_sysroot_to_chain): Allow for $SYSROOT prefix. * doc/cppdiropts.texi (-I @var{dir}): Document it. From-SVN: r249560 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4b78674ee3f..a2340c0f253 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-06-22 Rainer Orth + + * incpath.c (add_sysroot_to_chain): Allow for $SYSROOT prefix. + * doc/cppdiropts.texi (-I @var{dir}): Document it. + 2016-06-22 Richard Biener * tree-vect-loop.c (vect_model_reduction_cost): Handle diff --git a/gcc/doc/cppdiropts.texi b/gcc/doc/cppdiropts.texi index 1f72649937c..eee2b5cede8 100644 --- a/gcc/doc/cppdiropts.texi +++ b/gcc/doc/cppdiropts.texi @@ -22,8 +22,9 @@ for header files during preprocessing. @ifset cppmanual @xref{Search Path}. @end ifset -If @var{dir} begins with @samp{=}, then the @samp{=} is replaced -by the sysroot prefix; see @option{--sysroot} and @option{-isysroot}. +If @var{dir} begins with @samp{=} or @code{$SYSROOT}, then the @samp{=} +or @code{$SYSROOT} is replaced by the sysroot prefix; see +@option{--sysroot} and @option{-isysroot}. Directories specified with @option{-iquote} apply only to the quote form of the directive, @code{@w{#include "@var{file}"}}. diff --git a/gcc/incpath.c b/gcc/incpath.c index 98fe5ec9ab3..47942e2547d 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -314,7 +314,7 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head, } /* Add SYSROOT to any user-supplied paths in CHAIN starting with - "=". */ + "=" or "$SYSROOT". */ static void add_sysroot_to_chain (const char *sysroot, int chain) @@ -322,8 +322,15 @@ add_sysroot_to_chain (const char *sysroot, int chain) struct cpp_dir *p; for (p = heads[chain]; p != NULL; p = p->next) - if (p->name[0] == '=' && p->user_supplied_p) - p->name = concat (sysroot, p->name + 1, NULL); + { + if (p->user_supplied_p) + { + if (p->name[0] == '=') + p->name = concat (sysroot, p->name + 1, NULL); + if (strncmp (p->name, "$SYSROOT", strlen ("$SYSROOT")) == 0) + p->name = concat (sysroot, p->name + strlen ("$SYSROOT"), NULL); + } + } } /* Merge the four include chains together in the order quote, bracket,