aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Richardson <alexrichardson@google.com>2023-06-07 13:25:01 -0700
committerAlex Richardson <alexrichardson@google.com>2023-06-07 15:55:50 -0700
commit4a9d0c33bd3e532aa369d8362a7faf1ba3cfd26a (patch)
tree0203281924dfec359631df7f2d1cc9c3d5cff2f4
parentacb933b5ac129932a37ab79b6e672b5156dd1510 (diff)
downloadlk-4a9d0c33bd3e532aa369d8362a7faf1ba3cfd26a.tar.gz
[make] Build with -ffreestanding
We should build with -ffreestanding since we are building an OS kernel and cannot rely on all hosted environment functionality being present. Specifically this fixes a compilation error with clang caused by the the #include_next <limits.h>: ``` In file included from target/pc-x86/config.c:9: In file included from dev/include/dev/driver.h:10: In file included from lib/libc/include/sys/types.h:10: In file included from lib/libc/include/limits.h:5: In file included from /usr/lib/llvm-15/lib/clang/15.0.7/include/limits.h:21: /usr/include/limits.h:26:10: fatal error: 'bits/libc-header-start.h' file not found #include <bits/libc-header-start.h> ``` The flag fixes this issue by ensuring that __STDC_HOSTED__ is no longer set to 1, so Clang's limits.h will not try to include the host system one.
-rw-r--r--engine.mk3
1 files changed, 3 insertions, 0 deletions
diff --git a/engine.mk b/engine.mk
index 950af50e..cde3a250 100644
--- a/engine.mk
+++ b/engine.mk
@@ -66,6 +66,9 @@ GLOBAL_COMPILEFLAGS := -g -include $(CONFIGHEADER)
GLOBAL_COMPILEFLAGS += -Wextra -Wall -Werror=return-type -Wshadow -Wdouble-promotion
GLOBAL_COMPILEFLAGS += -Wno-multichar -Wno-unused-parameter -Wno-unused-function -Wno-unused-label
GLOBAL_COMPILEFLAGS += -fno-common
+# Build with -ffreestanding since we are building an OS kernel and cannot
+# rely on all hosted environment functionality being present.
+GLOBAL_COMPILEFLAGS += -ffreestanding
GLOBAL_CFLAGS := --std=gnu11 -Werror-implicit-function-declaration -Wstrict-prototypes -Wwrite-strings
GLOBAL_CPPFLAGS := --std=c++14 -fno-exceptions -fno-rtti -fno-threadsafe-statics
GLOBAL_ASMFLAGS := -DASSEMBLY