[llvm][clang] Add support for Tizen toolchain vendor
authorSlava Barinov <v.barinov@samsung.com>
Thu, 2 Sep 2021 20:51:42 +0000 (23:51 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 5 Dec 2024 06:24:58 +0000 (15:24 +0900)
Port of
ebf1682d714e4b6c1487ea0e136cf7c1ec30f46d
8845ba7f79513b7e362fed80bb57b708352ddbbd

Signed-off-by: Slava Barinov <v.barinov@samsung.com>
clang/include/clang/Config/config.h.cmake
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Linux.cpp
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/TargetParser/Triple.cpp

index 27ed69e21562bff28e065c3f04cb50159556dd46..3b4b7ceebb7de51125f563de57707accf483662d 100644 (file)
@@ -32,6 +32,9 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
 
+/* Multilib suffix for libdir. */
+#define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}"
+
 /* Multilib basename for libdir. */
 #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
 
index ecae475f75da009fb97bb08644387d08d058e7f3..e304130f09a51ac0e22f0900001a8466aca9e142 100644 (file)
@@ -189,10 +189,12 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
     // With a static-library build of libclang, LibClangPath will contain the
     // path of the embedding binary, which for LLVM binaries will be in bin/.
     // ../lib gets us to lib/ in both cases.
+    const char *NO_LIBDIR_SUFFIX = std::getenv("CLANG_NO_LIBDIR_SUFFIX");
+    StringRef ClangLibdirSuffix(NO_LIBDIR_SUFFIX ? "" : CLANG_LIBDIR_SUFFIX);
     P = llvm::sys::path::parent_path(Dir);
     // This search path is also created in the COFF driver of lld, so any
     // changes here also needs to happen in lld/COFF/Driver.cpp
-    llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
+    llvm::sys::path::append(P, Twine("lib") + ClangLibdirSuffix, "clang",
                             CLANG_VERSION_MAJOR_STRING);
   }
 
@@ -217,6 +219,11 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
   if (!this->VFS)
     this->VFS = llvm::vfs::getRealFileSystem();
 
+// Skip /emul if we work in accelerated environment
+#define QEMU_ACCEL_DIR "/emul"
+  if (ClangExecutable.substr(0, sizeof(QEMU_ACCEL_DIR) - 1) == QEMU_ACCEL_DIR)
+    ClangExecutable = ClangExecutable.drop_front(sizeof(QEMU_ACCEL_DIR) - 1);
+
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
 
index 35bf3906960509d28554f6ac7a8e06d310e74d07..48a25e8c02157b79b6556b19651311fcb0b48f49 100644 (file)
@@ -702,6 +702,7 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
     return;
 
   StringRef LibDir = GCCInstallation.getParentLibPath();
+  const StringRef InstallDir = GCCInstallation.getInstallPath();
   const Multilib &Multilib = GCCInstallation.getMultilib();
   const GCCVersion &Version = GCCInstallation.getVersion();
 
@@ -710,7 +711,7 @@ void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
       LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
       // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
       // without a subdirectory corresponding to the gcc version.
-      LibDir.str() + "/../include/c++",
+      LibDir.str() + "/../include/c++", InstallDir.str() + "/include/c++",
       // Cray's gcc installation puts headers under "g++" without a
       // version suffix.
       LibDir.str() + "/../include/g++",
index d2126a03db906afbd706a06265851e22fb857e00..76379f49bb6ae09c8fd010fa98587fcf473d0da8 100644 (file)
@@ -194,7 +194,8 @@ public:
     Mesa,
     SUSE,
     OpenEmbedded,
-    LastVendorType = OpenEmbedded
+    Tizen,
+    LastVendorType = Tizen
   };
   enum OSType {
     UnknownOS,
index 21d6c74b59560fbbcd2da4abcd097e3466684e57..0954ef214f1f4ab44e6662baace7130bcfc42857 100644 (file)
@@ -253,6 +253,7 @@ StringRef Triple::getVendorTypeName(VendorType Kind) {
   case PC: return "pc";
   case SCEI: return "scei";
   case SUSE: return "suse";
+  case Tizen: return "tizen";
   }
 
   llvm_unreachable("Invalid VendorType!");
@@ -640,6 +641,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
     .Case("mesa", Triple::Mesa)
     .Case("suse", Triple::SUSE)
     .Case("oe", Triple::OpenEmbedded)
+    .Case("tizen", Triple::Tizen)
     .Default(Triple::UnknownVendor);
 }