From 7b8260f3f63d61962d14bbd8ee0bba95e1a62a24 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 7 Apr 2023 12:07:08 +0200 Subject: [PATCH] all: Enable/disable debug symbols/optimization in COMMON_FLAGS --- CMakeLists.txt | 6 ++++++ kernel/CMakeLists.txt | 6 +----- libc/CMakeLists.txt | 6 ------ libluna/CMakeLists.txt | 9 --------- libos/CMakeLists.txt | 7 ------- tools/build-debug.sh | 2 +- 6 files changed, 8 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24773c9e..82371dab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,12 @@ set(COMMON_FLAGS -Wall -Wextra -Werror -Wvla -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -std=c++20 -fno-rtti -fno-exceptions) +if(LUNA_NO_OPTIMIZATIONS) +set(COMMON_FLAGS ${COMMON_FLAGS} -ggdb) +else() +set(COMMON_FLAGS ${COMMON_FLAGS} -Os) +endif() + add_subdirectory(libluna) add_subdirectory(libos) add_subdirectory(libc) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 2909560b..a924291f 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -85,12 +85,8 @@ if("${LUNA_ARCH}" MATCHES "x86_64") target_link_options(moon PRIVATE -mno-red-zone) endif() -if(MOON_DEBUG_SYMBOLS) - message(STATUS "Building Moon with debug symbols") - target_compile_options(moon PRIVATE -ggdb) +if(MOON_DEBUG) include(debug.cmake) -else() - target_compile_options(moon PRIVATE -Os) endif() target_link_options(moon PRIVATE -lgcc -Wl,--build-id=none -z max-page-size=0x1000 -mcmodel=kernel) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 1fe7eb5b..11e12f98 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -42,12 +42,6 @@ target_include_directories(bare_libc PUBLIC include/) target_compile_options(bare_libc PRIVATE ${COMMON_FLAGS}) -if(LUNA_DEBUG_SYMBOLS) - target_compile_options(bare_libc PRIVATE -ggdb) -else() - target_compile_options(bare_libc PRIVATE -Os) -endif() - target_link_options(bare_libc PRIVATE -nostdlib) set_target_properties(bare_libc PROPERTIES CXX_STANDARD 20) diff --git a/libluna/CMakeLists.txt b/libluna/CMakeLists.txt index 3cba6861..7c110a14 100644 --- a/libluna/CMakeLists.txt +++ b/libluna/CMakeLists.txt @@ -51,12 +51,3 @@ target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -m target_compile_definitions(luna-freestanding PUBLIC ARCH_X86_64) target_compile_definitions(luna PUBLIC ARCH_X86_64) endif() - -if(LUNA_DEBUG_SYMBOLS) - message(STATUS "Building Luna with debug symbols") - target_compile_options(luna PRIVATE -ggdb) - target_compile_options(luna-freestanding PRIVATE -ggdb) -else() - target_compile_options(luna PRIVATE -Os) - target_compile_options(luna-freestanding PRIVATE -Os) -endif() diff --git a/libos/CMakeLists.txt b/libos/CMakeLists.txt index 4629a903..c939aba1 100644 --- a/libos/CMakeLists.txt +++ b/libos/CMakeLists.txt @@ -15,10 +15,3 @@ target_include_directories(os PUBLIC ${LUNA_BASE}/usr/include) if("${LUNA_ARCH}" MATCHES "x86_64") target_compile_definitions(os PUBLIC ARCH_X86_64) endif() - -if(LUNA_DEBUG_SYMBOLS) - message(STATUS "Building libOS with debug symbols") - target_compile_options(os PRIVATE -ggdb) -else() - target_compile_options(os PRIVATE -Os) -endif() diff --git a/tools/build-debug.sh b/tools/build-debug.sh index d6e05cf6..afa8ef62 100755 --- a/tools/build-debug.sh +++ b/tools/build-debug.sh @@ -11,7 +11,7 @@ tools/full-clean.sh tools/install-headers.sh -cmake -S . -B $LUNA_BUILD_DIR -DMOON_DEBUG_SYMBOLS=ON -DLUNA_DEBUG_SYMBOLS=ON -G "$LUNA_CMAKE_GENERATOR_NAME" +cmake -S . -B $LUNA_BUILD_DIR -DLUNA_NO_OPTIMIZATIONS=ON -DMOON_DEBUG=ON -G "$LUNA_CMAKE_GENERATOR_NAME" cmake --build $LUNA_BUILD_DIR cmake --install $LUNA_BUILD_DIR