Skip to content

Commit ca28883

Browse files
committed
Don't use sysroot/include when sysroot is empty.
Baremetal toolchain add Driver.SysRoot/include to the system include paths without checking if Driver.SysRoot is empty. This resulted in "-internal-isystem" "include" in the command. This patch adds check for empty sysroot. Reviewed By: jroelofs Differential Revision: https://reviews.llvm.org/D92176
1 parent e60f2cb commit ca28883

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
107107

108108
if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
109109
SmallString<128> Dir(getDriver().SysRoot);
110-
llvm::sys::path::append(Dir, "include");
111-
addSystemInclude(DriverArgs, CC1Args, Dir.str());
110+
if (!Dir.empty()) {
111+
llvm::sys::path::append(Dir, "include");
112+
addSystemInclude(DriverArgs, CC1Args, Dir.str());
113+
}
112114
}
113115
}
114116

clang/test/Driver/baremetal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@
9393
// RUN: | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
9494
// CHECK-RTLIB-GCC: -lgcc
9595

96+
// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
97+
// RUN: | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
98+
// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
99+
96100
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
97101
// RUN: -target riscv64-unknown-elf \
98102
// RUN: -L some/directory/user/asked/for \

0 commit comments

Comments
 (0)