diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index 8100247..4ecbc75 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 12 +#define MONTAUK_BUILD_NUMBER 13 diff --git a/programs/GNUmakefile b/programs/GNUmakefile index 10d3f1d..7f81618 100644 --- a/programs/GNUmakefile +++ b/programs/GNUmakefile @@ -377,30 +377,31 @@ $(BINDIR)/os/%.elf: src/%/main.cpp link.ld GNUmakefile $(CXX) $(CXXFLAGS) $(LDFLAGS) obj/$*/main.o lib/libc/liblibc.a -o $@ # ============================================================================ -# Native development kit: binutils built for MontaukOS plus a target -# sysroot (headers, libc.a, crt objects) under 0:/usr. Skipped when the -# native tools have not been built; see toolchain/README.md. +# Native development kit (Montauk SDK): binutils built for MontaukOS +# plus a target sysroot (headers, libc.a, crt objects) under 0:/sdk. +# 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 .PHONY: devkit devkit: libc ifneq ($(wildcard $(NATIVE_BIN)/as),) - rm -rf $(BINDIR)/usr - mkdir -p $(BINDIR)/usr/bin $(BINDIR)/usr/lib $(BINDIR)/usr/include + rm -rf $(BINDIR)/sdk + mkdir -p $(BINDIR)/sdk/bin $(BINDIR)/sdk/lib $(BINDIR)/sdk/include 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 - cp -r ../toolchain/native/usr/x86_64-montauk $(BINDIR)/usr/x86_64-montauk - cp -r include/libc/. $(BINDIR)/usr/include/ - cp -r include/montauk $(BINDIR)/usr/include/montauk - cp -r include/Api $(BINDIR)/usr/include/Api - cp -r ../kernel/freestnd-cxx-hdrs/x86_64/include/. $(BINDIR)/usr/include/ - cp lib/libc/liblibc.a $(BINDIR)/usr/lib/libc.a - cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/usr/lib/ - ar rcs $(BINDIR)/usr/lib/libm.a - ar rcs $(BINDIR)/usr/lib/libstdc++.a + cp -r ../toolchain/native/sdk/x86_64-montauk $(BINDIR)/sdk/x86_64-montauk + cp -r include/libc/. $(BINDIR)/sdk/include/ + cp -r include/montauk $(BINDIR)/sdk/include/montauk + cp -r include/Api $(BINDIR)/sdk/include/Api + cp -r ../kernel/freestnd-cxx-hdrs/x86_64/include/. $(BINDIR)/sdk/include/ + cp lib/libc/liblibc.a $(BINDIR)/sdk/lib/libc.a + cp lib/libc/crt1.o lib/libc/crti.o lib/libc/crtn.o $(BINDIR)/sdk/lib/ + ar rcs $(BINDIR)/sdk/lib/libm.a + ar rcs $(BINDIR)/sdk/lib/libstdc++.a else @echo "devkit: toolchain/native/ not built; skipping native dev tools" endif diff --git a/programs/include/libc/unistd.h b/programs/include/libc/unistd.h index 364bc3c..2cfa39e 100644 --- a/programs/include/libc/unistd.h +++ b/programs/include/libc/unistd.h @@ -38,6 +38,15 @@ int execv(const char *path, char *const argv[]); int execve(const char *path, char *const argv[], char *const envp[]); int execvp(const char *file, char *const argv[]); 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; diff --git a/programs/lib/libc/libc.c b/programs/lib/libc/libc.c index ec8ff57..1ad0397 100644 --- a/programs/lib/libc/libc.c +++ b/programs/lib/libc/libc.c @@ -3435,6 +3435,19 @@ int kill(pid_t pid, int sig) { 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 NAME=VALUE strings, and exec* is unimplemented, so nothing can consume a populated environ yet. An empty, valid vector satisfies diff --git a/programs/lib/libc/obj/libc.o b/programs/lib/libc/obj/libc.o index b751d94..c056514 100644 Binary files a/programs/lib/libc/obj/libc.o and b/programs/lib/libc/obj/libc.o differ diff --git a/programs/lib/libjpeg/libjpeg.a b/programs/lib/libjpeg/libjpeg.a index 6d83c31..5a4ee17 100644 Binary files a/programs/lib/libjpeg/libjpeg.a and b/programs/lib/libjpeg/libjpeg.a differ diff --git a/programs/lib/libjpegwrite/libjpegwrite.a b/programs/lib/libjpegwrite/libjpegwrite.a index 65d381b..4f52a5a 100644 Binary files a/programs/lib/libjpegwrite/libjpegwrite.a and b/programs/lib/libjpegwrite/libjpegwrite.a differ diff --git a/programs/lib/tls/libtls.a b/programs/lib/tls/libtls.a index 1d595e7..3284474 100644 Binary files a/programs/lib/tls/libtls.a and b/programs/lib/tls/libtls.a differ diff --git a/programs/src/shell/exec.cpp b/programs/src/shell/exec.cpp index 86404c9..2187ae6 100644 --- a/programs/src/shell/exec.cpp +++ b/programs/src/shell/exec.cpp @@ -84,8 +84,8 @@ int exec_external(const char* cmd, const char* args) { scat(path, name, sizeof(path)); if (try_exec(path, finalArgs)) return 0; - // 5. Try 0:/usr/bin/.elf (native dev tools: as, ld, ar, ...) - scopy(path, "0:/usr/bin/", sizeof(path)); + // 5. Try 0:/sdk/bin/.elf (Montauk SDK: as, ld, ar, ...) + scopy(path, "0:/sdk/bin/", sizeof(path)); scat(path, name, sizeof(path)); scat(path, ".elf", sizeof(path)); if (try_exec(path, finalArgs)) return 0; diff --git a/programs/src/shell/tabcompletion.cpp b/programs/src/shell/tabcompletion.cpp index d120906..1430243 100644 --- a/programs/src/shell/tabcompletion.cpp +++ b/programs/src/shell/tabcompletion.cpp @@ -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] = { }; - 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++) { - /* 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. */ int inc = 0; for (int j = 0; usr_names[i][j]; j++) { diff --git a/toolchain/README.md b/toolchain/README.md index cf84481..8d2f6b4 100644 --- a/toolchain/README.md +++ b/toolchain/README.md @@ -72,7 +72,7 @@ mkdir -p toolchain/build/binutils-native && cd toolchain/build/binutils-native export PATH=$PWD/../../local/bin:$PATH ../../src/binutils-2.43.1/configure \ --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-plugins --disable-shared --enable-static make -j$(nproc) all-gas all-ld all-binutils @@ -92,10 +92,11 @@ Notes: posix_spawn milestone that needs kernel support (exit codes in SYS_WAITPID, fd redirection wiring). - 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 - target-side sysroot at 0:/usr/include + 0:/usr/lib (libc.a, crt - objects, empty libm/libstdc++). The kernel resolves driveless - absolute paths ("/usr/lib") against the cwd drive, so the binutils - --prefix=/usr layout works natively. The shell searches 0:/usr/bin - and tab-completes it. If toolchain/native/ has not been built the + into the OS image at 0:/sdk/bin (as.elf, ld.elf, ar.elf, ...) with a + target-side sysroot at 0:/sdk/include + 0:/sdk/lib (libc.a, crt + objects, empty libm/libstdc++) - the Montauk SDK. The kernel + resolves driveless absolute paths ("/sdk/lib") against the cwd + drive, so the --prefix=/sdk layout works natively. The shell + 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.