mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
5dfe2eb389
Since https://reviews.llvm.org/D131441, libc++ must be included before LibC. As clang includes libc++ as one of the system includes, LibC must be included after those, and the only correct way to do that is to install LibC's headers into the sysroot. Targets that don't link with LibC yet require its headers for one reason or another must add install_libc_headers as a dependency to ensure that the correct headers have been (re)installed into the sysroot. LibC/stddef.h has been dropped since the built-in stddef.h receives a higher include priority. In addition, string.h and wchar.h must define __CORRECT_ISO_CPP_STRING_H_PROTO and _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS respectively in order to tell libc++ to not try to define methods implemented by LibC.
43 lines
1.8 KiB
CMake
43 lines
1.8 KiB
CMake
set(SOURCES
|
|
UBSanitizer.cpp
|
|
../Library/MiniStdLib.cpp
|
|
boot.S
|
|
multiboot.S
|
|
init.cpp
|
|
../../Userland/Libraries/LibELF/Relocation.cpp
|
|
)
|
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
set(PREKERNEL_TARGET Prekernel64)
|
|
elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
message(SEND_ERROR "Prekernel is not needed on aarch64 and should not be compiled!")
|
|
endif()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
|
|
|
|
add_executable(${PREKERNEL_TARGET} ${SOURCES})
|
|
add_dependencies(${PREKERNEL_TARGET} install_libc_headers)
|
|
target_compile_options(${PREKERNEL_TARGET} PRIVATE -no-pie -fno-pic -fno-threadsafe-statics)
|
|
|
|
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)
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE gcc)
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|
target_link_libraries(${PREKERNEL_TARGET} PRIVATE clang_rt.builtins)
|
|
endif()
|
|
|
|
add_custom_command(
|
|
TARGET ${PREKERNEL_TARGET} POST_BUILD
|
|
COMMAND ${CMAKE_OBJCOPY} -O elf32-i386 ${CMAKE_CURRENT_BINARY_DIR}/${PREKERNEL_TARGET} ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
|
|
BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/Prekernel
|
|
)
|
|
|
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Prekernel" DESTINATION boot)
|
|
|
|
# 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}")
|