libllvm: fix clang-tools (#18270)

This commit is contained in:
termux-pacman-bot
2023-10-16 18:01:51 +00:00
parent d85924666a
commit ea30799e48
2 changed files with 40 additions and 13 deletions

View File

@@ -5,7 +5,7 @@ TERMUX_PKG_LICENSE_FILE="llvm/LICENSE.TXT"
TERMUX_PKG_MAINTAINER="@finagolfin"
LLVM_MAJOR_VERSION=17
TERMUX_PKG_VERSION=${LLVM_MAJOR_VERSION}.0.2
TERMUX_PKG_REVISION=1
TERMUX_PKG_REVISION=2
TERMUX_PKG_SHA256=351562b14d42fcefcbf00cc1f327680a1062bbbf67a1e1ca6acb64c473b06394
TERMUX_PKG_AUTO_UPDATE=false
TERMUX_PKG_SRCURL=https://github.com/llvm/llvm-project/releases/download/llvmorg-$TERMUX_PKG_VERSION/llvm-project-${TERMUX_PKG_VERSION}.src.tar.xz

View File

@@ -1,19 +1,46 @@
diff -u -r ../orig-src/llvm/lib/Support/Unix/Path.inc ./llvm/lib/Support/Unix/Path.inc
--- ../orig-src/llvm/lib/Support/Unix/Path.inc 2023-09-29 21:36:47.056335287 +0000
+++ ./llvm/lib/Support/Unix/Path.inc 2023-09-29 21:40:31.091417185 +0000
@@ -252,6 +252,7 @@
@@ -250,6 +250,42 @@
// If we don't have procfs mounted, fall back to argv[0]
if (getprogpath(exe_path, argv0) != NULL)
return exe_path;
+#elif defined(__ANDROID__) // termux-exec linker wrapping does not work with /proc/self/exe
+#ifdef __LP64__
+#define LINKERPATH "/system/bin/linker64"
+#else
+#define LINKERPATH "/system/bin/linker"
+#endif
+ if (char *real_path = realpath("/proc/self/exe", nullptr)) {
+ if (strcmp(real_path, LINKERPATH) != 0) {
+ std::string ret = std::string(real_path);
+ free(real_path);
+ return ret;
+ }
+ free(real_path);
+ }
+ if (FILE *cmdfile = fopen("/proc/self/cmdline", "r")) {
+ char *cmd = nullptr;
+ size_t len = 0;
+ ssize_t nread = getdelim(&cmd, &len, '\0', cmdfile);
+ if (nread == strlen(LINKERPATH) && !memcmp(cmd, LINKERPATH, strlen(LINKERPATH)))
+ nread = getdelim(&cmd, &len, '\0', cmdfile);
+ fclose(cmdfile);
+ if (nread > 0) {
+ if (char *real_path = realpath(cmd, nullptr)) {
+ free(cmd);
+ std::string ret = std::string(real_path);
+ free(real_path);
+ return ret;
+ }
+ }
+ free(cmd);
+ }
+#undef LINKERPATH
+ // Fall back to the classical detection.
+ char exe_path[PATH_MAX];
+ if (getprogpath(exe_path, argv0))
+ return exe_path;
#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__)
char exe_path[PATH_MAX];
+#ifndef __ANDROID__ /* Avoid looking at /proc/self/exe, as it does not work with termux-exec linker wrapping */
const char *aPath = "/proc/self/exe";
if (sys::fs::exists(aPath)) {
// /proc is not always mounted under Linux (chroot for example).
@@ -280,6 +281,7 @@
return std::string(real_path);
#endif
}
+#endif
// Fall back to the classical detection.
if (getprogpath(exe_path, argv0))
return exe_path;