refactor: move the native devkit from 0:/usr to 0:/sdk (Montauk SDK)

0:/usr was a Unix transplant in an otherwise Montauk-native layout.
The SDK now lives at 0:/sdk/{bin,include,lib} (+ ldscripts under
0:/sdk/x86_64-montauk): Montauk-flavored, and a clean unit for a
future per-component installer tickbox. Native binutils is rebuilt
with --prefix=/sdk so ld's compiled-in search paths follow; future
ports configure with --prefix=/sdk.

Also add pathconf() with _PC_* names to the libc: now that realpath
exists, libiberty's lrealpath.c compiles its pathconf fallback path
unconditionally.

Shell command resolution and tab completion updated to 0:/sdk/bin.
Boot-verified in QEMU: setup, login, desktop on the new image with
zero usr/ remnants in the ramdisk.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
2026-07-15 09:11:05 +02:00
co-authored by Claude Fable 5
parent 1f271b3ba8
commit 54c0584b85
11 changed files with 53 additions and 29 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once #pragma once
#define MONTAUK_BUILD_NUMBER 12 #define MONTAUK_BUILD_NUMBER 13
+17 -16
View File
@@ -377,30 +377,31 @@ $(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile
$(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o lib/libc/liblibc.a -o $@ $(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o lib/libc/liblibc.a -o $@
# ============================================================================ # ============================================================================
# Native development kit: binutils built for MontaukOS plus a target # Native development kit (Montauk SDK): binutils built for MontaukOS
# sysroot (headers, libc.a, crt objects) under 0:/usr. Skipped when the # plus a target sysroot (headers, libc.a, crt objects) under 0:/sdk.
# native tools have not been built; see toolchain/README.md. # Skipped when the native tools have not been built; see
# toolchain/README.md.
# ============================================================================ # ============================================================================
NATIVE_BIN := ../toolchain/native/usr/bin NATIVE_BIN := ../toolchain/native/sdk/bin
DEVKIT_TOOLS := as ld ar nm objcopy objdump readelf ranlib strip size strings addr2line c++filt elfedit DEVKIT_TOOLS := as ld ar nm objcopy objdump readelf ranlib strip size strings addr2line c++filt elfedit
.PHONY: devkit .PHONY: devkit
devkit: libc devkit: libc
ifneq ($(wildcard $(NATIVE_BIN)/as),) ifneq ($(wildcard $(NATIVE_BIN)/as),)
rm -rf $(BINDIR)/usr rm -rf $(BINDIR)/sdk
mkdir -p $(BINDIR)/usr/bin $(BINDIR)/usr/lib $(BINDIR)/usr/include mkdir -p $(BINDIR)/sdk/bin $(BINDIR)/sdk/lib $(BINDIR)/sdk/include
for t in $(DEVKIT_TOOLS); do \ for t in $(DEVKIT_TOOLS); do \
cp $(NATIVE_BIN)/$$t $(BINDIR)/usr/bin/$$t.elf || exit 1; \ cp $(NATIVE_BIN)/$$t $(BINDIR)/sdk/bin/$$t.elf || exit 1; \
done done
cp -r ../toolchain/native/usr/x86_64-montauk $(BINDIR)/usr/x86_64-montauk cp -r ../toolchain/native/sdk/x86_64-montauk $(BINDIR)/sdk/x86_64-montauk
cp -r include/libc/. $(BINDIR)/usr/include/ cp -r include/libc/. $(BINDIR)/sdk/include/
cp -r include/montauk $(BINDIR)/usr/include/montauk cp -r include/montauk $(BINDIR)/sdk/include/montauk
cp -r include/Api $(BINDIR)/usr/include/Api cp -r include/Api $(BINDIR)/sdk/include/Api
cp -r ../kernel/freestnd-cxx-hdrs/x86_64/include/. $(BINDIR)/usr/include/ cp -r ../kernel/freestnd-cxx-hdrs/x86_64/include/. $(BINDIR)/sdk/include/
cp lib/libc/liblibc.a $(BINDIR)/usr/lib/libc.a cp lib/libc/liblibc.a $(BINDIR)/sdk/lib/libc.a
cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/usr/lib/ cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/sdk/lib/
ar rcs $(BINDIR)/usr/lib/libm.a ar rcs $(BINDIR)/sdk/lib/libm.a
ar rcs $(BINDIR)/usr/lib/libstdc++.a ar rcs $(BINDIR)/sdk/lib/libstdc++.a
else else
@echo "devkit: toolchain/native/ not built; skipping native dev tools" @echo "devkit: toolchain/native/ not built; skipping native dev tools"
endif endif
+9
View File
@@ -38,6 +38,15 @@ int execv(const char *path, char *const argv[]);
int execve(const char *path, char *const argv[], char *const envp[]); int execve(const char *path, char *const argv[], char *const envp[]);
int execvp(const char *file, char *const argv[]); int execvp(const char *file, char *const argv[]);
int pipe(int fds[2]); int pipe(int fds[2]);
long pathconf(const char *path, int name);
/* pathconf() names (Linux numbering). */
#define _PC_LINK_MAX 0
#define _PC_MAX_CANON 1
#define _PC_MAX_INPUT 2
#define _PC_NAME_MAX 3
#define _PC_PATH_MAX 4
#define _PC_PIPE_BUF 5
extern char **environ; extern char **environ;
+13
View File
@@ -3435,6 +3435,19 @@ int kill(pid_t pid, int sig) {
return 0; return 0;
} }
long pathconf(const char *path, int name) {
(void)path;
switch (name) {
case 3: /* _PC_NAME_MAX */
return 255;
case 4: /* _PC_PATH_MAX */
return 4096;
default:
errno = EINVAL;
return -1;
}
}
/* The libc environment lives in name/value slots (getenv/setenv), not /* The libc environment lives in name/value slots (getenv/setenv), not
NAME=VALUE strings, and exec* is unimplemented, so nothing can NAME=VALUE strings, and exec* is unimplemented, so nothing can
consume a populated environ yet. An empty, valid vector satisfies consume a populated environ yet. An empty, valid vector satisfies
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -84,8 +84,8 @@ int exec_external(const char* cmd, const char* args) {
scat(path, name, sizeof(path)); scat(path, name, sizeof(path));
if (try_exec(path, finalArgs)) return 0; if (try_exec(path, finalArgs)) return 0;
// 5. Try 0:/usr/bin/<cmd>.elf (native dev tools: as, ld, ar, ...) // 5. Try 0:/sdk/bin/<cmd>.elf (Montauk SDK: as, ld, ar, ...)
scopy(path, "0:/usr/bin/", sizeof(path)); scopy(path, "0:/sdk/bin/", sizeof(path));
scat(path, name, sizeof(path)); scat(path, name, sizeof(path));
scat(path, ".elf", sizeof(path)); scat(path, ".elf", sizeof(path));
if (try_exec(path, finalArgs)) return 0; if (try_exec(path, finalArgs)) return 0;
+3 -3
View File
@@ -148,14 +148,14 @@ int get_completions( // returns no. of results
} }
} }
// ---- Native dev tools (0:/usr/bin/*.elf) ---- // ---- Montauk SDK tools (0:/sdk/bin/*.elf) ----
const char* usr_names[RD_MAX] = { }; const char* usr_names[RD_MAX] = { };
int un = montauk::readdir("0:/usr/bin", usr_names, RD_MAX); int un = montauk::readdir("0:/sdk/bin", usr_names, RD_MAX);
for (int i = 0; i < un; i++) { for (int i = 0; i < un; i++) {
/* Entries come back as "usr/bin/as.elf"; strip to the last /* Entries come back as "sdk/bin/as.elf"; strip to the last
slash, not the first. */ slash, not the first. */
int inc = 0; int inc = 0;
for (int j = 0; usr_names[i][j]; j++) { for (int j = 0; usr_names[i][j]; j++) {
+8 -7
View File
@@ -72,7 +72,7 @@ mkdir -p toolchain/build/binutils-native && cd toolchain/build/binutils-native
export PATH=$PWD/../../local/bin:$PATH export PATH=$PWD/../../local/bin:$PATH
../../src/binutils-2.43.1/configure \ ../../src/binutils-2.43.1/configure \
--build=x86_64-pc-linux-gnu --host=x86_64-montauk \ --build=x86_64-pc-linux-gnu --host=x86_64-montauk \
--target=x86_64-montauk --prefix=/usr \ --target=x86_64-montauk --prefix=/sdk \
--disable-nls --disable-werror --disable-gprofng --disable-gold \ --disable-nls --disable-werror --disable-gprofng --disable-gold \
--disable-plugins --disable-shared --enable-static --disable-plugins --disable-shared --enable-static
make -j$(nproc) all-gas all-ld all-binutils make -j$(nproc) all-gas all-ld all-binutils
@@ -92,10 +92,11 @@ Notes:
posix_spawn milestone that needs kernel support (exit codes in posix_spawn milestone that needs kernel support (exit codes in
SYS_WAITPID, fd redirection wiring). SYS_WAITPID, fd redirection wiring).
- The `devkit` target in programs/GNUmakefile ships the staged tools - The `devkit` target in programs/GNUmakefile ships the staged tools
into the OS image at 0:/usr/bin (as.elf, ld.elf, ar.elf, ...) with a into the OS image at 0:/sdk/bin (as.elf, ld.elf, ar.elf, ...) with a
target-side sysroot at 0:/usr/include + 0:/usr/lib (libc.a, crt target-side sysroot at 0:/sdk/include + 0:/sdk/lib (libc.a, crt
objects, empty libm/libstdc++). The kernel resolves driveless objects, empty libm/libstdc++) - the Montauk SDK. The kernel
absolute paths ("/usr/lib") against the cwd drive, so the binutils resolves driveless absolute paths ("/sdk/lib") against the cwd
--prefix=/usr layout works natively. The shell searches 0:/usr/bin drive, so the --prefix=/sdk layout works natively. The shell
and tab-completes it. If toolchain/native/ has not been built the searches 0:/sdk/bin and tab-completes it. Future ports configure
with --prefix=/sdk. If toolchain/native/ has not been built the
devkit step is skipped and the image builds without it. devkit step is skipped and the image builds without it.