From 2a659a9d03a94206b041f4dcc6b8db693f168aae Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 9 Aug 2024 15:16:49 +0300 Subject: [PATCH] BuildSystem: Fix enable sse definition __enable_sse was never actually defined for any targets. This also adds __arch definition for libc (so `utsname` works). --- CMakeLists.txt | 3 +-- kernel/CMakeLists.txt | 6 +++++- userspace/libraries/LibC/CMakeLists.txt | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e438964..c08a832a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,7 @@ if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "banan-os") message(FATAL_ERROR "CMAKE_SYSTEM_NAME is not banan-os") endif () -#add_compile_options(-mno-sse -mno-sse2) -add_compile_definitions(__enable_sse=1) +set(BANAN_ENABLE_SSE 1) project(banan-os CXX C ASM) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index c3307b9e..3d330b8f 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -172,7 +172,11 @@ set(KERNEL_SOURCES add_executable(kernel ${KERNEL_SOURCES}) target_compile_definitions(kernel PUBLIC __is_kernel) -target_compile_definitions(kernel PUBLIC __arch=${BANAN_ARCH}) +target_compile_definitions(kernel PRIVATE __arch=${BANAN_ARCH}) +target_compile_definitions(kernel PRIVATE __enable_sse=${BANAN_ENABLE_SSE}) +if (NOT BANAN_ENABLE_SSE) + target_compile_options(kernel PRIVATE -mno-sse -mno-sse2) +endif () target_compile_options(kernel PUBLIC -O2 -g) target_compile_options(kernel PUBLIC $<$:-Wno-literal-suffix -fno-rtti -fno-exceptions>) diff --git a/userspace/libraries/LibC/CMakeLists.txt b/userspace/libraries/LibC/CMakeLists.txt index 1ad81877..61086b3a 100644 --- a/userspace/libraries/LibC/CMakeLists.txt +++ b/userspace/libraries/LibC/CMakeLists.txt @@ -36,6 +36,12 @@ set(LIBC_SOURCES ) add_library(libc ${LIBC_SOURCES}) +target_compile_definitions(libc PRIVATE __arch=${BANAN_ARCH}) +target_compile_definitions(libc PRIVATE __enable_sse=${BANAN_ENABLE_SSE}) +if (NOT BANAN_ENABLE_SSE) + target_compile_options(libc PRIVATE -mno-sse -mno-sse2) +endif () + target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns -fno-exceptions -nostdlib) target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)