This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][DRIVER] Wrong C++ include paths when configuring with "--with-sysroot=/"


Hi all,


To build a GCC-4.9.2 ARM cross-compiler for my setting I need to configure it with "--with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.9.2".
But I found that gcc driver removes the leading slash from resulting paths:

`gcc -print-prog-name=cc1plus` -v
...
ignoring nonexistent directory "usr/include/c++/4.9.2"   <- HERE
ignoring nonexistent directory "usr/include/c++/4.9.2/armv7l-tizen-linux-gnueabi" <- AND HERE
ignoring nonexistent directory "usr/include/c++/4.9.2/backward" <- AND HERE
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include
/usr/local/include
/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include-fixed
/usr/include

It's also reproducible on trunk.

Attached patch fixes this bug.

Thanks,
Pavel.
gcc/Changelog

2015-04-20  Pavel Kopyl  <p.kopyl@samsung.com>

    	* gcc.c (add_sysrooted_prefix): Add new variable 'real_sysroot'.
    	Pass it to 'concat()' instead of 'sysroot_no_trailing_dir_separator'.
    	* incpath.c (add_standard_paths): Likewise.

diff --git a/gcc/gcc.c b/gcc/gcc.c
index c3d44b1..b0b7515 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -2581,11 +2581,19 @@ add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix,
 	sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
 
       if (target_sysroot_suffix)
-	prefix = concat (sysroot_no_trailing_dir_separator,
-			 target_sysroot_suffix, prefix, NULL);
+	{
+	  const char *real_sysroot
+	     = ((target_sysroot_suffix[0] == DIR_SEPARATOR)
+		? sysroot_no_trailing_dir_separator : target_system_root);
+	  prefix = concat (real_sysroot, target_sysroot_suffix, prefix, NULL);
+	}
       else
-	prefix = concat (sysroot_no_trailing_dir_separator, prefix, NULL);
-
+	{
+	  const char *real_sysroot
+	    = ((prefix[0] == DIR_SEPARATOR)
+	       ? sysroot_no_trailing_dir_separator : target_system_root);
+	  prefix = concat (real_sysroot, prefix, NULL);
+	}
       free (sysroot_no_trailing_dir_separator);
 
       /* We have to override this because GCC's notion of sysroot
diff --git a/gcc/incpath.c b/gcc/incpath.c
index f495c0a..2387db6 100644
--- a/gcc/incpath.c
+++ b/gcc/incpath.c
@@ -178,10 +178,14 @@ add_standard_paths (const char *sysroot, const char *iprefix,
 	    {
 	      char *sysroot_no_trailing_dir_separator = xstrdup (sysroot);
 	      size_t sysroot_len = strlen (sysroot);
+	      const char *real_sysroot;
 
 	      if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR)
 		sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
-	      str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);
+
+	      real_sysroot = ((p->fname[0] == DIR_SEPARATOR)
+			      ? sysroot_no_trailing_dir_separator : sysroot);
+	      str = concat (real_sysroot, p->fname, NULL);
 	      free (sysroot_no_trailing_dir_separator);
 	    }
 	  else if (!p->add_sysroot && relocated

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]