Skip to content

Commit

Permalink
pw_toolchain: Use -Oz for size optimized Clang+arm
Browse files Browse the repository at this point in the history
Sets the Clang-based ARM toolchain to use "-Oz" for size-optimized
builds rather than "-Os".

Change-Id: I7887017e781ef7e94d792e114beef333678c7549
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/32240
Pigweed-Auto-Submit: Armando Montanez <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
armandomontanez authored and CQ Bot Account committed Aug 26, 2022
1 parent 760344f commit 994fb89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions pw_build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ config("optimize_size") {
ldflags = cflags
}

config("optimize_size_clang") {
cflags = [ "-Oz" ]
ldflags = cflags
}

# Standard compiler flags to reduce output binary size.
config("reduced_size") {
cflags = [
Expand Down
16 changes: 8 additions & 8 deletions pw_toolchain/arm_clang/toolchains.gni
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m0plus_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m0plus + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m0plus + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m3_debug = {
Expand All @@ -84,7 +84,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m3_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m3 + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m3 + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m4_debug = {
Expand All @@ -105,7 +105,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m4_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m4 + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m4 + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m4f_debug = {
Expand All @@ -126,7 +126,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m4f_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m4f + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m4f + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m7_debug = {
Expand All @@ -147,7 +147,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m7_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m7 + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m7 + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m7f_debug = {
Expand All @@ -168,7 +168,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m7f_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m7f + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m7f + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m33_debug = {
Expand All @@ -189,7 +189,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m33_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m33 + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m33 + [ "$dir_pw_build:optimize_size_clang" ]
}
}
cortex_m33f_debug = {
Expand All @@ -210,7 +210,7 @@ pw_toolchain_arm_clang = {
name = "arm_clang_cortex_m33f_size_optimized"
forward_variables_from(_arm_clang_toolchain, "*")
defaults = {
default_configs = _cortex_m33f + [ "$dir_pw_build:optimize_size" ]
default_configs = _cortex_m33f + [ "$dir_pw_build:optimize_size_clang" ]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pw_toolchain/host_clang/toolchains.gni
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pw_toolchain_host_clang = {
forward_variables_from(_host_clang_toolchain, "*")
defaults = {
forward_variables_from(_defaults, "*")
default_configs += [ "$dir_pw_build:optimize_size" ]
default_configs += [ "$dir_pw_build:optimize_size_clang" ]
foreach(sanitizer, pw_toolchain_SANITIZERS) {
default_configs +=
[ "$dir_pw_toolchain/host_clang:sanitize_$sanitizer" ]
Expand Down

0 comments on commit 994fb89

Please sign in to comment.