Skip to content

Commit

Permalink
llvm: Avoid looking at /proc/self/exe
Browse files Browse the repository at this point in the history
LLVM looks at /proc/self/exe to determine which binary has been called.
This does not work with the proposed changes for termux-exec:
termux/termux-exec#24

Luckily the fallback to look at argv0 works instead.
  • Loading branch information
fornwall committed Oct 4, 2023
1 parent b470466 commit 710c81c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/libllvm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TERMUX_PKG_LICENSE_FILE="llvm/LICENSE.TXT"
TERMUX_PKG_MAINTAINER="@finagolfin"
LLVM_MAJOR_VERSION=16
TERMUX_PKG_VERSION=${LLVM_MAJOR_VERSION}.0.6
TERMUX_PKG_REVISION=2
TERMUX_PKG_REVISION=3
TERMUX_PKG_SHA256=ce5e71081d17ce9e86d7cbcfa28c4b04b9300f8fb7e78422b1feb6bc52c3028e
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
Expand Down
19 changes: 19 additions & 0 deletions packages/libllvm/llvm-lib-Support-Unix-Path.inc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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 @@
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;

0 comments on commit 710c81c

Please sign in to comment.