fix: real argv[0] via SYS_GETEXECPATH - GCC driver finds its backends
The GCC driver relocates its install prefix from argv[0]. crt1 hardcoded argv[0] as "prog", so make_relative_prefix cwd-joined it and computed exec prefixes relative to the current directory (0:/users/admin/../libexec/gcc/...), and because the computed gcc_exec_prefix is non-NULL the standard /sdk prefixes were never searched. cc1plus was unreachable from anywhere except (by accident of the path arithmetic) 0:/sdk/bin. sdk-diag proved the kernel and libc layers all worked; only the driver's self-relocation was lost. New SYS_GETEXECPATH (151) returns the absolute path the process was spawned from (Process::name); crt1 uses it for argv[0] with a "prog" fallback. With a real argv[0], make_relative_prefix computes 0:/sdk/bin/../libexec/gcc/ from any cwd. Native GCC relinked against the new crt1; sdk-diag ships in the SDK as a permanent probe; the montauk.h TCC mirror gains the wrapper (checker enforced it). Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -12,4 +12,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MONTAUK_BUILD_NUMBER 23
|
||||
#define MONTAUK_BUILD_NUMBER 25
|
||||
|
||||
@@ -84,6 +84,18 @@ namespace montauk::abi {
|
||||
return childPid;
|
||||
}
|
||||
|
||||
// Copy the absolute path this process was spawned from (argv[0]).
|
||||
static int Sys_GetExecPath(char* buf, uint64_t maxLen) {
|
||||
auto* proc = Sched::GetCurrentProcessPtr();
|
||||
if (proc == nullptr || buf == nullptr || maxLen == 0) return -1;
|
||||
int i = 0;
|
||||
for (; i < (int)maxLen - 1 && proc->name[i]; i++) {
|
||||
buf[i] = proc->name[i];
|
||||
}
|
||||
buf[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
|
||||
static int Sys_GetArgs(char* buf, uint64_t maxLen) {
|
||||
auto* proc = Sched::GetCurrentProcessPtr();
|
||||
if (proc == nullptr || buf == nullptr || maxLen == 0) return -1;
|
||||
|
||||
@@ -150,6 +150,9 @@ namespace montauk::abi {
|
||||
return (int64_t)Sys_FbMap();
|
||||
case SYS_FBFLIP:
|
||||
return Sys_FbFlip(frame->arg1, frame->arg2);
|
||||
case SYS_GETEXECPATH:
|
||||
if (!UserMemory::Range(frame->arg2 ? frame->arg1 : frame->arg1, frame->arg2, true)) return -1;
|
||||
return Sys_GetExecPath((char*)frame->arg1, frame->arg2);
|
||||
case SYS_TERMSIZE:
|
||||
return (int64_t)Sys_TermSize();
|
||||
case SYS_GETARGS:
|
||||
|
||||
@@ -280,7 +280,10 @@ namespace montauk::abi {
|
||||
static constexpr uint64_t SYS_POWERINFO = 149; // (PowerInfo*) -> 0, -1 unsupported
|
||||
|
||||
/* Graphics.hpp -- framebuffer page flip (double-buffered scanout) */
|
||||
static constexpr uint64_t SYS_FBFLIP = 150; // (index, flags) -> new front index; index=-1 queries support (1/0); flags bit0 = wait vsync
|
||||
static constexpr uint64_t SYS_FBFLIP = 150;
|
||||
|
||||
// Absolute path of the running executable (for argv[0]).
|
||||
static constexpr uint64_t SYS_GETEXECPATH = 151; // (index, flags) -> new front index; index=-1 queries support (1/0); flags bit0 = wait vsync
|
||||
|
||||
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
|
||||
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
|
||||
|
||||
Reference in New Issue
Block a user