[PATCH] D65699: [Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 5 23:24:52 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367981: [Driver] Prioritize SYSROOT/usr/include over RESOURCE_DIR/include on linux-musl (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65699/new/
https://reviews.llvm.org/D65699
Files:
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/linux-musl-header-search.cpp
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -658,11 +658,11 @@
if (!DriverArgs.hasArg(options::OPT_nostdlibinc))
addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
- if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
- SmallString<128> P(D.ResourceDir);
- llvm::sys::path::append(P, "include");
- addSystemInclude(DriverArgs, CC1Args, P);
- }
+ SmallString<128> ResourceDirInclude(D.ResourceDir);
+ llvm::sys::path::append(ResourceDirInclude, "include");
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc) &&
+ (!getTriple().isMusl() || DriverArgs.hasArg(options::OPT_nostdlibinc)))
+ addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
@@ -860,6 +860,9 @@
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+ if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
+ addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
}
static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem &vfs,
Index: cfe/trunk/test/Driver/linux-musl-header-search.cpp
===================================================================
--- cfe/trunk/test/Driver/linux-musl-header-search.cpp
+++ cfe/trunk/test/Driver/linux-musl-header-search.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-linux-musl -stdlib=libc++ \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN: | FileCheck --check-prefix=CHECK-X86-64-LIBCXX %s
+
+// RESOURCE_DIR/include comes after /usr/include on linux-musl.
+// This is different from a glibc-based distribution.
+// CHECK-X86-64-LIBCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-X86-64-LIBCXX: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[SYSROOT]]/usr/include/c++/v1"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-X86-64-LIBCXX: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+// CHECK-X86-64-LIBCXX: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only -nobuiltininc 2>&1 \
+// RUN: -target x86_64-linux-musl \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN: | FileCheck --check-prefix=CHECK-NOBUILTININC %s
+
+// CHECK-NOBUILTININC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOBUILTININC-NOT: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only -nostdlibinc 2>&1 \
+// RUN: -target x86_64-linux-musl \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree --gcc-toolchain= \
+// RUN: | FileCheck --check-prefix=CHECK-NOSTDLIBINC %s
+
+// CHECK-NOSTDLIBINC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem"
+// CHECK-NOSTDLIBINC-NOT: "-internal-isystem"
+// CHECK-NOSTDLIBINC: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+// CHECK-NOSTDLIBINC-NOT: "-internal-externc-isystem"
+// CHECK-NOSTDLIBINC-NOT: "-internal-isystem"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65699.213524.patch
Type: text/x-patch
Size: 3774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190806/67989ae3/attachment.bin>
More information about the cfe-commits
mailing list