diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 059542c24335a2..26cd880d227855 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -768,7 +768,11 @@ def python_is_optimized(): for opt in cflags.split(): if opt.startswith('-O'): final_opt = opt - return final_opt not in ('', '-O0', '-Og') + if sysconfig.get_config_var("CC") == "gcc": + non_opts = ('', '-O0', '-Og') + else: + non_opts = ('', '-O0') + return final_opt not in non_opts def check_cflags_pgo():