From ba19e48d90208b5550e607153aab5d007d3d4dd5 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Tue, 4 Jan 2022 09:48:45 -0800 Subject: [PATCH] Fix C++ compiler option checks, increase max stack frame size The former fixes the actual compiler option checks in `CMakeLists.txt`. The latter is to avoid a compiler warning in `sandboxed_api/sandbox2/util.cc`, which needs a stack frame size bigger than pthread's default value (16K). PiperOrigin-RevId: 419618052 Change-Id: Ieaf72a03bfad0853d774ce0548040e3f2a3ebbc0 --- CMakeLists.txt | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f39e7c9..d9a26ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,14 +89,29 @@ target_include_directories(sapi_base INTERFACE "${Protobuf_INCLUDE_DIR}" ) if(UNIX) - foreach(flag IN ITEMS -Wno-deprecated - -Wno-deprecated-declarations - -Wno-psabi) - check_cxx_compiler_flag(${flag} _sapi_has_flag) - if(_sapi_has_flag) - target_compile_options(sapi_base INTERFACE ${flag}) + set(_sapi_check_no_deprecated + -Wno-deprecated SAPI_HAS_W_NO_DEPRECATED + ) + # For sandbox2/util.cc's CloneAndJump() + set(_sapi_check_frame_larger_than + -Wframe-larger-than=20480 SAPI_HAS_W_FRAME_LARGER_THAN + ) + set(_sapi_check_no_deprecated_declarations + -Wno-deprecated-declarations SAPI_HAS_W_NO_DEPRECATED_DECLARATIONS + ) + set(_sapi_check_no_psabi + -Wno-psabi SAPI_HAS_W_NO_PSABI + ) + foreach(check IN ITEMS _sapi_check_no_deprecated + _sapi_check_frame_larger_than + _sapi_check_no_deprecated_declarations + _sapi_check_no_psabi) + list(GET ${check} 0 opt_value) + list(GET ${check} 1 var_name) + check_cxx_compiler_flag(${opt_value} ${var_name}) + if(${var_name}) + target_compile_options(sapi_base INTERFACE ${opt_value}) endif() - unset(_sapi_has_flag) endforeach() endif()