]> granicus.if.org Git - clang/commit
[Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl
authorFangrui Song <maskray@google.com>
Tue, 6 Aug 2019 06:25:32 +0000 (06:25 +0000)
committerFangrui Song <maskray@google.com>
Tue, 6 Aug 2019 06:25:32 +0000 (06:25 +0000)
commitdc9ef6a5a27d86a7a720c7d05452f19d433c15d3
tree94cf9ed4964f8a103202e5209c4b1e1466a31d9c
parent3a4107b072d4e4c7f986b5dcd89282c87eb87592
[Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl

On a musl-based Linux distribution, stdalign.h stdarg.h stdbool.h stddef.h stdint.h stdnoreturn.h are expected to be provided by musl (/usr/include), instead of RESOURCE_DIR/include.
Reorder RESOURCE_DIR/include to fix the search order problem.
(Currently musl doesn't provide stdatomic.h. stdatomic.h is still found in RESOURCE_DIR/include.)

gcc on musl has a similar search order:

```
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/x86_64-alpine-linux-musl
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../include/c++/8.3.0/backward
 /usr/local/include
 /usr/include/fortify
 /usr/include
 /usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/include
```

This is different from a glibc-based distribution where RESOURCE_DIR/include is placed before SYSROOT/usr/include.

According to the maintainer of musl:

> musl does not support use/mixing of compiler-provided std headers with its headers, and intentionally has no mechanism for communicating with such headers as to which types have already been defined or still need to be defined. If the current include order, with clang's headers before the libc ones, works in some situations, it's only by accident.

Reviewed by: phosek

Differential Revision: https://reviews.llvm.org/D65699

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367981 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Driver/ToolChains/Linux.cpp
test/Driver/linux-musl-header-search.cpp [new file with mode: 0644]