summaryrefslogtreecommitdiff
path: root/scripts/build/environments
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build/environments')
-rw-r--r--scripts/build/environments/host.mk8
-rw-r--r--scripts/build/environments/kernel.mk28
-rw-r--r--scripts/build/environments/phys.mk12
3 files changed, 48 insertions, 0 deletions
diff --git a/scripts/build/environments/host.mk b/scripts/build/environments/host.mk
new file mode 100644
index 0000000..0911ad3
--- /dev/null
+++ b/scripts/build/environments/host.mk
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+HOSTCC ?= cc
+HOSTCXX ?= c++
+HOSTAR ?= ar
+HOSTCFLAGS ?= -O2 -g -Wall -Wextra
+HOSTCXXFLAGS ?= $(HOSTCFLAGS) -std=c++23
+
diff --git a/scripts/build/environments/kernel.mk b/scripts/build/environments/kernel.mk
new file mode 100644
index 0000000..088cdf0
--- /dev/null
+++ b/scripts/build/environments/kernel.mk
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+WARNINGS ?= -Wall -Wextra -Wno-unused-parameter
+
+ifeq ($(BUILD_VARIANT),release)
+KERNEL_OPT_FLAGS := -O2 -g0 -DNDEBUG
+else
+KERNEL_OPT_FLAGS := -O2 -g
+endif
+
+CFLAGS := $(WARNINGS) $(KERNEL_OPT_FLAGS) \
+ -ffreestanding -nostdlib \
+ -mcmodel=medany -fPIE -MMD -MP \
+ $(TOOLCHAIN_CFLAGS) $(KCPPFLAGS) $(INCLUDES) \
+ -I$(BUILD)/generated
+
+CFLAGS_LIBC := $(CFLAGS) -std=gnu23 -Iinclude/libc-shim \
+ -Wno-parentheses -Wno-sign-compare
+
+CXXFLAGS := $(CFLAGS) $(TOOLCHAIN_CXXFLAGS) -std=c++23 \
+ -fno-exceptions -fno-rtti -fno-use-cxa-atexit \
+ -fno-threadsafe-statics
+
+# Pre-MMU assembly must never use GOT-indirect addressing.
+ASFLAGS := $(filter-out -fPIE,$(CFLAGS)) -fno-pie
+
+LDFLAGS := -nostdlib -shared -Bsymbolic -z notext -z norelro \
+ --no-dynamic-linker
diff --git a/scripts/build/environments/phys.mk b/scripts/build/environments/phys.mk
new file mode 100644
index 0000000..6a11c12
--- /dev/null
+++ b/scripts/build/environments/phys.mk
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Early physical-address execution environment. It deliberately has no heap,
+# exceptions, RTTI, thread-safe statics, or PIE/GOT assumptions.
+PHYS_CFLAGS := $(WARNINGS) -Os -g -ffreestanding -nostdlib \
+ -fno-pie -fno-stack-protector $(TOOLCHAIN_CFLAGS) \
+ $(KCPPFLAGS) $(INCLUDES) -I$(BUILD)/generated
+PHYS_CXXFLAGS := $(PHYS_CFLAGS) $(TOOLCHAIN_CXXFLAGS) -std=c++23 \
+ -fno-exceptions -fno-rtti -fno-use-cxa-atexit \
+ -fno-threadsafe-statics
+PHYS_ASFLAGS := $(PHYS_CFLAGS)
+