<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - clangd-indexer fails using concurrency with multiple directories"
   href="https://bugs.llvm.org/show_bug.cgi?id=41195">41195</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clangd-indexer fails using concurrency with multiple directories
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang-tools-extra
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>clangd
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>shanehird@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I reported this to the mailing list but it may be more appropriate here.

clangd-indexer does not seem to handle compile_commands.json with different
directories. I am able to workaround the problem by passing
'-execute-concurrency=1'.

It seems to work ok with a single directory (i.e with just 'abc' from the
example below), but fails if there are multiple, as in the example below.
I am working with revision 356635 of clangd.

With a directory structure of:

./
./abc
./abc/test.h
./abc/test.cc
./def
./def/ytest.h
./def/xtest.cc
./compile_commands.json

And a compile_commands.json of:

[
    {
        "arguments": [
            "g++",
            "-c",
            "-o",
            "test.o",
            "test.cc"
        ],
        "directory": "/home/test/abc",
        "file": "test.cc"
    },
    {
        "arguments": [
            "g++",
            "-c",
            "-o",
            "xtest.o",
            "xtest.cc"
        ],
        "directory": "/home/test/def",
        "file": "xtest.cc"
    }
]

I receive the error:

[test]$ clangd-indexer -executor=all-TUs compile_commands.json  > clangd.dex
[1/2] Processing file /home/test/abc/test.cc
[2/2] Processing file /home/test/def/xtest.cc
error: no such file or directory: 'test.cc'
error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''
Error while processing /home/test/abc/test.cc.
Failed to run action on /home/test/abc/test.cc


I assume it may be related to a non-thread-safe chdir somewhere in the code.</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>