summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2026-02-02 22:10:30 +0800
committerGitHub <[email protected]>2026-02-02 22:10:30 +0800
commit3bf7d52392bd9489ce7e580120dec8dac7d7c29f (patch)
treea7cf54ae80ee4eae0adf923517f3de66e77ba362 /core/src
parentd46368bd6d2d5c0331e701a1cfa62590407f074c (diff)
Update engine.c
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/engine.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index 7a76da7a1..32a4855cf 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -874,32 +874,11 @@ static tb_bool_t xm_engine_get_program_file(xm_engine_t *engine, tb_char_t **arg
ssize_t size = readlink(XM_PROC_SELF_FILE, path, (size_t)maxn);
if (size > 0 && size < maxn) {
path[size] = '\0';
-#if defined(TB_CONFIG_OS_LINUX)
- // fix /usr/bin/ape for cosmocc
- if (size > 3 && !tb_strcmp(path + size - 3, "ape")) {
- FILE* fp = fopen("/proc/self/cmdline", "rb");
- if (fp) {
- tb_char_t line[TB_PATH_MAXN * 2];
- if (fread(line, 1, sizeof(line), fp) > 0) {
- tb_char_t* p = line;
- // if argv[0] is /usr/bin/ape, we use argv[1]
- if (tb_strstr(p, "ape")) {
- p += tb_strlen(p) + 1;
- }
- // get absolute path
- if (p < line + sizeof(line) && *p) {
- tb_char_t buf[TB_PATH_MAXN];
- if (tb_path_absolute(p, buf, sizeof(buf))) {
- tb_strlcpy(path, buf, maxn);
- }
- }
- }
- fclose(fp);
+ // ignore cosmocc ape binary, we fallback to argv[0], .e.g /usr/bin/ape, /home/ruki/.ape-1.10
+ if (!tb_strstr(path, "ape")) {
+ ok = tb_true;
}
}
-#endif
- ok = tb_true;
- }
#elif defined(TB_CONFIG_OS_BSD) && defined(KERN_PROC_PATHNAME)
// only for FreeBSD and OpenBSD, https://github.com/xmake-io/xmake/issues/2948
tb_int_t mib[4];