[clang] faa889b - [Hexagon] clang driver should consider --sysroot option
Sid Manning via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 18 12:26:47 PST 2020
Author: Sid Manning
Date: 2020-02-18T14:25:55-06:00
New Revision: faa889b2358704c57febf2ad75ad88eec5debf31
URL: https://github.com/llvm/llvm-project/commit/faa889b2358704c57febf2ad75ad88eec5debf31
DIFF: https://github.com/llvm/llvm-project/commit/faa889b2358704c57febf2ad75ad88eec5debf31.diff
LOG: [Hexagon] clang driver should consider --sysroot option
Hexagon's clang driver should consider --sysroot option when setting
up include paths.
Differential Revision: https://reviews.llvm.org/D74776
Added:
Modified:
clang/lib/Driver/ToolChains/Hexagon.cpp
clang/test/Driver/hexagon-toolchain-elf.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index 2b9046712a26..25e9f1b6c222 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -540,6 +540,13 @@ void HexagonToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
return;
const Driver &D = getDriver();
+ if (!D.SysRoot.empty()) {
+ SmallString<128> P(D.SysRoot);
+ llvm::sys::path::append(P, "include");
+ addExternCSystemInclude(DriverArgs, CC1Args, P.str());
+ return;
+ }
+
std::string TargetDir = getHexagonTargetDir(D.getInstalledDir(),
D.PrefixDirs);
addExternCSystemInclude(DriverArgs, CC1Args, TargetDir + "/hexagon/include");
diff --git a/clang/test/Driver/hexagon-toolchain-elf.c b/clang/test/Driver/hexagon-toolchain-elf.c
index 9b5ebe3c86a4..4af00215ea31 100644
--- a/clang/test/Driver/hexagon-toolchain-elf.c
+++ b/clang/test/Driver/hexagon-toolchain-elf.c
@@ -577,3 +577,14 @@
// RUN: | FileCheck -check-prefix=CHECK082 %s
// CHECK082-NOT: -march=
// CHECK082-NOT: -mcpu=
+// -----------------------------------------------------------------------------
+// Passing --sysroot
+// -----------------------------------------------------------------------------
+// RUN: %clang -### -target hexagon-unknown-elf \
+// RUN: -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN: -mcpu=hexagonv60 \
+// RUN: --sysroot=/hexagon \
+// RUN: %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK083 %s
+// CHECK083: "-isysroot" "/hexagon"
+// CHECK083: "-internal-externc-isystem" "/hexagon/include"
More information about the cfe-commits
mailing list