|
|
|
@ -19,6 +19,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
include(cmake/git.cmake)
|
|
|
|
|
include(cmake/util.cmake)
|
|
|
|
|
|
|
|
|
|
include(cmake/config.cmake)
|
|
|
|
|
configure_file(
|
|
|
|
@ -28,10 +29,17 @@ configure_file(
|
|
|
|
|
|
|
|
|
|
include("arch/${ARCH}/config/toolchain.cmake")
|
|
|
|
|
|
|
|
|
|
# Used by the KASSERT macro for printing the filename relative to the source root
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
|
|
|
|
|
gay_append_cmake_c_flags(
|
|
|
|
|
-ggdb
|
|
|
|
|
-pipe
|
|
|
|
|
-nostdinc
|
|
|
|
|
-ffreestanding
|
|
|
|
|
-fno-stack-protector
|
|
|
|
|
-Wused-but-marked-unused
|
|
|
|
|
# Used by the KASSERT macro for printing the filename relative to the source root
|
|
|
|
|
"-D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -nostdinc -ffreestanding -fno-stack-protector")
|
|
|
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -pipe -D_ASM_SOURCE")
|
|
|
|
|
if(DEBUG)
|
|
|
|
|
# -Og on gcc optimizes for the best debugging experience, but apparently this
|
|
|
|
@ -39,12 +47,12 @@ if(DEBUG)
|
|
|
|
|
# you're supposed to use -O0 in order to get the most submissive and debuggable
|
|
|
|
|
# code instead:
|
|
|
|
|
# <https://clang.llvm.org/docs/CommandGuide/clang.html#code-generation-options>
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb")
|
|
|
|
|
gay_append_cmake_c_flags(-O0)
|
|
|
|
|
# i don't think -O0 does anything for assembly code, but it can't hurt to
|
|
|
|
|
# have it in there just in case (somebody check on this at some point plz)
|
|
|
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0 -ggdb")
|
|
|
|
|
gay_append_cmake_asm_flags(-O0)
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -ggdb")
|
|
|
|
|
gay_append_cmake_c_flags(-O2)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# --whole-archive ensures no (seemingly) unused symbols
|
|
|
|
|