From 0778d0c94ebb4796740e927643890c2dac44d86c Mon Sep 17 00:00:00 2001 From: Niranjan Yardi Date: Fri, 11 Aug 2023 16:44:19 -0700 Subject: [PATCH] Set sb_is_modular, sb_is_evergreen appropriately. (#1207) b/294267479 b/294230277 Modular builds are of 2 types: 1. evergreen 2. cobalt toolchain with platform native linker builds This change consolidates the build system to have mostly 2 flags for modular builds - sb_is_modular, sb_is_evergreen. 1. sb_is_modular : Includes common GN flags and variables related to modular and evergreen GN configurations. 2. sb_is_evergreen: Includes only evergreen-specific GN flags and variables 3. build_with_separate_cobalt_toolchain: Passed as a command line GN arg for cobalt toolchain with platform native linker builds : This flag is used very minimally in the GN code as most of the changes are governed by combinations of sb_is_modular , sb_is_evergreen This change also cleans up unused GN dependencies Change-Id: I8911ec3355ba6d1aa875c96307e7ea0e5a897fc1 --- build/toolchain/gcc_toolchain.gni | 2 +- cobalt/BUILD.gn | 3 --- components/update_client/BUILD.gn | 6 +----- starboard/BUILD.gn | 11 +++-------- starboard/build/config/BUILD.gn | 2 +- starboard/build/config/starboard_target_type.gni | 2 +- .../evergreen/shared/platform_configuration/BUILD.gn | 2 +- .../linux/shared/platform_configuration/BUILD.gn | 4 ++-- starboard/linux/x64x11/BUILD.gn | 4 ++-- starboard/linux/x64x11/clang/3.9/BUILD.gn | 2 +- starboard/linux/x64x11/egl/BUILD.gn | 2 +- starboard/linux/x64x11/gcc/6.3/BUILD.gn | 2 +- starboard/linux/x64x11/shared/BUILD.gn | 2 +- .../x64x11/shared/platform_configuration/BUILD.gn | 6 +++--- starboard/linux/x64x11/skia/BUILD.gn | 2 +- third_party/llvm-project/libcxx/BUILD.gn | 3 --- third_party/llvm-project/libcxxabi/BUILD.gn | 3 --- 17 files changed, 20 insertions(+), 38 deletions(-) diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index cf8ad60a5a29..2a2cc3c7963d 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -117,7 +117,7 @@ if (enable_resource_allowlist_generation) { template("gcc_toolchain") { toolchain(target_name) { is_starboard_toolchain = target_name == "starboard" - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { not_needed(["is_starboard_toolchain"]) } assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") diff --git a/cobalt/BUILD.gn b/cobalt/BUILD.gn index 53c4bc36e032..92fe9dc4d66f 100644 --- a/cobalt/BUILD.gn +++ b/cobalt/BUILD.gn @@ -81,8 +81,5 @@ group("default") { "//components/update_client", ] } - if (!build_with_separate_cobalt_toolchain) { - deps += [ "//third_party/llvm-project/libunwind:unwind_evergreen" ] - } } } diff --git a/components/update_client/BUILD.gn b/components/update_client/BUILD.gn index d83b2e664b57..8c3ab2025c87 100644 --- a/components/update_client/BUILD.gn +++ b/components/update_client/BUILD.gn @@ -246,10 +246,6 @@ target(gtest_target_type, "cobalt_slot_management_test") { "//starboard/loader_app:installation_manager", "//testing/gmock", "//testing/gtest", + "//starboard/loader_app" ] - if (build_with_separate_cobalt_toolchain) { - data_deps = [ "//starboard/loader_app($starboard_toolchain)" ] - } else { - deps += [ "//starboard/loader_app" ] - } } diff --git a/starboard/BUILD.gn b/starboard/BUILD.gn index 0bd4ef0b2b5d..9f1afbfbe57d 100644 --- a/starboard/BUILD.gn +++ b/starboard/BUILD.gn @@ -57,11 +57,6 @@ group("gn_all") { deps += [ "//starboard/benchmark" ] } - if (build_with_separate_cobalt_toolchain && is_cobalt_toolchain) { - assert(sb_is_modular, - "sb_is_modular should be set when building with cobalt_toolchain") - } - if (!sb_is_evergreen) { deps += [ "//third_party/lz4_lib:lz4" ] @@ -99,7 +94,7 @@ group("starboard") { if (sb_is_evergreen) { public_deps += [ "//starboard/elf_loader:sabi_string" ] } - if (build_with_separate_cobalt_toolchain) { + if (sb_is_modular && !sb_is_evergreen) { data_deps = [ ":starboard_platform_group($starboard_toolchain)" ] } else { public_deps += [ "//third_party/llvm-project/libunwind:unwind_evergreen" ] @@ -110,7 +105,7 @@ group("starboard") { "//starboard/common", ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { if (sb_is_evergreen_compatible) { public_deps += [ "//third_party/crashpad/wrapper" ] } else { @@ -215,7 +210,7 @@ if (current_toolchain == starboard_toolchain) { group("starboard_with_main") { public_deps = [ ":starboard" ] - if (build_with_separate_cobalt_toolchain) { + if (sb_is_modular && !sb_is_evergreen) { public_deps += [ "//$starboard_path:starboard_platform_with_main" ] } } diff --git a/starboard/build/config/BUILD.gn b/starboard/build/config/BUILD.gn index 84e33936b251..6a0290a7a328 100644 --- a/starboard/build/config/BUILD.gn +++ b/starboard/build/config/BUILD.gn @@ -92,7 +92,7 @@ config("host") { config("target") { if (current_toolchain != host_toolchain) { if (final_executable_type == "shared_library") { - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { # Rewrite main() functions into StarboardMain. TODO: This is a # hack, it would be better to be more surgical, here. defines = [ "main=StarboardMain" ] diff --git a/starboard/build/config/starboard_target_type.gni b/starboard/build/config/starboard_target_type.gni index 0c3983a457c7..503c0b03c019 100644 --- a/starboard/build/config/starboard_target_type.gni +++ b/starboard/build/config/starboard_target_type.gni @@ -17,7 +17,7 @@ declare_args() { } if (starboard_target_type == "") { - if (build_with_separate_cobalt_toolchain) { + if (sb_is_modular && !sb_is_evergreen) { starboard_target_type = "shared_library" } else { starboard_target_type = "group" diff --git a/starboard/evergreen/shared/platform_configuration/BUILD.gn b/starboard/evergreen/shared/platform_configuration/BUILD.gn index 01ac96f4605e..2340c86ce613 100644 --- a/starboard/evergreen/shared/platform_configuration/BUILD.gn +++ b/starboard/evergreen/shared/platform_configuration/BUILD.gn @@ -28,7 +28,7 @@ config("platform_configuration") { "-Wl,-u GetEvergreenSabiString", ] - if (!build_with_separate_cobalt_toolchain) { + if (sb_is_evergreen) { ldflags += [ "-nostdlib" ] } cflags = [ diff --git a/starboard/linux/shared/platform_configuration/BUILD.gn b/starboard/linux/shared/platform_configuration/BUILD.gn index c1b9622abcf4..4e7334a96f13 100644 --- a/starboard/linux/shared/platform_configuration/BUILD.gn +++ b/starboard/linux/shared/platform_configuration/BUILD.gn @@ -63,8 +63,8 @@ config("compiler_flags") { # Do not warn about unused function params. "-Wno-unused-parameter", ] - if (build_with_separate_cobalt_toolchain) { - # If we're building modularly, we need visibility. + if (sb_is_modular && !sb_is_evergreen) { + # If we're building with cobalt toolchain and native linker, we need visibility. cflags += [ "-fvisibility=default" ] } else { # Default visibility to hidden, to enable dead stripping. diff --git a/starboard/linux/x64x11/BUILD.gn b/starboard/linux/x64x11/BUILD.gn index 8888c702467f..3666f36cb196 100644 --- a/starboard/linux/x64x11/BUILD.gn +++ b/starboard/linux/x64x11/BUILD.gn @@ -16,7 +16,7 @@ static_library("starboard_platform") { check_includes = false sources = [ "//starboard/linux/x64x11/run_starboard_main.cc" ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/main.cc" ] } @@ -28,7 +28,7 @@ static_library("starboard_platform") { configs += [ "//starboard/build/config:starboard_implementation" ] } -if (build_with_separate_cobalt_toolchain) { +if (sb_is_modular && !sb_is_evergreen) { static_library("starboard_platform_with_main") { check_includes = false sources = [ "//starboard/linux/x64x11/main.cc" ] diff --git a/starboard/linux/x64x11/clang/3.9/BUILD.gn b/starboard/linux/x64x11/clang/3.9/BUILD.gn index b26b37630e54..f947b50ddbd3 100644 --- a/starboard/linux/x64x11/clang/3.9/BUILD.gn +++ b/starboard/linux/x64x11/clang/3.9/BUILD.gn @@ -16,7 +16,7 @@ static_library("starboard_platform") { check_includes = false sources = [ "//starboard/linux/x64x11/run_starboard_main.cc" ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/main.cc" ] } diff --git a/starboard/linux/x64x11/egl/BUILD.gn b/starboard/linux/x64x11/egl/BUILD.gn index e3ff3b53b756..91ed00730575 100644 --- a/starboard/linux/x64x11/egl/BUILD.gn +++ b/starboard/linux/x64x11/egl/BUILD.gn @@ -16,7 +16,7 @@ static_library("starboard_platform") { check_includes = false sources = [ "//starboard/linux/x64x11/run_starboard_main.cc" ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/main.cc" ] } diff --git a/starboard/linux/x64x11/gcc/6.3/BUILD.gn b/starboard/linux/x64x11/gcc/6.3/BUILD.gn index b26b37630e54..f947b50ddbd3 100644 --- a/starboard/linux/x64x11/gcc/6.3/BUILD.gn +++ b/starboard/linux/x64x11/gcc/6.3/BUILD.gn @@ -16,7 +16,7 @@ static_library("starboard_platform") { check_includes = false sources = [ "//starboard/linux/x64x11/run_starboard_main.cc" ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/main.cc" ] } diff --git a/starboard/linux/x64x11/shared/BUILD.gn b/starboard/linux/x64x11/shared/BUILD.gn index d58d764d12d8..2da6b40468c6 100644 --- a/starboard/linux/x64x11/shared/BUILD.gn +++ b/starboard/linux/x64x11/shared/BUILD.gn @@ -45,7 +45,7 @@ static_library("starboard_platform_sources") { "//starboard/shared/x11/window_internal.cc", ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/sanitizer_options.cc" ] } diff --git a/starboard/linux/x64x11/shared/platform_configuration/BUILD.gn b/starboard/linux/x64x11/shared/platform_configuration/BUILD.gn index 32c24f6a7049..ab9cf36ce80e 100644 --- a/starboard/linux/x64x11/shared/platform_configuration/BUILD.gn +++ b/starboard/linux/x64x11/shared/platform_configuration/BUILD.gn @@ -13,8 +13,8 @@ # limitations under the License. config("platform_configuration") { - if (current_toolchain == default_toolchain && - build_with_separate_cobalt_toolchain) { + if (current_toolchain == default_toolchain && sb_is_modular && + !sb_is_evergreen) { configs = [ "//starboard/evergreen/x64/platform_configuration" ] } else { configs = [ @@ -28,7 +28,7 @@ config("platform_configuration") { config("libraries") { configs = [ "//starboard/linux/shared/platform_configuration:libraries" ] - if (build_with_separate_cobalt_toolchain) { + if (sb_is_modular && !sb_is_evergreen) { libs = [ "//third_party/libvpx/platforms/linux-x64/libvpx.so.6" ] ldflags = [ "-Wl,-rpath=" + rebase_path("//") + "/third_party/libvpx/platforms/linux-x64/" ] diff --git a/starboard/linux/x64x11/skia/BUILD.gn b/starboard/linux/x64x11/skia/BUILD.gn index e62d4856551e..66917eaf8e30 100644 --- a/starboard/linux/x64x11/skia/BUILD.gn +++ b/starboard/linux/x64x11/skia/BUILD.gn @@ -21,7 +21,7 @@ static_library("starboard_platform") { "//starboard/linux/x64x11/skia/configuration.h", "//starboard/linux/x64x11/skia/system_get_extensions.cc", ] - if (!build_with_separate_cobalt_toolchain) { + if (!sb_is_modular || sb_is_evergreen) { sources += [ "//starboard/linux/x64x11/main.cc" ] } diff --git a/third_party/llvm-project/libcxx/BUILD.gn b/third_party/llvm-project/libcxx/BUILD.gn index 1d47c2309b56..0c80cace8222 100644 --- a/third_party/llvm-project/libcxx/BUILD.gn +++ b/third_party/llvm-project/libcxx/BUILD.gn @@ -119,7 +119,4 @@ static_library("cxx") { "//third_party/llvm-project/libcxxabi:cxxabi", "//third_party/musl:c", ] - if (!build_with_separate_cobalt_toolchain) { - deps += [ "//third_party/llvm-project/libunwind:unwind_evergreen" ] - } } diff --git a/third_party/llvm-project/libcxxabi/BUILD.gn b/third_party/llvm-project/libcxxabi/BUILD.gn index 0ed1b4244b65..9142fa43f4f7 100644 --- a/third_party/llvm-project/libcxxabi/BUILD.gn +++ b/third_party/llvm-project/libcxxabi/BUILD.gn @@ -90,7 +90,4 @@ static_library("cxxabi") { all_dependent_configs = [ ":cxxabi_dependents_config" ] deps = [ "//third_party/musl:c" ] - if (!build_with_separate_cobalt_toolchain) { - deps += [ "//third_party/llvm-project/libunwind:unwind_evergreen" ] - } }