mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
b5c98ede08
Replace the old logic where we would start with a host build, and swap all the CMake compiler and target variables underneath it to trick CMake into building for Serenity after we configured and built the Lagom code generators. The SuperBuild creates two ExternalProjects, one for Lagom and one for Serenity. The Serenity project depends on the install stage for the Lagom build. The SuperBuild also generates a CMakeToolchain file for the Serenity build to use that replaces the old toolchain file that was only used for Ports. To ensure that code generators are rebuilt when core libraries such as AK and LibCore are modified, developers will need to direct their manual `ninja` invocations to the SuperBuild's binary directory instead of the Serenity binary directory. This commit includes warning coalescing and option style cleanup for the affected CMakeLists in the Kernel, top level, and runtime support libraries. A large part of the cleanup is replacing USE_CLANG_TOOLCHAIN with the proper CMAKE_CXX_COMPILER_ID variable, which will no longer be confused by a host clang compiler.
48 lines
2.1 KiB
CMake
48 lines
2.1 KiB
CMake
set(LOADER_SOURCES
|
|
main.cpp
|
|
misc.cpp
|
|
)
|
|
|
|
file(GLOB AK_SOURCES "../../AK/*.cpp")
|
|
file(GLOB ELF_SOURCES "../Libraries/LibELF/*.cpp")
|
|
file(GLOB LIBC_SOURCES1 "../Libraries/LibC/*.cpp")
|
|
file(GLOB LIBC_SOURCES2 "../Libraries/LibC/*/*.cpp")
|
|
|
|
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/aarch64/*.S")
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/aarch64/entry.S ../Libraries/LibELF/Arch/aarch64/plt_trampoline.S)
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "i686")
|
|
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/i386/*.S")
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/i386/entry.S ../Libraries/LibELF/Arch/i386/plt_trampoline.S)
|
|
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/x86_64/*.S")
|
|
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/x86_64/entry.S ../Libraries/LibELF/Arch/x86_64/plt_trampoline.S)
|
|
endif()
|
|
|
|
file(GLOB LIBSYSTEM_SOURCES "../Libraries/LibSystem/*.cpp")
|
|
|
|
if (ENABLE_UNDEFINED_SANITIZER)
|
|
set(LOADER_SOURCES ${LOADER_SOURCES} ../Libraries/LibSanitizer/UBSanitizer.cpp)
|
|
endif()
|
|
|
|
add_definitions(-D_DYNAMIC_LOADER)
|
|
|
|
set(SOURCES ${LOADER_SOURCES} ${AK_SOURCES} ${ELF_SOURCES} ${LIBC_SOURCES1} ${LIBC_SOURCES2} ${LIBC_SOURCES3} ${LIBSYSTEM_SOURCES})
|
|
|
|
# FIXME: remove -nodefaultlibs after the next toolchain update
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -nodefaultlibs -nostdlib -pie -fpic -DNO_TLS")
|
|
|
|
set_source_files_properties (../Libraries/LibC/ssp.cpp PROPERTIES COMPILE_FLAGS
|
|
"-fno-stack-protector")
|
|
# Prevent GCC from removing null checks by marking the `FILE*` argument non-null
|
|
set_source_files_properties(../Libraries/LibC/stdio.cpp PROPERTIES COMPILE_FLAGS "-fno-builtin-fputc -fno-builtin-fputs -fno-builtin-fwrite")
|
|
|
|
add_executable(Loader.so ${SOURCES})
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
target_link_libraries(Loader.so PRIVATE gcc)
|
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
|
|
target_link_libraries(Loader.so PRIVATE "clang_rt.builtins-${SERENITY_CLANG_ARCH}")
|
|
endif ()
|
|
target_link_options(Loader.so PRIVATE LINKER:--no-dynamic-linker)
|
|
install(TARGETS Loader.so RUNTIME DESTINATION usr/lib/)
|