diff --git a/starboard/build/config/BUILD.gn b/starboard/build/config/BUILD.gn index 0173fd5c8056..b2010320c8b9 100644 --- a/starboard/build/config/BUILD.gn +++ b/starboard/build/config/BUILD.gn @@ -246,4 +246,25 @@ config("default_cpp_standard") { if (is_host_win && !sb_is_modular) { cflags = [ "/std:c++17" ] } + + if (is_apple) { + cflags_cc = [ "-std=gnu++17" ] + cflags_objcc = [ "-std=gnu++17" ] + } +} + +config("cpp20_supported_config") { + if ((sb_is_modular && current_toolchain == cobalt_toolchain) || is_android) { + cflags_cc = [ "-std=c++20" ] + } + + # These flags apply to non-modular windows platforms which includes win32, xb1. + if (is_host_win && !sb_is_modular) { + cflags = [ "/std:c++20" ] + } + + if (is_apple) { + cflags_cc = [ "-std=gnu++20" ] + cflags_objcc = [ "-std=gnu++20" ] + } } diff --git a/starboard/build/config/mac/BUILD.gn b/starboard/build/config/mac/BUILD.gn index c69eaf2a32f4..6bf4ccfcf191 100644 --- a/starboard/build/config/mac/BUILD.gn +++ b/starboard/build/config/mac/BUILD.gn @@ -43,8 +43,6 @@ config("host") { config("common") { arflags = [ "-no_warning_for_no_symbols" ] - cflags_cc = [ "-std=gnu++17" ] - cflags_objcc = [ "-std=gnu++17" ] cflags = [ "-fno-common" ] asmflags = [ "-fno-common" ] ldflags = [ "-fno-common" ] diff --git a/starboard/nplb/compiler_compliance/BUILD.gn b/starboard/nplb/compiler_compliance/BUILD.gn index 63375ccaeb08..38dcd9fea97a 100644 --- a/starboard/nplb/compiler_compliance/BUILD.gn +++ b/starboard/nplb/compiler_compliance/BUILD.gn @@ -54,15 +54,6 @@ if (sb_enable_cpp20_audit) { # We do this to ensure the -std=c++20 flag is added after any other -std flag # so it overrides any other one. group("cpp20_supported_config_shim") { - public_configs = [ ":cpp20_supported_config" ] - } - - config("cpp20_supported_config") { - # These flags apply to non-modular windows platforms which includes win32, xb1. - if (is_host_win && !sb_is_modular) { - cflags_cc = [ "/std:c++20" ] - } else { - cflags_cc = [ "-std=c++20" ] - } + public_configs = [ "//starboard/build/config:cpp20_supported_config" ] } }