From 11739f5e36e501f1e88885524bb5b9bf443c7815 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 31 Aug 2023 10:11:32 -0700 Subject: [PATCH] [macOS] Link __availaibility_version_check Links in an implementation of _availability_version_check on macOS. This is required due to an upstream compiler builtin (runtime) change that marked this function as weakly-linked via `__attribute__((weak import))` As such, no linking failure occurs when the function is unavailable at link time. Since the symbol is no longer linked in, App Store review blocks publishing due to relying on a private symbol. By providing an implementation, the linker picks up our implementation, which looks up symbol in question at runtime (via dlsym) on the first invocation, caches it for later invocations, then invokes it. This is, in fact, precisely what the original clang builtin implementation did. Upstream clang change: https://reviews.llvm.org/D150397 Issue: https://github.com/flutter/flutter/issues/133777 --- shell/platform/darwin/common/BUILD.gn | 27 ++++++++++++++++++++++++++- shell/platform/darwin/macos/BUILD.gn | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/common/BUILD.gn b/shell/platform/darwin/common/BUILD.gn index 7d844b75b81de..0d29be6c703eb 100644 --- a/shell/platform/darwin/common/BUILD.gn +++ b/shell/platform/darwin/common/BUILD.gn @@ -13,13 +13,38 @@ source_set("common") { cflags_objcc = flutter_cflags_objcc sources = [ - "availability_version_check.cc", "buffer_conversions.h", "buffer_conversions.mm", "command_line.h", "command_line.mm", ] + deps = [ + ":availability_version_check", + "//flutter/fml", + ] + + public_configs = [ "//flutter:config" ] +} + +# Provides an implementation for _availability_version_check. +# +# This is required due to an upstream compiler builtin (runtime) change +# that marked this function as weakly-linked via __attribute__((weak import)) +# As such, no linking failure occurs when the function is unavailable at +# link time. Since the symbol is no longer linked in, App Store review blocks +# publishing due to relying on a private symbol. Instead we link in our own +# implementation, which provides the exact implementation used in clang prior +# to the upstream change. +# +# See: Upstream clang change: https://reviews.llvm.org/D150397 +# See: https://github.com/flutter/flutter/issues/133777 +source_set("availability_version_check") { + cflags_objc = flutter_cflags_objc + cflags_objcc = flutter_cflags_objcc + + sources = [ "availability_version_check.cc" ] + deps = [ "//flutter/fml" ] public_configs = [ "//flutter:config" ] diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 4bef2c68b1942..d36e9b1486099 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -121,6 +121,7 @@ source_set("flutter_framework_source") { "//flutter/shell/platform/common:common_cpp_enums", "//flutter/shell/platform/common:common_cpp_input", "//flutter/shell/platform/common:common_cpp_switches", + "//flutter/shell/platform/darwin/common:availability_version_check", "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/darwin/graphics:graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library",