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

Add an OPTIMIZE_FOR option that sets different compiler and hardening flags depending on the requested optimization type.

Signed-off-by: Bernhard Rosenkränzer bernhard.rosenkraenzer.ext@huawei.com

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
115
116 # Configure what to optimize for:
117 # - "normal": A normal build.
118 # - "debugging": More debuggable, but less performant and less secure binaries.
119 # - "security": Add security hardening even when it comes at the cost of
120 # severe performance penalties
121 # - "size": Optimize for code size
122 # - "speed": Optimize for performance
123 # - "unsafespeed": Optimize for performance even when it means
124 # relaxing standards (potentially introducing bugs)
125 OPTIMIZE_FOR ?= "normal"
126
127 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"
128 TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'debugging', '-g4', '', d)}"
129 TARGET_CFLAGS += "${@oe.utils.conditional('OPTIMIZE_FOR', 'security', '-ftrivial-auto-var-init=pattern', '', d)}"
130 TARGET_CFLAGS:toolchain-clang += "${@oe.utils.conditional('OPTIMIZE_FOR', 'security', '-mspeculative-load-hardening -mretpoline', '', d)}"
  • If I understand this patch well, we set up different options here, but keep everything as before for now, new options aren't used anywhere. Is this understanding correct?

  • mentioned in issue #202 (closed)

  • Please register or sign in to reply
    Loading