summaryrefslogtreecommitdiff
path: root/Kernel/CMakeLists.txt
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-04 17:50:05 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-04 18:25:01 +0100
commitadb2e6be5f2858076f7c226c1d986db464fd4f0b (patch)
tree464926708344545ee1942b96d991570c163a7bbc /Kernel/CMakeLists.txt
parentaae91dda66f99cce81f6d21ffad46528d69a2194 (diff)
downloadserenity-adb2e6be5f2858076f7c226c1d986db464fd4f0b.zip
Kernel: Make the kernel compile & link for x86_64
It's now possible to build the whole kernel with an x86_64 toolchain. There's no bootstrap code so it doesn't work yet (obviously.)
Diffstat (limited to 'Kernel/CMakeLists.txt')
-rw-r--r--Kernel/CMakeLists.txt14
1 files changed, 12 insertions, 2 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt
index 54037845b4..cd74fddb66 100644
--- a/Kernel/CMakeLists.txt
+++ b/Kernel/CMakeLists.txt
@@ -1,5 +1,11 @@
add_compile_options(-Os)
+if ("${SERENITY_ARCH}" STREQUAL "i686")
+ set(KERNEL_ARCH i386)
+elseif("${SERENITY_ARCH}" STREQUAL "x86_64")
+ set(KERNEL_ARCH x86_64)
+endif()
+
set(KERNEL_HEAP_SOURCES
Heap/SlabAllocator.cpp
Heap/kmalloc.cpp
@@ -285,6 +291,10 @@ if (NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES SerenityOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -nostdinc -nostdinc++")
endif()
+if ("${SERENITY_ARCH}" STREQUAL "x86_64")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcmodel=large -mno-red-zone")
+endif()
+
# Kernel Undefined Behavior Sanitizer (KUBSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
@@ -307,9 +317,9 @@ add_link_options(LINKER:-T ${CMAKE_CURRENT_BINARY_DIR}/linker.ld -nostdlib)
# kernel won't re-link when boot.S changes without this.
set_source_files_properties(init.cpp
PROPERTIES
- OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Arch/i386/Boot/boot.S
+ OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Arch/${KERNEL_ARCH}/Boot/boot.S
)
-add_library(boot OBJECT Arch/i386/Boot/boot.S)
+add_library(boot OBJECT Arch/${KERNEL_ARCH}/Boot/boot.S)
add_library(kernel_heap STATIC ${KERNEL_HEAP_SOURCES})
file(GENERATE OUTPUT linker.ld INPUT linker.ld)