clang: make code submissive and debuggable
This commit is contained in:
parent
5c0fa715a4
commit
d4ee4e5953
1 changed files with 9 additions and 2 deletions
|
@ -23,8 +23,15 @@ include("arch/${ARCH}/config/toolchain.cmake")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffreestanding")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffreestanding")
|
||||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -D_ASM_SOURCE")
|
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -D_ASM_SOURCE")
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ggdb")
|
# -Og on gcc optimizes for the best debugging experience, but apparently this
|
||||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -Og -ggdb")
|
# is treated the same as -O1 on clang for some reason. The LLVM manual says
|
||||||
|
# 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")
|
||||||
|
# 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")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in a new issue