[llvm-branch-commits] [clang] ca28883 - Don't use sysroot/include when sysroot is empty.

Hafiz Abid Qadeer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 4 10:38:01 PST 2020


Author: Hafiz Abid Qadeer
Date: 2020-12-04T18:33:24Z
New Revision: ca2888310b245d0532d989685a090ae373ee3f93

URL: https://github.com/llvm/llvm-project/commit/ca2888310b245d0532d989685a090ae373ee3f93
DIFF: https://github.com/llvm/llvm-project/commit/ca2888310b245d0532d989685a090ae373ee3f93.diff

LOG: 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

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/BareMetal.cpp
    clang/test/Driver/baremetal.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index e032d07112eb..20ffd4b2cd57 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
     SmallString<128> Dir(getDriver().SysRoot);
-    llvm::sys::path::append(Dir, "include");
-    addSystemInclude(DriverArgs, CC1Args, Dir.str());
+    if (!Dir.empty()) {
+      llvm::sys::path::append(Dir, "include");
+      addSystemInclude(DriverArgs, CC1Args, Dir.str());
+    }
   }
 }
 

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 7dd213ee56b4..addf09f00e14 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN:     -target riscv64-unknown-elf \
 // RUN:     -L some/directory/user/asked/for \


        


More information about the llvm-branch-commits mailing list