<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Non-standard install of libstdc++, clang does not find a valid gcc install / does not find c++ headers"
   href="http://llvm.org/bugs/show_bug.cgi?id=21152">21152</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Non-standard install of libstdc++, clang does not find a valid gcc install / does not find c++ headers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>phantall+llvm@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>configured with:

PATH=/usr/somenetworkmount/tools/gcc/latest/linux/bin:${PATH}
../../src/llvm/llvm-3.5/configure
--prefix=/usr/somenetworkmount/tools/llvm/3.5/linux/release --enable-optimized
CC=gcc CXX=g++ --with-gcc-toolchain


Everything built, but `make check` failed because it was finding the system
libstdc++.so.6 (I can't control that installation, hence the non-standard
configuration).  I then ran `make check` setting LD_LIBRARY_PATH to compensate
and the checks all passed.

However, it fails to find c++ headers (I hope you'll forgive my not typing
everything out, but I'm testing this on an airgapped machine -- I don't have
the means to test this on a machine with internet access and re-typing the
output of the below commands would be tedious and probably unnecessary):


~ echo '#include <string>' | Release+Asserts/bin/clang -xc++ -v -
clang version 3.5.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
(omitted call to clang with flags)
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include

/mnt/scratch/tools/build/llvm-3.5/Release+Asserts/bin/../lib/clang/3.5.0/include
 /usr/include
End of search list.
<stdin>:1:10: fatal error: "string" file not found
#include <string>
          ^
1 error generated.


I did a little digging; at or around lib/Driver/ToolChains.cpp:3474,
LibDir.str() returns the empty string.  I backtracked from there to line 1237
and getGCCToolchainDir returns the simple string "yes".

So I re-ran the above command with a twist:

echo '#include <string>' | strace -f Release+Asserts/bin/clang -xc++ -v - |&
grep -P '\byes\b'
access("yes", F_OK)                      = -1 ENOENT (No such file or
directory)


... to which I conclude it thinks it has received the `--gcc-toolchain` option
(because it was configured/built using --with-gcc-toolchain?), but it doesn't
have a real path for the gcc toolchain.

To confirm this, I ran the following test and it succeeded:

echo '#include <string>' | Release+Asserts/bin/clang -xc++ -
--gcc-toolchain=/usr/somenetworkmount/tools/gcc/latest/Linux -c -o /tmp/blah.o
test -e /tmp/blah.o && echo 'It worked'
It worked</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>