[clang] bfbfd83 - [Driver] Linux.cpp: delete unneeded D.getVFS().exists checks
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 24 15:25:43 PDT 2021
Author: Fangrui Song
Date: 2021-03-24T15:25:36-07:00
New Revision: bfbfd83f147f0e02e652f3ae2635dd834c2e6b46
URL: https://github.com/llvm/llvm-project/commit/bfbfd83f147f0e02e652f3ae2635dd834c2e6b46
DIFF: https://github.com/llvm/llvm-project/commit/bfbfd83f147f0e02e652f3ae2635dd834c2e6b46.diff
LOG: [Driver] Linux.cpp: delete unneeded D.getVFS().exists checks
Not only can this save unneeded filesystem stats, it can make `clang
--sysroot=/path/to/debian-sysroot -c a.cc` work (get `-internal-isystem
$sysroot/usr/include/x86_64-linux-gnu`) even without `lib/x86_64-linux-gnu/`.
This should make thakis happy.
Added:
Modified:
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index cbfa5152bc8e..cea77b679318 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -58,70 +58,42 @@ std::string Linux::getMultiarchTriple(const Driver &D,
// regardless of what the actual target triple is.
case llvm::Triple::arm:
case llvm::Triple::thumb:
- if (IsAndroid) {
+ if (IsAndroid)
return "arm-linux-androideabi";
- } else if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
- if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf"))
- return "arm-linux-gnueabihf";
- } else {
- if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabi"))
- return "arm-linux-gnueabi";
- }
- break;
+ if (TargetEnvironment == llvm::Triple::GNUEABIHF)
+ return "arm-linux-gnueabihf";
+ return "arm-linux-gnueabi";
case llvm::Triple::armeb:
case llvm::Triple::thumbeb:
- if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
- if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf"))
- return "armeb-linux-gnueabihf";
- } else {
- if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabi"))
- return "armeb-linux-gnueabi";
- }
- break;
+ if (TargetEnvironment == llvm::Triple::GNUEABIHF)
+ return "armeb-linux-gnueabihf";
+ return "armeb-linux-gnueabi";
case llvm::Triple::x86:
if (IsAndroid)
return "i686-linux-android";
- if (D.getVFS().exists(SysRoot + "/lib/i386-linux-gnu"))
- return "i386-linux-gnu";
- break;
+ return "i386-linux-gnu";
case llvm::Triple::x86_64:
if (IsAndroid)
return "x86_64-linux-android";
- // We don't want this for x32, otherwise it will match x86_64 libs
- if (TargetEnvironment != llvm::Triple::GNUX32 &&
- D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
- return "x86_64-linux-gnu";
- break;
+ if (TargetEnvironment == llvm::Triple::GNUX32)
+ return "x86_64-linux-gnux32";
+ return "x86_64-linux-gnu";
case llvm::Triple::aarch64:
if (IsAndroid)
return "aarch64-linux-android";
- if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
- return "aarch64-linux-gnu";
- break;
+ return "aarch64-linux-gnu";
case llvm::Triple::aarch64_be:
- if (D.getVFS().exists(SysRoot + "/lib/aarch64_be-linux-gnu"))
- return "aarch64_be-linux-gnu";
- break;
+ return "aarch64_be-linux-gnu";
case llvm::Triple::m68k:
- if (D.getVFS().exists(SysRoot + "/lib/m68k-linux-gnu"))
- return "m68k-linux-gnu";
- break;
+ return "m68k-linux-gnu";
- case llvm::Triple::mips: {
- std::string MT = IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
- if (D.getVFS().exists(SysRoot + "/lib/" + MT))
- return MT;
- break;
- }
- case llvm::Triple::mipsel: {
+ case llvm::Triple::mips:
+ return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
+ case llvm::Triple::mipsel:
if (IsAndroid)
return "mipsel-linux-android";
- std::string MT = IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
- if (D.getVFS().exists(SysRoot + "/lib/" + MT))
- return MT;
- break;
- }
+ return IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
case llvm::Triple::mips64: {
std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") +
"-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
@@ -145,33 +117,19 @@ std::string Linux::getMultiarchTriple(const Driver &D,
case llvm::Triple::ppc:
if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
return "powerpc-linux-gnuspe";
- if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnu"))
- return "powerpc-linux-gnu";
- break;
+ return "powerpc-linux-gnu";
case llvm::Triple::ppcle:
- if (D.getVFS().exists(SysRoot + "/lib/powerpcle-linux-gnu"))
- return "powerpcle-linux-gnu";
- break;
+ return "powerpcle-linux-gnu";
case llvm::Triple::ppc64:
- if (D.getVFS().exists(SysRoot + "/lib/powerpc64-linux-gnu"))
- return "powerpc64-linux-gnu";
- break;
+ return "powerpc64-linux-gnu";
case llvm::Triple::ppc64le:
- if (D.getVFS().exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
- return "powerpc64le-linux-gnu";
- break;
+ return "powerpc64le-linux-gnu";
case llvm::Triple::sparc:
- if (D.getVFS().exists(SysRoot + "/lib/sparc-linux-gnu"))
- return "sparc-linux-gnu";
- break;
+ return "sparc-linux-gnu";
case llvm::Triple::sparcv9:
- if (D.getVFS().exists(SysRoot + "/lib/sparc64-linux-gnu"))
- return "sparc64-linux-gnu";
- break;
+ return "sparc64-linux-gnu";
case llvm::Triple::systemz:
- if (D.getVFS().exists(SysRoot + "/lib/s390x-linux-gnu"))
- return "s390x-linux-gnu";
- break;
+ return "s390x-linux-gnu";
}
return TargetTriple.str();
}
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index a53c8a007559..db8c27b37720 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1896,7 +1896,6 @@
// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|\\\\}}crti.o"
// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0{{/|\\\\}}crtbegin.o"
// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0"
-// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi"
// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib"
// CHECK-OE-ARM: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0{{/|\\\\}}crtend.o"
More information about the cfe-commits
mailing list