forked from OSchip/llvm-project
BareMetal: detect usr/include/c++/v1 path in sysroot
Currently baremetal driver adds <sysroot>/include/c++/v1 for libc++ headers. However on ChromeOS, all include files are inside <sysroot>/usr/include. So add <sysroot>/usr/include/c++/v1 if it exists in baremetal driver. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D134478
This commit is contained in:
parent
730ee6568c
commit
5e5d21462d
|
@ -217,12 +217,21 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||||
DriverArgs.hasArg(options::OPT_nostdincxx))
|
DriverArgs.hasArg(options::OPT_nostdincxx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const Driver &D = getDriver();
|
||||||
std::string SysRoot(computeSysRoot());
|
std::string SysRoot(computeSysRoot());
|
||||||
if (SysRoot.empty())
|
if (SysRoot.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (GetCXXStdlibType(DriverArgs)) {
|
switch (GetCXXStdlibType(DriverArgs)) {
|
||||||
case ToolChain::CST_Libcxx: {
|
case ToolChain::CST_Libcxx: {
|
||||||
|
// First check sysroot/usr/include/c++/v1 if it exists.
|
||||||
|
SmallString<128> TargetDir(SysRoot);
|
||||||
|
llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
|
||||||
|
if (D.getVFS().exists(TargetDir)) {
|
||||||
|
addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Add generic path if nothing else succeeded so far.
|
||||||
SmallString<128> Dir(SysRoot);
|
SmallString<128> Dir(SysRoot);
|
||||||
llvm::sys::path::append(Dir, "include", "c++", "v1");
|
llvm::sys::path::append(Dir, "include", "c++", "v1");
|
||||||
addSystemInclude(DriverArgs, CC1Args, Dir.str());
|
addSystemInclude(DriverArgs, CC1Args, Dir.str());
|
||||||
|
@ -234,9 +243,8 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
|
Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
|
||||||
// Walk the subdirs, and find the one with the newest gcc version:
|
// Walk the subdirs, and find the one with the newest gcc version:
|
||||||
for (llvm::vfs::directory_iterator
|
for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Dir.str(), EC),
|
||||||
LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
|
LE;
|
||||||
LE;
|
|
||||||
!EC && LI != LE; LI = LI.increment(EC)) {
|
!EC && LI != LE; LI = LI.increment(EC)) {
|
||||||
StringRef VersionText = llvm::sys::path::filename(LI->path());
|
StringRef VersionText = llvm::sys::path::filename(LI->path());
|
||||||
auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);
|
auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);
|
||||||
|
|
|
@ -77,6 +77,22 @@
|
||||||
// CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
|
// CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
|
||||||
// CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
|
// CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
|
||||||
|
|
||||||
|
// RUN: rm -rf %T/baremetal_cxx_sysroot
|
||||||
|
// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
|
||||||
|
// RUN: %clangxx %s -### 2>&1 \
|
||||||
|
// RUN: --target=armv6m-none-eabi \
|
||||||
|
// RUN: --sysroot=%T/baremetal_cxx_sysroot \
|
||||||
|
// RUN: -stdlib=libc++ \
|
||||||
|
// RUN: | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
|
||||||
|
// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
|
||||||
|
// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-SAME: "-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
|
||||||
|
// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
|
||||||
|
|
||||||
// RUN: %clangxx --target=arm-none-eabi -v 2>&1 \
|
// RUN: %clangxx --target=arm-none-eabi -v 2>&1 \
|
||||||
// RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
|
// RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
|
||||||
// CHECK-THREAD-MODEL: Thread model: posix
|
// CHECK-THREAD-MODEL: Thread model: posix
|
||||||
|
|
Loading…
Reference in New Issue