termux-packages/packages/emscripten/llvm-project-clang-lib-Driver-ToolChains-Linux.cpp.patch.diff

50 lines
2.3 KiB
Diff
Raw Normal View History

diff -uNr llvm-project/clang/lib/Driver/ToolChains/Linux.cpp llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp
--- llvm-project/clang/lib/Driver/ToolChains/Linux.cpp 2022-02-24 01:38:33.000000000 +0800
+++ llvm-project.mod/clang/lib/Driver/ToolChains/Linux.cpp 2022-02-26 20:33:29.977336914 +0800
@@ -162,8 +162,8 @@
// FIXME: This is a bit of a hack. We should really unify this code for
// reasoning about oslibdir spellings with the lib dir spellings in the
// GCCInstallationDetector, but that is a more significant refactoring.
- if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
- Triple.getArch() == llvm::Triple::sparc)
+ if (!Triple.isAndroid() && (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
+ Triple.getArch() == llvm::Triple::sparc))
return "lib32";
if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
@@ -291,7 +291,7 @@
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
Triple.isArch64Bit())
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
- else
+ else if (!IsAndroid)
addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
if (IsRISCV) {
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
@@ -306,7 +306,7 @@
// searched.
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
- if (StringRef(D.Dir).startswith(SysRoot)) {
+ if (StringRef(D.Dir).startswith(SysRoot) && !IsAndroid) {
// Even if OSLibDir != "lib", this is needed for Clang in the build
// directory (not installed) to find libc++.
addPathIfExists(D, D.Dir + "/../lib", Paths);
@@ -315,7 +315,15 @@
}
addPathIfExists(D, SysRoot + "/lib", Paths);
- addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+ bool nativeBuild = MultiarchTriple == getMultiarchTriple(D, llvm::Triple(llvm::sys::getDefaultTargetTriple()), SysRoot);
+ if (nativeBuild || !IsAndroid)
+ addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+
+ if (IsAndroid) {
+ addPathIfExists(D, SysRoot + "/usr/" + MultiarchTriple + "/lib", Paths);
+ addPathIfExists(D, "/system/" + OSLibDir, Paths);
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
+ }
}
ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {