feat: ship native dev tools and target sysroot at 0:/usr

The devkit target in programs/GNUmakefile stages the native binutils
(as, ld, ar, nm, objcopy, objdump, readelf, ranlib, strip, size,
strings, addr2line, c++filt, elfedit as *.elf) into the image at
0:/usr/bin, plus a target-side sysroot: libc headers, montauk/ and
Api/ SDK headers and the freestanding C++ set at 0:/usr/include, and
libc.a + crt1/crti/crtn objects (with empty libm/libstdc++ stand-ins)
at 0:/usr/lib. ld's ldscripts ship under 0:/usr/x86_64-montauk.

The /usr prefix matches the binutils configure prefix, and the kernel
already resolves driveless absolute paths against the cwd drive, so
compiled-in /usr/lib search paths work natively on drive 0.

The shell resolves commands from 0:/usr/bin (after 0:/os) and tab
completion lists it. When toolchain/native/ has not been built, the
devkit step skips cleanly and the image builds as before.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-07-14 20:53:57 +02:00
co-authored by Claude Fable 5
parent bd9158fdcc
commit fe040f8fea
5 changed files with 77 additions and 7 deletions
+8 -2
View File
@@ -84,13 +84,19 @@ int exec_external(const char* cmd, const char* args) {
scat(path, name, sizeof(path));
if (try_exec(path, finalArgs)) return 0;
// 5. Try 0:/games/<cmd>.elf
// 5. Try 0:/usr/bin/<cmd>.elf (native dev tools: as, ld, ar, ...)
scopy(path, "0:/usr/bin/", sizeof(path));
scat(path, name, sizeof(path));
scat(path, ".elf", sizeof(path));
if (try_exec(path, finalArgs)) return 0;
// 6. Try 0:/games/<cmd>.elf
scopy(path, "0:/games/", sizeof(path));
scat(path, name, sizeof(path));
scat(path, ".elf", sizeof(path));
if (try_exec(path, finalArgs)) return 0;
// 6. If on a non-zero drive, also try drive root
// 7. If on a non-zero drive, also try drive root
if (current_drive != 0) {
build_drive_path(current_drive, name, path, sizeof(path));
if (try_exec(path, finalArgs)) return 0;
+30
View File
@@ -148,6 +148,36 @@ int get_completions( // returns no. of results
}
}
// ---- Native dev tools (0:/usr/bin/*.elf) ----
const char* usr_names[RD_MAX] = { };
int un = montauk::readdir("0:/usr/bin", usr_names, RD_MAX);
for (int i = 0; i < un; i++) {
/* Entries come back as "usr/bin/as.elf"; strip to the last
slash, not the first. */
int inc = 0;
for (int j = 0; usr_names[i][j]; j++) {
if (usr_names[i][j] == '/')
inc = j + 1;
}
if (montauk::starts_with(usr_names[i] + inc, (const char*)string)) {
if (r >= arrayMax)
break;
if (!is_executable(usr_names[i]))
continue;
char* p = (char *)usr_names[i] + inc;
strip_elf_extension(p);
array[r] = (char *)p;
r++;
}
}
// ---- Shell builtins ----
size_t builtins_count = sizeof(shell_builtins) / sizeof(const char*);