[macOS] Link __availability_version_check (flutter/engine#45333)

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.                                                                         
                                                                                   
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 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Chris Bracken
2023-08-31 11:41:00 -07:00
committed by GitHub
parent e2b30eb181
commit 9bf9453e26
2 changed files with 27 additions and 1 deletions

View File

@@ -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" ]

View File

@@ -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",