diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 665cdc3132fb8fc69f0a33feffdd0a82a5510810..3ee5624e85f201bdcc78e07f783895b752cc637f 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2156,6 +2156,11 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( Prefixes.push_back("/opt/rh/devtoolset-2/root/usr"); } + // openeuler embedded nativesdk uses this dir + if (SysRoot.empty() && TargetTriple.getVendor() == llvm::Triple::OpenEmbedded && + D.getVFS().exists("/opt/buildtools/nativesdk/sysroots")) + Prefixes.push_back("/opt/buildtools/nativesdk/sysroots/" + TargetTriple.getTriple()); + // Fall back to /usr which is used by most non-Solaris systems. Prefixes.push_back(concat(SysRoot, "/usr")); } @@ -2201,7 +2206,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( static const char *const CSKYTriples[] = { "csky-linux-gnuabiv2", "csky-linux-uclibcabiv2", "csky-elf-noneabiv2"}; - static const char *const X86_64LibDirs[] = {"/lib64", "/lib"}; + static const char *const X86_64LibDirs[] = {"/lib64", "/lib", "/usr/lib"}; static const char *const X86_64Triples[] = { "x86_64-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-pc-linux-gnu", "x86_64-redhat-linux6E", diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp index ceb1a982c3a4ceb28575f9ffb4a962d67b77254b..d3c5ae53a3b28b14893f3541292e65df8897092a 100644 --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -376,7 +376,7 @@ std::string Linux::computeSysRoot() const { return std::string(); } - if (!GCCInstallation.isValid() || !getTriple().isMIPS()) + if (!GCCInstallation.isValid() || (!getTriple().isMIPS() && getTriple().getVendor() != llvm::Triple::OpenEmbedded)) return std::string(); // Standalone MIPS toolchains use different names for sysroot folder @@ -396,6 +396,11 @@ std::string Linux::computeSysRoot() const { Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str(); + if (getVFS().exists(Path)) + return Path; + + Path = (InstallDir + "/../../../../../" + TripleStr).str(); + if (getVFS().exists(Path)) return Path; @@ -454,7 +459,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { llvm_unreachable("unsupported architecture"); case llvm::Triple::aarch64: - LibDir = "lib"; + LibDir = "lib64"; Loader = "ld-linux-aarch64.so.1"; break; case llvm::Triple::aarch64_be: @@ -545,9 +550,12 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { break; case llvm::Triple::x86_64: { bool X32 = Triple.isX32(); + bool OE = (Triple.getVendor() == llvm::Triple::OpenEmbedded); LibDir = X32 ? "libx32" : "lib64"; Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2"; + if (OE) + return "/opt/buildtools/nativesdk/sysroots/" + Triple.str() + "/lib/"+ Loader; break; } case llvm::Triple::ve: diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 6696d158b2c1ae3d31f0819880ec0814f74a3a16..0d348df5974e2652b3bfc7d200e7c8796325d7db 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -543,6 +543,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) { .Case("mesa", Triple::Mesa) .Case("suse", Triple::SUSE) .Case("oe", Triple::OpenEmbedded) + .Case("pokysdk", Triple::OpenEmbedded) .Default(Triple::UnknownVendor); }