Skip to content

Instantly share code, notes, and snippets.

@esnosy
Created January 8, 2023 08:37
Show Gist options
  • Save esnosy/bcd75ae9f57d4465108680e77eda7f0c to your computer and use it in GitHub Desktop.
Save esnosy/bcd75ae9f57d4465108680e77eda7f0c to your computer and use it in GitHub Desktop.
# https://airbus-seclab.github.io/c-compiler-security/
# TODO: Enable stricter flags for clang
if(CMAKE_COMPILER_IS_GNUCC)
target_compile_options(
tiny_stl
PRIVATE -Wdouble-promotion
-fno-common
-O2
-Werror
-Wall
-Wextra
-Wpedantic
-Wformat=2
-Wformat-overflow=2
-Wformat-truncation=2
-Wformat-security
-Wnull-dereference
-Wstack-protector
-Wtrampolines
-Walloca
-Wvla
-Warray-bounds=2
-Wimplicit-fallthrough=3
-Wshift-overflow=2
-Wcast-qual
-Wstringop-overflow=4
-Wconversion
-Wlogical-op
-Wduplicated-cond
-Wduplicated-branches
-Wformat-signedness
-Wshadow
-Wstrict-overflow=4
-Wundef
-Wswitch-default
-Wswitch-enum
-Wstack-usage=1000000
-Wcast-align=strict
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=3
# -fstack-protector-strong
-fstack-clash-protection
-fPIE
-fsanitize=bounds
-fsanitize-undefined-trap-on-error
-Wl,-z,relro
-Wl,-z,now
-Wl,-z,noexecstack
-Wl,-z,separate-code)
elseif(MSVC)
target_compile_options(tiny_stl PRIVATE /Wall /guard:cf /guard:ehcont)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment