http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56896



             Bug #: 56896

           Summary: Missing DIR_SEPARATOR if --with-gxx-include-dir

                    configured as subdir of sysroot

    Classification: Unclassified

           Product: gcc

           Version: 4.9.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: rmansfi...@qnx.com





If gcc is configured with --with-sysroot=<path> and

--with-gxx-include-dir=<path>/<subpath> then gcc_gxx_include_dir will end up as

a relative path, and then incpath.c will trip the trailing sysroot

DIR_SEPARATOR and construct an invalid path. 



e.g.



~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -v

Using built-in specs.

COLLECT_GCC=./xgcc

Target: x86_64-unknown-linux-gnu

Configured with: ../configure --enable-languages=c++ --disable-bootstrap

--with-gxx-include-dir=/home/ryan/foo/bar/usr/include/4.9.0

--with-sysroot=/home/ryan/foo/bar/

Thread model: posix

gcc version 4.9.0 20130409 (experimental) [trunk revision 197644] (GCC) 

## --------- ##

## Platform. ##

~/gnu/gcc/trunk/tmp$ grep -nr gcc_gxx_include_dir *

gcc/Makefile:623:gcc_gxx_include_dir = usr/include/4.9.0

gcc/Makefile:624:gcc_gxx_include_dir_add_sysroot = 1

gcc/Makefile:1108:    "gxx_include_dir=$(gcc_gxx_include_dir)" \

gcc/Makefile:4055:  -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \

gcc/Makefile:4056: 

-DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \

gcc/Makefile:4057: 

-DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\"

\

gcc/Makefile:4058: 

-DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \

gcc/config.log:6339:gcc_gxx_include_dir='usr/include/4.9.0'

gcc/config.log:6340:gcc_gxx_include_dir_add_sysroot='1'

gcc/config.status:682:S["gcc_gxx_include_dir_add_sysroot"]="1"

gcc/config.status:683:S["gcc_gxx_include_dir"]="usr/include/4.9.0"





~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -B. ~/hw.cc -v

Reading specs from ./specs

COLLECT_GCC=./xgcc

COLLECT_LTO_WRAPPER=./lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ../configure --enable-languages=c++ --disable-bootstrap

--with-gxx-include-dir=/home/ryan/foo/bar/usr/include/4.9.0

--with-sysroot=/home/ryan/foo/bar/

Thread model: posix

gcc version 4.9.0 20130409 (experimental) [trunk revision 197644] (GCC) 

COLLECT_GCC_OPTIONS='-B' '.' '-v' '-mtune=generic' '-march=x86-64'

 ./cc1plus -quiet -v -iprefix

/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/

-isystem ./include -isystem ./include-fixed -D_GNU_SOURCE /home/ryan/hw.cc

-quiet -dumpbase hw.cc -mtune=generic -march=x86-64 -auxbase hw -version -o

/tmp/cclOMQFL.s

GNU C++ (GCC) version 4.9.0 20130409 (experimental) [trunk revision 197644]

(x86_64-unknown-linux-gnu)

    compiled by GNU C version 4.7.2, GMP version 5.0.2, MPFR version 3.1.0-p3,

MPC version 0.9

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096

ignoring nonexistent directory

"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include"

ignoring nonexistent directory

"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed"

ignoring nonexistent directory

"/home/ryan/gnu/gcc/trunk/tmp/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include"

ignoring nonexistent directory "/home/ryan/foo/barusr/include/4.9.0"

ignoring nonexistent directory

"/home/ryan/foo/barusr/include/4.9.0/x86_64-unknown-linux-gnu"

ignoring nonexistent directory "/home/ryan/foo/barusr/include/4.9.0/backward"

<snip>



Or:



~/gnu/gcc/trunk/tmp/gcc$ ./xgcc -B. ~/hw.cc --sysroot=/foo/bar

<snip>

ignoring nonexistent directory "/foo/barusr/include/4.9.0"

ignoring nonexistent directory

"/foo/barusr/include/4.9.0/x86_64-unknown-linux-gnu"

ignoring nonexistent directory "/foo/barusr/include/4.9.0/backward"



I'm not sure if the following is sufficient, or if the gcc_gxx_include_dir

should never end up without a leading DIR_SEPARATOR. 



Index: gcc/incpath.c

===================================================================

--- gcc/incpath.c    (revision 197644)

+++ gcc/incpath.c    (working copy)

@@ -179,7 +179,8 @@

           char *sysroot_no_trailing_dir_separator = xstrdup (sysroot);

           size_t sysroot_len = strlen (sysroot);



-          if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR)

+          if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR

+          && p->fname[0] == DIR_SEPARATOR)

         sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';

           str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);

           free (sysroot_no_trailing_dir_separator);

Reply via email to