mirror of
https://github.com/seL4/seL4.git
synced 2026-03-27 02:19:55 +00:00
cmake: remove default flags added to the compiler
Previously, CMake defaults to adding various flags to the compile
options, such as `-O3`, `-DNDEBUG`, and `-g`. Here is an excerpt from
CMakeCache.txt:
//Flags used by the C compiler during RELEASE builds.
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
//Flags used by the C compiler during RELWITHDEBINFO builds.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
We instead change the CMAKE_BUILD_TYPE to 'None' so that CMake
doesn't try to be clever and append extra compile flags. Anything
that depends on seL4 will be unaffected as CMake variables are scoped.
This should have no meaningful change to the kernel's generated code,
as the compile flags were being overridden anyway.
Relevant parts of the build.ninja file for comparison:
- Now, `-DRELEASE=ON`:
FLAGS = -march=armv8-a -D__KERNEL_64__ -std=c99 -Wall -Werror
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs
-Wmissing-declarations -Wundef -Wpointer-arith -Wno-nonnull
-nostdinc -ffreestanding -fno-stack-protector
-fno-asynchronous-unwind-tables -fno-common -O2 -nostdlib
-fno-pic -fno-pie -mgeneral-regs-only -mno-outline-atomics
-E -CC -I/sel4test-manifest/build/kernel/generated_prune
- Before, `-DRELEASE=ON`:
FLAGS = -march=armv8-a -D__KERNEL_64__ -O3 -DNDEBUG -std=c99 -Wall
-Werror -Wstrict-prototypes -Wmissing-prototypes
-Wnested-externs -Wmissing-declarations -Wundef
-Wpointer-arith -Wno-nonnull -nostdinc -ffreestanding
-fno-stack-protector -fno-asynchronous-unwind-tables
-fno-common -O2 -nostdlib -fno-pic -fno-pie
-mgeneral-regs-only -mno-outline-atomics -E -CC
-I/sel4test-manifest/build/kernel/generated_prune
Note the lack of -O3 -DNDEBUG options.
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
This commit is contained in:
committed by
Kent McLeod
parent
a478be32d5
commit
c406015c38
@@ -247,14 +247,16 @@ if(KernelFWholeProgram)
|
||||
KernelCommonFlags(-fwhole-program)
|
||||
endif()
|
||||
|
||||
# Stop CMake from appending various flags such as -O3/-O2, -DNDEBUG, -g, etc.
|
||||
# The kernel build sidesteps most of the CMake notions of release/debug and
|
||||
# has its own conceptualisations of the current optimisation levels that
|
||||
# conflict with CMake appending flags.
|
||||
set(CMAKE_BUILD_TYPE "None")
|
||||
|
||||
if(KernelDebugBuild)
|
||||
# As we control debug/release mode independently of CMake,
|
||||
# append the debug information flags manually.
|
||||
KernelCommonFlags(-g -ggdb)
|
||||
# Pretend to CMake that we're a release build with debug info. This is because
|
||||
# we do actually allow CMake to do the final link step, so we'd like it not to
|
||||
# strip our binary
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
if(KernelArchX86)
|
||||
|
||||
Reference in New Issue
Block a user