Skip to content

clang-scan-deps unable to find system headers in p1689 format #61006

@mordante

Description

@mordante

While testing modules with CMake I ran into an issue that some system headers are not found.

I tested with Debian clang version 17.0.0 (++20230226071743+b8df886c1e2a-1~exp1~20230226071846.576)

And this code

module;
#include <vector>
export module test;
void test() {}

Compilation with Clang succeeds

/usr/bin/clang++-17 -stdlib=libc++ -std=c++20 -x c++ test.cppm -c -o /tmp/test.cppm.o

But testing with the dependency scanner

/usr/bin/clang-scan-deps-17 -format=p1689 -- /usr/bin/clang++-17 -stdlib=libc++ -std=c++20 -x c++ test.cppm -c -o /tmp/test.cppm.o

Fails with the following output

Error while scanning dependencies for test.cppm:
In file included from test.cppm:3:
In file included from /usr/bin/../include/c++/v1/vector:281:
In file included from /usr/bin/../include/c++/v1/__algorithm/copy.h:12:
In file included from /usr/bin/../include/c++/v1/__algorithm/copy_move_common.h:12:
In file included from /usr/bin/../include/c++/v1/__algorithm/iterator_operations.h:15:
In file included from /usr/bin/../include/c++/v1/__iterator/advance.h:26:
In file included from /usr/bin/../include/c++/v1/cstdlib:87:
In file included from /usr/bin/../include/c++/v1/stdlib.h:94:
In file included from /usr/include/stdlib.h:31:
/usr/bin/../include/c++/v1/stddef.h:17:15: fatal error: 'stddef.h' file not found
{
  "revision": 0,
  "rules": [],
  "version": 1
}

The line where the header is not found uses #include_next <stddef.h> to include stddef.h.

I get similar errors when I don't specify libc++ and use libstdc++.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions