Skip to content
Snippets Groups Projects

conf/distro: Add option for controlling compiler flags

Open Bernhard Rosenkränzer requested to merge bero/oniro:features/cflags into kirkstone
2 unresolved threads
1 file
+ 21
0
Compare changes
  • Side-by-side
  • Inline
@@ -112,3 +112,24 @@ ENABLE_UART ?= "1"
GPU_MEM:raspberrypi4-64 = "128"
SPLASH = "psplash-oniro"
# Configure what to optimize for:
# - "normal": A normal build.
# - "debugging": More debuggable, but less performant and less secure binaries.
# - "security": Add security hardening even when it comes at the cost of
# severe performance penalties
# - "size": Optimize for code size
# - "speed": Optimize for performance
# - "unsafespeed": Optimize for performance even when it means
# relaxing standards (potentially introducing bugs)
OPTIMIZE_FOR ?= "normal"
TARGET_CFLAGS += "-O2 -flto -Wformat -Wformat-security -Wformat-nonliteral -Werror=format-security -Werror=format-nonliteral -Werror=array-bounds -Wstrict-aliasing=2 -Werror=strict-aliasing -Wl,-z,relro,-z,now,-z,noexecstack,--hash-style=gnu,--as-needed -fvisibility=hidden -fvisibility-inlines-hidden -fstack-protector-strong --param=ssp-buffer-size=4 -fstack-clash-protection -fPIE -pie"
TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'debugging', '-g4', '', d)}"
TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'security', '-ftrivial-auto-var-init=pattern', '', d)}"
TARGET_CFLAGS:toolchain-clang += "${@oe.utils.conditional('OPTIMIZE_FOR', 'security', '-mspeculative-load-hardening -mretpoline', '', d)}"
Please register or sign in to reply
TARGET_CFLAGS:toolchain-gcc += "${@oe.utils.conditional('OPTIMIZE_FOR', 'security', '-mindirect-branch -mfunction-return', '', d)}"
TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'size', '-Os', '', d)}"
TARGET_CFLAGS:toolchain-clang += "${@oe.utils.conditional('OPTIMIZE_FOR', 'size', '-Oz', '', d)}"
TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'speed', '-O3 -fno-semantic-interposition -Wl,-Bsymbolic,-Bsymbolic-functions', '', d)}"
TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'unsafespeed', '-Ofast -fno-semantic-interposition -Wl,-Bsymbolic,-Bsymbolic-functions', '', d)}"
Loading