From 295fb5d0b8166603d22e54901949e1866f5ff070 Mon Sep 17 00:00:00 2001 From: Fabian Sommer Date: Mon, 22 Aug 2022 10:25:04 +0000 Subject: [PATCH] NaCl on ARM64: Remove dependencies on //skia NaCl cannot depend on //skia when building for ARM64, as in that build some libraries are not present in the 32-bit version that NaCl needs. Therefore, build some (parts of) files only in builds that are not for nacl_helper. Introduce a new buildflag IS_MINIMAL_TOOLCHAIN. This is to limit dependencies in .h/.cc files if we build nacl_helper for ARM64. Use nogncheck for such conditional includes as gn does not run the preprocessor. Test: Build nacl_helper for Linux ARM64 Bug: 1339021 Change-Id: Id95147bc134e34fbae91af3d540ed30a4e96b512 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3829145 Reviewed-by: Mustafa Emre Acer Commit-Queue: Fabian Sommer Reviewed-by: Derek Schuff Reviewed-by: Mark Seaborn Reviewed-by: vikas soni Cr-Commit-Position: refs/heads/main@{#1037644} --- components/nacl/common/BUILD.gn | 6 +++++- components/nacl/loader/BUILD.gn | 5 ++++- gpu/command_buffer/client/BUILD.gn | 9 ++++++--- gpu/command_buffer/client/DEPS | 1 + .../client/gles2_implementation.cc | 12 +++++++----- gpu/ipc/common/BUILD.gn | 5 +++-- ppapi/proxy/BUILD.gn | 6 ++++-- ppapi/proxy/DEPS | 1 + ppapi/proxy/ppb_image_data_proxy.cc | 19 ++++++++++--------- ppapi/proxy/ppb_image_data_proxy.h | 11 ++++++----- ppapi/shared_impl/BUILD.gn | 4 +++- ppapi/shared_impl/DEPS | 1 + ppapi/shared_impl/ppb_image_data_shared.cc | 8 +++++--- .../private/net_address_private_impl.cc | 8 +++++--- .../private/net_address_private_impl.h | 9 ++++++++- 15 files changed, 69 insertions(+), 36 deletions(-) diff --git a/components/nacl/common/BUILD.gn b/components/nacl/common/BUILD.gn index 15fcd45c3fa6ee..27cb91a3547dda 100644 --- a/components/nacl/common/BUILD.gn +++ b/components/nacl/common/BUILD.gn @@ -4,6 +4,7 @@ import("//build/buildflag_header.gni") import("//components/nacl/features.gni") +import("//components/nacl/toolchain.gni") import("//mojo/public/tools/bindings/mojom.gni") if (enable_nacl) { @@ -146,5 +147,8 @@ static_library("switches") { buildflag_header("buildflags") { header = "buildflags.h" - flags = [ "ENABLE_NACL=$enable_nacl" ] + flags = [ + "ENABLE_NACL=$enable_nacl", + "IS_MINIMAL_TOOLCHAIN=$is_minimal_toolchain", + ] } diff --git a/components/nacl/loader/BUILD.gn b/components/nacl/loader/BUILD.gn index 622e78d1bb54af..e0fee03a82388e 100644 --- a/components/nacl/loader/BUILD.gn +++ b/components/nacl/loader/BUILD.gn @@ -166,7 +166,10 @@ if ((is_linux || is_chromeos) && current_cpu != "arm64") { ] if (is_minimal_toolchain) { - assert_no_deps += [ "//net" ] + assert_no_deps += [ + "//net", + "//skia", + ] } } diff --git a/gpu/command_buffer/client/BUILD.gn b/gpu/command_buffer/client/BUILD.gn index 6b39c77003577e..77bfd14d69dede 100644 --- a/gpu/command_buffer/client/BUILD.gn +++ b/gpu/command_buffer/client/BUILD.gn @@ -2,9 +2,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//components/nacl/toolchain.gni") import("//ui/gl/features.gni") -if (!is_nacl) { +if (!is_nacl && !is_minimal_toolchain) { import("//skia/features.gni") } @@ -95,7 +96,7 @@ source_set("client_sources") { ] # These files now rely on Skia which isn't allowed as a dependency in nacl builds. - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { sources += [ "shared_image_interface.cc", "shared_image_interface.h", @@ -235,13 +236,14 @@ component("gles2_implementation") { ":gles2_cmd_helper", ":gles2_interface", "//base", + "//components/nacl/common:buildflags", "//gpu/command_buffer/common", "//gpu/command_buffer/common:gles2", "//gpu/command_buffer/common:gles2_utils", "//ui/gfx/geometry", ] - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//components/viz/common:resource_format", "//ui/gfx:color_space", @@ -338,6 +340,7 @@ component("gles2_implementation_no_check") { ":gles2_cmd_helper", ":gles2_interface", "//base", + "//components/nacl/common:buildflags", "//gpu/command_buffer/common", "//gpu/command_buffer/common:gles2", "//gpu/command_buffer/common:gles2_utils", diff --git a/gpu/command_buffer/client/DEPS b/gpu/command_buffer/client/DEPS index 516d9f6c60047f..aa9d3f02550587 100644 --- a/gpu/command_buffer/client/DEPS +++ b/gpu/command_buffer/client/DEPS @@ -1,6 +1,7 @@ include_rules = [ "+ui/latency", "+cc/paint", + "+components/nacl/common/buildflags.h", "+third_party/skia", "+components/viz/common/resources/resource_format.h", "+components/viz/common/resources/resource_format_utils.h", diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 5c61920b1f9e46..e97c3bebd8b6d5 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -37,6 +37,7 @@ #include "base/trace_event/process_memory_dump.h" #include "base/trace_event/trace_event.h" #include "build/build_config.h" +#include "components/nacl/common/buildflags.h" #include "gpu/command_buffer/client/buffer_tracker.h" #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gpu_control.h" @@ -56,9 +57,9 @@ #include "ui/gfx/geometry/rect_f.h" #include "ui/gl/gpu_preference.h" -#if !defined(__native_client__) -#include "ui/gfx/color_space.h" -#include "ui/gfx/ipc/color/gfx_param_traits.h" +#if !defined(__native_client__) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) +#include "ui/gfx/color_space.h" // nogncheck +#include "ui/gfx/ipc/color/gfx_param_traits.h" // nogncheck #endif #if defined(GPU_CLIENT_DEBUG) @@ -82,7 +83,8 @@ // // If it was up to us we'd just always write to the destination but the OpenGL // spec defines the behavior of OpenGL functions, not us. :-( -#if defined(__native_client__) || defined(GLES2_CONFORMANCE_TESTS) +#if defined(__native_client__) || defined(GLES2_CONFORMANCE_TESTS) || \ + BUILDFLAG(IS_MINIMAL_TOOLCHAIN) #define GPU_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) #define GPU_CLIENT_DCHECK(v) #elif defined(GPU_DCHECK) @@ -5924,7 +5926,7 @@ void GLES2Implementation::ResizeCHROMIUM(GLuint width, << height << ", " << scale_factor << ", " << alpha << ")"); // Including gfx::ColorSpace would bring Skia and a lot of other code into // NaCl's IRT, so just leave the color space unspecified. -#if !defined(__native_client__) +#if !defined(__native_client__) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) if (gl_color_space) { gfx::ColorSpace gfx_color_space = *reinterpret_cast(gl_color_space); diff --git a/gpu/ipc/common/BUILD.gn b/gpu/ipc/common/BUILD.gn index 39432cb7c51291..7a14e48d85c455 100644 --- a/gpu/ipc/common/BUILD.gn +++ b/gpu/ipc/common/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/ui.gni") +import("//components/nacl/toolchain.gni") import("//gpu/vulkan/features.gni") import("//mojo/public/tools/bindings/mojom.gni") @@ -52,7 +53,7 @@ source_set("command_buffer_traits_sources") { "//ui/gfx/ipc/geometry", ] - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//ui/gfx/ipc/skia" ] } } @@ -158,7 +159,7 @@ source_set("ipc_common_sources") { frameworks = [ "IOSurface.framework" ] } - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//ui/gfx/ipc/skia" ] } diff --git a/ppapi/proxy/BUILD.gn b/ppapi/proxy/BUILD.gn index 342c8af6f70e61..d6e1b0cf863e6b 100644 --- a/ppapi/proxy/BUILD.gn +++ b/ppapi/proxy/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/nacl/config.gni") +import("//components/nacl/toolchain.gni") import("//ppapi/buildflags/buildflags.gni") assert(enable_ppapi) @@ -229,6 +230,7 @@ component("proxy") { deps = [ ":common", "//base", + "//components/nacl/common:buildflags", "//device/base/synchronization", "//device/gamepad/public/cpp:shared_with_blink", "//gpu/command_buffer/client:client", @@ -245,7 +247,7 @@ component("proxy") { "//ui/gfx/ipc/geometry", ] - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//base/third_party/dynamic_annotations", "//gin", @@ -320,7 +322,7 @@ source_set("ipc_sources") { public_deps = [ "//ipc" ] - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//skia" ] } } diff --git a/ppapi/proxy/DEPS b/ppapi/proxy/DEPS index 06e0731a8a3b06..50a0dde3e380a4 100644 --- a/ppapi/proxy/DEPS +++ b/ppapi/proxy/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+base", + "+components/nacl/common/buildflags.h", "+device", "+gin", "+gpu", diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc index 30e64f6c686f69..da8e3a9645d664 100644 --- a/ppapi/proxy/ppb_image_data_proxy.cc +++ b/ppapi/proxy/ppb_image_data_proxy.cc @@ -16,6 +16,7 @@ #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "build/build_config.h" +#include "components/nacl/common/buildflags.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_resource.h" @@ -32,9 +33,9 @@ #include "ppapi/thunk/enter.h" #include "ppapi/thunk/thunk.h" -#if !BUILDFLAG(IS_NACL) -#include "skia/ext/platform_canvas.h" -#include "ui/surface/transport_dib.h" +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) +#include "skia/ext/platform_canvas.h" //nogncheck +#include "ui/surface/transport_dib.h" //nogncheck #endif using ppapi::thunk::PPB_ImageData_API; @@ -371,7 +372,7 @@ void ImageData::RecycleToPlugin(bool zero_contents) { // PlatformImageData ----------------------------------------------------------- -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) PlatformImageData::PlatformImageData( const HostResource& resource, const PP_ImageDataDesc& desc, @@ -411,7 +412,7 @@ void PlatformImageData::Unmap() { SkCanvas* PlatformImageData::GetCanvas() { return mapped_canvas_.get(); } -#endif // !BUILDFLAG(IS_NACL) +#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // SimpleImageData ------------------------------------------------------------- @@ -490,7 +491,7 @@ PP_Resource PPB_ImageData_Proxy::CreateProxyResource( break; } case PPB_ImageData_Shared::PLATFORM: { -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) ppapi::proxy::SerializedHandle image_handle; dispatcher->Send(new PpapiHostMsg_PPBImageData_CreatePlatform( kApiID, instance, format, size, init_to_zero, &result, &desc, @@ -518,7 +519,7 @@ PP_Resource PPB_ImageData_Proxy::CreateProxyResource( bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(PPB_ImageData_Proxy, msg) -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreatePlatform, OnHostMsgCreatePlatform) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBImageData_CreateSimple, @@ -532,7 +533,7 @@ bool PPB_ImageData_Proxy::OnMessageReceived(const IPC::Message& msg) { return handled; } -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // static PP_Resource PPB_ImageData_Proxy::CreateImageData( PP_Instance instance, @@ -640,7 +641,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreateSimple( result_image_handle->set_null_shmem_region(); } } -#endif // !BUILDFLAG(IS_NACL) +#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) void PPB_ImageData_Proxy::OnPluginMsgNotifyUnusedImageData( const HostResource& old_image_data) { diff --git a/ppapi/proxy/ppb_image_data_proxy.h b/ppapi/proxy/ppb_image_data_proxy.h index 2980dce5d79251..3a331c8d4816a1 100644 --- a/ppapi/proxy/ppb_image_data_proxy.h +++ b/ppapi/proxy/ppb_image_data_proxy.h @@ -11,6 +11,7 @@ #include "base/memory/unsafe_shared_memory_region.h" #include "build/build_config.h" +#include "components/nacl/common/buildflags.h" #include "ipc/ipc_platform_file.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" @@ -27,9 +28,9 @@ #include "ppapi/shared_impl/resource.h" #include "ppapi/thunk/ppb_image_data_api.h" -#if !BUILDFLAG(IS_NACL) -#include "third_party/skia/include/core/SkRefCnt.h" -#endif // !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) +#include "third_party/skia/include/core/SkRefCnt.h" //nogncheck +#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) class TransportDIB; @@ -83,7 +84,7 @@ class PPAPI_PROXY_EXPORT ImageData : public ppapi::Resource, // PlatformImageData is a full featured image data resource which can access // the underlying platform-specific canvas and |image_region|. This can't be // used by NaCl apps. -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { public: PlatformImageData(const ppapi::HostResource& resource, @@ -106,7 +107,7 @@ class PPAPI_PROXY_EXPORT PlatformImageData : public ImageData { // Null when the image isn't mapped. std::unique_ptr mapped_canvas_; }; -#endif // !BUILDFLAG(IS_NACL) +#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // SimpleImageData is a simple, platform-independent image data resource which // can be used by NaCl. It can also be used by trusted apps when access to the diff --git a/ppapi/shared_impl/BUILD.gn b/ppapi/shared_impl/BUILD.gn index 2d8fedbd1fb848..2b8ab18bd8c059 100644 --- a/ppapi/shared_impl/BUILD.gn +++ b/ppapi/shared_impl/BUILD.gn @@ -104,13 +104,14 @@ source_set("common") { "//base", "//base:i18n", "//build:chromeos_buildflags", + "//components/nacl/common:buildflags", "//ppapi/c", "//ppapi/thunk:headers", "//third_party/icu:icuuc", "//url", ] - if (!is_nacl) { + if (!is_nacl && !is_minimal_toolchain) { deps += [ "//skia" ] } } @@ -222,6 +223,7 @@ component("shared_impl") { deps = [ "//base/third_party/dynamic_annotations", "//build:chromeos_buildflags", + "//components/nacl/common:buildflags", "//device/gamepad/public/cpp:shared_with_blink", "//gpu/command_buffer/client", "//gpu/command_buffer/client:gles2_cmd_helper", diff --git a/ppapi/shared_impl/DEPS b/ppapi/shared_impl/DEPS index d6ff4c0929768e..fd31ac6917a3bd 100644 --- a/ppapi/shared_impl/DEPS +++ b/ppapi/shared_impl/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+base", + "+components/nacl/common/buildflags.h", "+device/gamepad/public/cpp", "+gpu", "+media/audio", diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc index b59cb8fba9e720..d3e45cc762c42e 100644 --- a/ppapi/shared_impl/ppb_image_data_shared.cc +++ b/ppapi/shared_impl/ppb_image_data_shared.cc @@ -6,9 +6,11 @@ #include "base/notreached.h" #include "build/build_config.h" +#include "components/nacl/common/buildflags.h" -#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) -#include "third_party/skia/include/core/SkTypes.h" +#if !BUILDFLAG(IS_NACL) && !defined(NACL_WIN64) && \ + !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) +#include "third_party/skia/include/core/SkTypes.h" //nogncheck #endif namespace ppapi { @@ -20,7 +22,7 @@ PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() { // later. // TODO(dmichael): Really proxy this. return PP_IMAGEDATAFORMAT_BGRA_PREMUL; -#elif defined(NACL_WIN64) +#elif defined(NACL_WIN64) || BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // In the NaCl Win64 helper, this shouldn't be called. If we start building // Chrome on Windows 64 for realz, we should really implement this. NOTIMPLEMENTED(); diff --git a/ppapi/shared_impl/private/net_address_private_impl.cc b/ppapi/shared_impl/private/net_address_private_impl.cc index 8930e480577d38..06d1817dc12243 100644 --- a/ppapi/shared_impl/private/net_address_private_impl.cc +++ b/ppapi/shared_impl/private/net_address_private_impl.cc @@ -12,6 +12,7 @@ #include "base/check.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" +#include "components/nacl/common/buildflags.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/private/ppb_net_address_private.h" #include "ppapi/shared_impl/proxy_lock.h" @@ -22,7 +23,8 @@ #include #include #include -#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_NACL) +#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_NACL) && \ + !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) #include #include #include @@ -389,7 +391,7 @@ GetPPB_NetAddress_Private_1_1_Thunk() { } // namespace thunk // For the NaCl target, all we need are the API functions and the thunk. -#if !BUILDFLAG(IS_NACL) +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // static bool NetAddressPrivateImpl::ValidateNetAddress( @@ -484,7 +486,7 @@ bool NetAddressPrivateImpl::NetAddressToIPEndPoint( address->Assign(net_addr->address, address_size); return true; } -#endif // !BUILDFLAG(IS_NACL) +#endif // !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) // static std::string NetAddressPrivateImpl::DescribeNetAddress( diff --git a/ppapi/shared_impl/private/net_address_private_impl.h b/ppapi/shared_impl/private/net_address_private_impl.h index 5516b4080353c9..3009be261a605c 100644 --- a/ppapi/shared_impl/private/net_address_private_impl.h +++ b/ppapi/shared_impl/private/net_address_private_impl.h @@ -8,11 +8,16 @@ #include #include -#include "net/base/ip_address.h" +#include "build/build_config.h" +#include "components/nacl/common/buildflags.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb_net_address.h" #include "ppapi/shared_impl/ppapi_shared_export.h" +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) +#include "net/base/ip_address.h" //nogncheck +#endif + struct PP_NetAddress_Private; struct sockaddr; @@ -24,6 +29,7 @@ class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { NetAddressPrivateImpl(const NetAddressPrivateImpl&) = delete; NetAddressPrivateImpl& operator=(const NetAddressPrivateImpl&) = delete; +#if !BUILDFLAG(IS_NACL) && !BUILDFLAG(IS_MINIMAL_TOOLCHAIN) static bool ValidateNetAddress(const PP_NetAddress_Private& addr); static bool SockaddrToNetAddress(const sockaddr* sa, @@ -37,6 +43,7 @@ class PPAPI_SHARED_EXPORT NetAddressPrivateImpl { static bool NetAddressToIPEndPoint(const PP_NetAddress_Private& net_addr, net::IPAddressBytes* address, uint16_t* port); +#endif static std::string DescribeNetAddress(const PP_NetAddress_Private& addr, bool include_port);