2021-07-18 12:47:32 +00:00
|
|
|
set(SOURCES
|
2021-09-07 01:01:13 +00:00
|
|
|
UBSanitizer.cpp
|
2021-09-07 00:49:38 +00:00
|
|
|
../MiniStdLib.cpp
|
2022-03-08 17:21:40 +00:00
|
|
|
boot.S
|
|
|
|
multiboot.S
|
|
|
|
init.cpp
|
|
|
|
../../Userland/Libraries/LibELF/Relocation.cpp
|
2021-08-28 17:41:14 +00:00
|
|
|
)
|
|
|
|
|
2022-10-04 00:05:54 +00:00
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
2023-04-28 15:27:24 +00:00
|
|
|
set(PREKERNEL_TARGET Prekernel64)
|
2022-03-08 17:21:40 +00:00
|
|
|
elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
|
|
message(SEND_ERROR "Prekernel is not needed on aarch64 and should not be compiled!")
|
2021-07-18 12:47:32 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-26 13:10:51 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
|
|
|
|
|
2023-04-28 15:27:24 +00:00
|
|
|
add_executable(${PREKERNEL_TARGET} ${SOURCES})
|
2021-09-12 13:09:36 +00:00
|
|
|
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2022-03-08 17:21:40 +00:00
|
|
|
target_link_options(${PREKERNEL_TARGET} PRIVATE LINKER:-T ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld -nostdlib LINKER:--no-pie)
|
|
|
|
set_target_properties(${PREKERNEL_TARGET} PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2021-09-07 08:21:36 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2021-09-17 14:01:46 +00:00
|
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE gcc)
|
2021-09-07 08:21:36 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
Toolchain+Meta: Update LLVM version to 13.0.0
This commit updates the Clang toolchain's version to 13.0.0, which comes
with better C++20 support and improved handling of new features by
clang-format. Due to the newly enabled `-Bsymbolic-functions` flag, our
Clang binaries will only be 2-4% slower than if we dynamically linked
them, but we save hundreds of megabytes of disk space.
The `BuildClang.sh` script has been reworked to build the entire
toolchain in just three steps: one for the compiler, one for GNU
binutils, and one for the runtime libraries. This reduces the complexity
of the build script, and will allow us to modify the CI configuration to
only rebuild the libraries when our libc headers change.
Most of the compile flags have been moved out to a separate CMake cache
file, similarly to how the Android and Fuchsia toolchains are
implemented within the LLVM repo. This provides a nicer interface than
the heaps of command-line arguments.
We no longer build separate toolchains for each architecture, as the
same Clang binary can compile code for multiple targets.
The horrible mess that `SERENITY_CLANG_ARCH` was, has been removed in
this commit. Clang happily accepts an `i686-pc-serenity` target triple,
which matches what our GCC toolchain accepts.
2021-08-13 10:11:12 +00:00
|
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE clang_rt.builtins)
|
2021-07-13 14:43:45 +00:00
|
|
|
endif()
|
2021-07-18 12:47:32 +00:00
|
|
|
|
2022-03-08 17:21:40 +00:00
|
|
|
add_custom_command(
|
|
|
|
TARGET ${PREKERNEL_TARGET} POST_BUILD
|
2023-04-28 15:27:24 +00:00
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
|
2022-03-08 17:21:40 +00:00
|
|
|
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
|
|
|
|
)
|
2021-10-13 21:43:02 +00:00
|
|
|
|
2023-04-28 15:27:24 +00:00
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
|
2021-08-25 03:28:51 +00:00
|
|
|
|
|
|
|
# Remove options which the Prekernel environment doesn't support.
|
|
|
|
get_target_property(PREKERNEL_TARGET_OPTIONS ${PREKERNEL_TARGET} COMPILE_OPTIONS)
|
|
|
|
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize-coverage=trace-pc")
|
|
|
|
list(REMOVE_ITEM PREKERNEL_TARGET_OPTIONS "-fsanitize=kernel-address")
|
|
|
|
set_target_properties(${PREKERNEL_TARGET} PROPERTIES COMPILE_OPTIONS "${PREKERNEL_TARGET_OPTIONS}")
|