From 22548a3f4a64f0fd37ff18c85a902243c1e99061 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 21 Jun 2024 17:10:58 +0300 Subject: [PATCH] BuildSystem: Fix crt file installation crt files for userspace are now a dependency of libc, which means that everytime libc gets installed, crt files will also install. This fixes the problem when building libc --- userspace/CMakeLists.txt | 1 - userspace/libraries/LibC/CMakeLists.txt | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/userspace/CMakeLists.txt b/userspace/CMakeLists.txt index 56654dc3bc..00881bddd7 100644 --- a/userspace/CMakeLists.txt +++ b/userspace/CMakeLists.txt @@ -53,7 +53,6 @@ add_custom_target(userspace) foreach(project ${USERSPACE_PROJECTS}) add_subdirectory(${project}) - add_dependencies(${project} crtx-install) add_dependencies(userspace ${project}) # This is to allow cmake to link when libc updates target_link_options(${project} PRIVATE -nolibc) diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 163c394f77..00cbcdbc35 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -35,15 +35,15 @@ add_library(libc ${LIBC_SOURCES}) target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns -nostdlib) target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=) -add_library(crt0 OBJECT arch/${BANAN_ARCH}/crt0.S) -add_library(crti OBJECT arch/${BANAN_ARCH}/crti.S) -add_library(crtn OBJECT arch/${BANAN_ARCH}/crtn.S) -add_custom_target(crtx-install - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crt0.o - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crti.o - COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_INSTALL_LIBDIR}/crtn.o - DEPENDS crt0 crti crtn sysroot -) +function(add_crtx crtx) + add_custom_target(${crtx} COMMAND ${CMAKE_CXX_COMPILER} -c -o ${crtx}.o ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/${crtx}.S) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${crtx}.o DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL) + add_dependencies(libc ${crtx}) +endfunction() + +add_crtx(crt0) +add_crtx(crti) +add_crtx(crtn) banan_include_headers(libc ban) banan_include_headers(libc kernel)