feat: build userspace programs with the x86_64-montauk toolchain
Switch all program and library Makefiles from host g++ (or the bare-metal x86_64-elf compiler) to x86_64-montauk-g++/gcc and drop the flags the target now owns: -nostdinc + kernel freestanding -isystem paths, -m64/-march, -fno-PIC, -mno-red-zone, -mcmodel=small, -static, -Wl,-m,elf_x86_64, -z max-page-size, --build-id=none. Deliberate policy flags stay (-ffreestanding, per-app SSE, -nostdlib + link.ld). Program builds now require the montauk toolchain and fail with a pointer to build-montauk-toolchain.sh; lib/ and libs/ keep the host fallback since the toolchain script bootstraps libc through it. Userspace is also now pinned to the cross GCC instead of drifting with the distro compiler. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
MAKEFLAGS += -rR
|
||||
.SUFFIXES:
|
||||
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-montauk-
|
||||
ifeq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
CC = $(error x86_64-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh first)
|
||||
AR = $(error x86_64-montauk toolchain not found. Run ./toolchain/build-montauk-toolchain.sh first)
|
||||
else
|
||||
CC := $(TOOLCHAIN_PREFIX)gcc
|
||||
AR := $(TOOLCHAIN_PREFIX)ar
|
||||
else
|
||||
CC := gcc
|
||||
AR := ar
|
||||
endif
|
||||
|
||||
SRCDIR := src
|
||||
@@ -26,19 +26,13 @@ CFLAGS := \
|
||||
-Wno-sign-compare \
|
||||
-Wno-misleading-indentation \
|
||||
-Wno-implicit-fallthrough \
|
||||
-nostdinc \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fno-PIC \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-msse \
|
||||
-msse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=small \
|
||||
-D__MONTAUKOS__=1 \
|
||||
-DLUA_COMPAT_5_3 \
|
||||
-I$(SRCDIR) \
|
||||
@@ -47,11 +41,7 @@ CFLAGS := \
|
||||
|
||||
LDFLAGS := \
|
||||
-nostdlib \
|
||||
-static \
|
||||
-Wl,--build-id=none \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-m,elf_x86_64 \
|
||||
-z max-page-size=0x1000 \
|
||||
-T ../../link.ld
|
||||
|
||||
CORE_SRCS := \
|
||||
|
||||
Reference in New Issue
Block a user