diff --git a/shim_et/xplat/executorch/build/runtime_wrapper.bzl b/shim_et/xplat/executorch/build/runtime_wrapper.bzl index d03a3f71b3b..0cabf73cbb9 100644 --- a/shim_et/xplat/executorch/build/runtime_wrapper.bzl +++ b/shim_et/xplat/executorch/build/runtime_wrapper.bzl @@ -117,6 +117,12 @@ def _patch_build_mode_flags(kwargs): "ovr_config//os:macos": ["-fvisibility=default"], }) + # Add -O2 compiler flag when the compiler_flag_O2 config is set + kwargs["compiler_flags"] = kwargs["compiler_flags"] + select({ + "DEFAULT": [], + "fbsource//xplat/assistant/oacr/native/scripts:compiler_flag_O2": ["-O2"], + }) + return kwargs def _patch_test_compiler_flags(kwargs):