Patchwork avoid '//' prefixes when sysroot is set to '/'

login
register
mail settings
Submitter Matthias Klose
Date Feb. 8, 2012, 12:13 a.m.
Message ID <4F31BE47.2020506@ubuntu.com>
Download mbox | patch
Permalink /patch/140043/
State New
Headers show

Comments

Matthias Klose - Feb. 8, 2012, 12:13 a.m.
On 26.01.2012 18:57, Joseph S. Myers wrote:
> On Thu, 26 Jan 2012, Matthias Klose wrote:
>
>> On 25.01.2012 17:45, Joseph S. Myers wrote:
>>> On Wed, 25 Jan 2012, Matthias Klose wrote:
>>>
>>>> This can end up in generation for dependency files, and other files
>>>> parsing
>>>> the output. The solution I came up with is to check for sysroot set to '/'
>>>> and
>>>> special case this in two places. Afaics, there are no other places.
>>>
>>> I could imagine a sysroot path that isn't just '/' but ends with '/'
>>> resulting in duplicate '/' in the middle of the path - although that's not
>>> a correctness issue in the way that '//' at the start could be, maybe the
>>> best check is actually for '/' at end of sysroot (in which case skip the
>>> '/' at the start of the path within the sysroot)?
>>
>> as in the attached trailing.diff? built and regression tested.
>
> Yes, that's OK (with copyright date updates in incpath.c).

there is one more issue, when configuring

  --with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.7

in that the leading / is stripped away in configure.ac. This case needs an 
explicit check. Ok for the trunk?

   Matthias

* configure.ac (gcc_gxx_include_dir): Don't strip a `/' sysroot value.
Joseph S. Myers - Feb. 8, 2012, 1:01 a.m.
On Wed, 8 Feb 2012, Matthias Klose wrote:

> there is one more issue, when configuring
> 
>  --with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.7
> 
> in that the leading / is stripped away in configure.ac. This case needs an
> explicit check. Ok for the trunk?

This looks like a case where any sysroot with a trailing '/' could 
misbehave and remove a leading '/' that should be left there, i.e. where 
gcc_gxx_without_sysroot should be computed in a way that ignores any 
trailing '/' on the sysroot setting.  Or is such a removal actually 
harmless in all cases except for plain '/' as the sysroot?

Patch

--- a/src/gcc/configure.ac
+++ b/src/gcc/configure.ac
@@ -149,7 +149,9 @@ 
 if test "${with_sysroot+set}" = set; then
   gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'`
   if test "${gcc_gxx_without_sysroot}"; then
-    gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
+    if test x${with_sysroot} != x/; then
+      gcc_gxx_include_dir="${gcc_gxx_without_sysroot}"
+    fi
     gcc_gxx_include_dir_add_sysroot=1
   fi
 fi