when setting sysroot to / (for whatever reason), then search directories and
headers start with a double-slash, as seen with gcc -v.
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/4.6/include
//usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
//usr/include/x86_64-linux-gnu
//usr/include
End of search list.
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.6/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/://lib/x86_64-linux-gnu/://lib/../lib/://usr/lib/x86_64-linux-gnu/://usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../://lib/://usr/lib/
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.
With the patch, both the include paths and the library paths start with a single
slash. No regressions seen running the testsuite on x86_64-linux-gnu.
Matthias
2012-01-24 Matthias Klose <d...@ubuntu.com>
* gcc.c (add_sysrooted_prefix): Don't prefix with the system root,
if it is the root directory.
* incpath.c (add_standard_paths): Likewise.
Index: gcc/incpath.c
===================================================================
--- gcc/incpath.c (revision 183421)
+++ gcc/incpath.c (working copy)
@@ -166,7 +166,10 @@
/* Should this directory start with the sysroot? */
if (sysroot && p->add_sysroot)
- str = concat (sysroot, p->fname, NULL);
+ if (IS_DIR_SEPARATOR (*sysroot) && sysroot[1] == '\0')
+ str = concat (p->fname, NULL);
+ else
+ str = concat (sysroot, p->fname, NULL);
else if (!p->add_sysroot && relocated
&& !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
{
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c (revision 183421)
+++ gcc/gcc.c (working copy)
@@ -2443,7 +2443,9 @@
if (!IS_ABSOLUTE_PATH (prefix))
fatal_error ("system path %qs is not absolute", prefix);
- if (target_system_root)
+ if (target_system_root
+ && !IS_DIR_SEPARATOR (*target_system_root)
+ && target_system_root[1] != '\0')
{
if (target_sysroot_suffix)
prefix = concat (target_sysroot_suffix, prefix, NULL);