diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt index 6294319815b4..39d383922e1d 100644 --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -41,8 +41,6 @@ if (NOT LIBCXX_ENABLE_RTTI) serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False) endif() -serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}") - if (CMAKE_CXX_COMPILER_TARGET) serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}") else() diff --git a/libcxx/utils/libcxx/test/features/libcxx_macros.py b/libcxx/utils/libcxx/test/features/libcxx_macros.py index 7a465f2e8786..92825a93ac0f 100644 --- a/libcxx/utils/libcxx/test/features/libcxx_macros.py +++ b/libcxx/utils/libcxx/test/features/libcxx_macros.py @@ -6,7 +6,7 @@ # # ===----------------------------------------------------------------------===## -from libcxx.test.dsl import Feature, compilerMacros +from libcxx.test.dsl import Feature, compilerMacros, programSucceeds features = [] @@ -74,3 +74,22 @@ for macro, feature in inverted_macros.items(): and compilerMacros(cfg)[m] == "0", ) ) + +for mode in ("none", "fast", "extensive", "debug"): + check_program = f""" + #include // any header to get the definitions + int main(int, char**) {{ + #if defined(_LIBCPP_VERSION) && \\ + defined(_LIBCPP_HARDENING_MODE) && _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_{mode.upper()} + return 0; + #else + return 1; + #endif + }} + """ + features.append( + Feature( + name=f"libcpp-hardening-mode={mode}", + when=lambda cfg, prog=check_program: programSucceeds(cfg, prog) + ) + ) diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py index 07158dcf8fba..d0bb38ab84df 100644 --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -420,7 +420,6 @@ DEFAULT_PARAMETERS = [ AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST") if hardening_mode == "fast" else None, AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE") if hardening_mode == "extensive" else None, AddCompileFlag("-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG") if hardening_mode == "debug" else None, - AddFeature("libcpp-hardening-mode={}".format(hardening_mode)) if hardening_mode != "undefined" else None, ], ), ),