public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: gcc-patches@gcc.gnu.org
Subject: Support $SYSROOT for = in -I etc.
Date: Thu, 01 Jun 2017 08:37:00 -0000	[thread overview]
Message-ID: <yddy3tcnlwf.fsf@CeBiTec.Uni-Bielefeld.DE> (raw)

[-- Attachment #1: Type: text/plain, Size: 992 bytes --]

GNU ld recently gained support for a $SYSROOT token in -L to denote the
sysroot prefix (similar to $ORIGIN in rpath), to be more intuitive than
the current use of '=' for that purpose:

	PR ld/21251
        Support $SYSROOT in ld -L and INPUT command
	https://sourceware.org/bugzilla/show_bug.cgi?id=21251

gcc's -I etc. options currently also support '=' for that purpose only,
and it seems sensible to allow $SYSROOT here for the same reasons.

The following patch implements just that, bootstrapped on
i386-pc-solaris2.12 and sparc-sun-solaris2.12, only manually tested
since currently there are no --sysroot tests whatsoever in the
testsuite.

Ok for mainline?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2017-05-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* incpath.c (add_sysroot_to_chain): Allow for $SYSROOT prefix.
	* doc/cppdiropts.texi (-I @var{dir}): Document it.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: I-sysroot.patch --]
[-- Type: text/x-patch, Size: 1692 bytes --]

# HG changeset patch
# Parent  3c4ef3ebcd067bdeea49ba77eab3ed9b650e0d58
Support $SYSROOT for = in -I etc.

diff --git a/gcc/doc/cppdiropts.texi b/gcc/doc/cppdiropts.texi
--- 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
--- a/gcc/incpath.c
+++ b/gcc/incpath.c
@@ -314,7 +314,7 @@ remove_duplicates (cpp_reader *pfile, st
 }
 
 /* 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 *sysroo
   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,

                 reply	other threads:[~2017-06-01  8:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yddy3tcnlwf.fsf@CeBiTec.Uni-Bielefeld.DE \
    --to=ro@cebitec.uni-bielefeld.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).