: Generic_ELF(Host, Triple) {
llvm::Triple::ArchType Arch =
llvm::Triple(getDriver().DefaultHostTriple).getArch();
+ const std::string &SysRoot = getDriver().SysRoot;
bool Exists;
std::string GccTriple = "";
Multilib, Paths);
addPathIfExists(Base + "/../../../../" + Multilib, Paths);
}
- addPathIfExists("/lib/../" + Multilib, Paths);
- addPathIfExists("/usr/lib/../" + Multilib, Paths);
+ addPathIfExists(SysRoot + "/lib/../" + Multilib, Paths);
+ addPathIfExists(SysRoot + "/usr/lib/../" + Multilib, Paths);
}
// Add the non-multiplib suffixed paths (if potentially different).
addPathIfExists(Base + "/../../../../" + GccTriple + "/lib", Paths);
addPathIfExists(Base + "/../../..", Paths);
}
- addPathIfExists("/lib", Paths);
- addPathIfExists("/usr/lib", Paths);
+ addPathIfExists(SysRoot + "/lib", Paths);
+ addPathIfExists(SysRoot + "/usr/lib", Paths);
if (Arch == getArch() && IsUbuntu(Distro))
- Paths.push_back("/usr/lib/" + GccTriple);
+ Paths.push_back(SysRoot + "/usr/lib/" + GccTriple);
}
bool Linux::HasNativeLLVMSupport() const {
-// General tests that ld invocations on Linux targets sane.
+// General tests that ld invocations on Linux targets sane. Note that we use
+// sysroot to make these tests independent of the host system.
//
-// RUN: %clang -no-canonical-prefixes -ccc-host-triple i386-unknown-linux %s -### -o %t.o 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -ccc-host-triple i386-unkown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-32 %s
-// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" {{.*}} "-L/lib" "-L/usr/lib"
+// CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-32: {{.*}} "-L[[SYSROOT]]/lib" "-L[[SYSROOT]]/usr/lib"
//
-// RUN: %clang -no-canonical-prefixes -ccc-host-triple x86_64-unknown-linux %s -### -o %t.o 2>&1 \
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -ccc-host-triple x86_64-unknown-linux \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
// RUN: | FileCheck --check-prefix=CHECK-LD-64 %s
-// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" {{.*}} "-L/lib" "-L/usr/lib"
+// CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-64: {{.*}} "-L[[SYSROOT]]/lib" "-L[[SYSROOT]]/usr/lib"