提问人:Dolphin 提问时间:4/11/2023 最后编辑:Dolphin 更新时间:7/3/2023 访问量:664
screen_capturer_mac.mm:462:11:错误:“CGDisplayStreamUpdateGetRects”仅在 macOS 13.0 或更高版本上可用 [-Werror,-Wunguarded-availability-new]
screen_capturer_mac.mm:462:11: error: 'CGDisplayStreamUpdateGetRects' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
问:
我正在使用 M13.2.1 pro 芯片在 macOS 1 中编译 chrome,当我运行此命令时,显示错误:
➜ src git:(64ca7395b4) autoninja -C out/Default chrome
ninja: Entering directory `out/Default'
[20433/54517] OBJCXX obj/third_party/webrtc/modules/desktop_capture/desktop_capture_objc/screen_capturer_mac.o
FAILED: obj/third_party/webrtc/modules/desktop_capture/desktop_capture_objc/screen_capturer_mac.o
../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/webrtc/modules/desktop_capture/desktop_capture_objc/screen_capturer_mac.o.d -DDCHECK_ALWAYS_ON=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DCR_XCODE_VERSION=1430 -DCR_CLANG_REVISION=\"llvmorg-17-init-4759-g547e3456-2\" -DCOMPONENT_BUILD -DCR_LIBCXX_REVISION=049d48aa99786a2452537a5f5e3c411c741abb82 -D_LIBCPP_ENABLE_ASSERTIONS=1 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DWEBRTC_ENABLE_PROTOBUF=1 -DWEBRTC_STRICT_FIELD_TRIALS=0 -DRTC_ENABLE_VP9 -DRTC_DAV1D_IN_INTERNAL_DECODER_FACTORY -DWEBRTC_HAVE_SCTP -DENABLE_EXTERNAL_AUTH -DHAVE_WEBRTC_VIDEO -DLOGGING_INSIDE_WEBRTC -DWEBRTC_ARCH_ARM64 -DWEBRTC_HAS_NEON -DWEBRTC_LIBRARY_IMPL -DWEBRTC_ENABLE_SYMBOL_EXPORT -DWEBRTC_ENABLE_AVX2 -DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0 -DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_MAC -DABSL_ALLOCATOR_NOTHROW=1 -I../.. -Igen -I../../buildtools/third_party/libc++ -I../../third_party/webrtc_overrides -I../../third_party/webrtc -Igen/third_party/webrtc -I../../third_party/abseil-cpp -I../../third_party/perfetto/include -Igen/third_party/perfetto/build_config -Igen/third_party/perfetto -I../../third_party/libyuv/include -I../../third_party/webrtc/sdk/objc -I../../third_party/webrtc/sdk/objc/base -Wall -Werror -Wextra -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wunguarded-availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wshadow -fno-delete-null-pointer-checks -fno-ident -fno-strict-aliasing -fstack-protector-strong -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -ffp-contract=off -fcomplete-member-pointers -arch arm64 -fno-global-isel -mno-outline -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern -O0 -fno-omit-frame-pointer -g2 -gdwarf-aranges -Xclang -debug-info-kind=limited -isysroot ../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacos-version-min=10.13 -fvisibility=hidden -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang raw-ref-template-as-trivial-member -Xclang -plugin-arg-find-bad-constructs -Xclang check-stack-allocated -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors -Wglobal-constructors -Wno-shadow -Wctad-maybe-unsupported -Wimplicit-retain-self -Wstrict-overflow -Wmissing-field-initializers -Wimplicit-retain-self -Wobjc-missing-property-synthesis -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare -std=c++20 -Wno-trigraphs -fobjc-call-cxx-cdtors -fno-exceptions -fno-rtti -nostdinc++ -isystem../../buildtools/third_party/libc++/trunk/include -isystem../../buildtools/third_party/libc++abi/trunk/include -fvisibility-inlines-hidden -fobjc-arc -c ../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm -o obj/third_party/webrtc/modules/desktop_capture/desktop_capture_objc/screen_capturer_mac.o
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:462:11: error: 'CGDisplayStreamUpdateGetRects' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:106:37: note: 'CGDisplayStreamUpdateGetRects' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN const CGRect * __nullable CGDisplayStreamUpdateGetRects(CGDisplayStreamUpdateRef __nullable updateRef,
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:462:11: note: enclose 'CGDisplayStreamUpdateGetRects' in an @available check to silence this warning
CGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:472:45: error: 'kCGDisplayStreamShowCursor' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
(const void* []){kCGDisplayStreamShowCursor},
^~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:195:30: note: 'kCGDisplayStreamShowCursor' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN const CFStringRef kCGDisplayStreamShowCursor CG_AVAILABLE_BUT_DEPRECATED(13.0, 14.0, "Please use ScreenCaptureKit API's SCStreamConfiguration showsCursor property instead"); /* CFBoolean - defaults to false */
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:472:45: note: enclose 'kCGDisplayStreamShowCursor' in an @available check to silence this warning
(const void* []){kCGDisplayStreamShowCursor},
^~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:478:41: error: 'CGDisplayStreamCreate' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CGDisplayStreamRef display_stream = CGDisplayStreamCreate(
^~~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:243:41: note: 'CGDisplayStreamCreate' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN CGDisplayStreamRef __nullable CGDisplayStreamCreate(CGDirectDisplayID display,
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:478:41: note: enclose 'CGDisplayStreamCreate' in an @available check to silence this warning
CGDisplayStreamRef display_stream = CGDisplayStreamCreate(
^~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:482:23: error: 'CGDisplayStreamStart' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CGError error = CGDisplayStreamStart(display_stream);
^~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:273:19: note: 'CGDisplayStreamStart' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN CGError CGDisplayStreamStart(CGDisplayStreamRef cg_nullable displayStream)
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:482:23: note: enclose 'CGDisplayStreamStart' in an @available check to silence this warning
CGError error = CGDisplayStreamStart(display_stream);
^~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:485:35: error: 'CGDisplayStreamGetRunLoopSource' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(display_stream);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:295:41: note: 'CGDisplayStreamGetRunLoopSource' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN CFRunLoopSourceRef __nullable CGDisplayStreamGetRunLoopSource(CGDisplayStreamRef cg_nullable displayStream)
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:485:35: note: enclose 'CGDisplayStreamGetRunLoopSource' in an @available check to silence this warning
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(display_stream);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:498:33: error: 'CGDisplayStreamGetRunLoopSource' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(stream);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:295:41: note: 'CGDisplayStreamGetRunLoopSource' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN CFRunLoopSourceRef __nullable CGDisplayStreamGetRunLoopSource(CGDisplayStreamRef cg_nullable displayStream)
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:498:33: note: enclose 'CGDisplayStreamGetRunLoopSource' in an @available check to silence this warning
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(stream);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:500:5: error: 'CGDisplayStreamStop' is only available on macOS 13.0 or newer [-Werror,-Wunguarded-availability-new]
CGDisplayStreamStop(stream);
^~~~~~~~~~~~~~~~~~~
../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayStream.h:285:19: note: 'CGDisplayStreamStop' has been marked as being introduced in macOS 13.0 here, but the deployment target is macOS 10.13.0
CG_EXTERN CGError CGDisplayStreamStop(CGDisplayStreamRef cg_nullable displayStream)
^
../../third_party/webrtc/modules/desktop_capture/mac/screen_capturer_mac.mm:500:5: note: enclose 'CGDisplayStreamStop' in an @available check to silence this warning
CGDisplayStreamStop(stream);
^~~~~~~~~~~~~~~~~~~
7 errors generated.
[20444/54517] CXX obj/third_party/webrtc/modules/pacing/pacing/packet_router.o
ninja: build stopped: subcommand failed.
如何解决这个问题?我已经阅读了文档 https://chromium.googlesource.com/chromium/src/+/main/docs/mac_arm64.md 并且已经添加了文件。Xcode 版本是 。这是 args.gn 文件内容:target_cpu = "arm64"
chromium/src/out/Default/args.gn
Version 14.3 (14E222b)
➜ Default git:(64ca7395b4) cat args.gn
# Set build arguments here. See `gn help buildargs`.
target_cpu = "arm64"
答:
我看到发布的编译器命令行包含参数,也就是说,它想要编译一个可以在 MacOS 10.13(又名“High Sierra”)或更高版本下运行的可执行文件。-mmacos-version-min=10.13
此类程序可能无法合法调用仅在 MacOS 13.0(又名“Ventura”)或更高版本中可用的函数,因此会出现错误消息。
我建议您在 build-config 中找到指定的位置,并将其更改为类似的东西;或者,如果你确实需要你的程序可以在High Sierra下运行,那么你需要重写代码,这样它就不会调用10.13 / High Sierra版本操作系统不支持的任何函数。 其他一些代码路径被调用;但我对这种技术不是很熟悉,所以与其尝试描述它,不如只提供一个指向 Apple 文档的链接)-mmacos-version-min=10.13
-mmacos-version-min=13.0
有两种方法: 第一个是添加 gn arg
treat_warnings_as_errors = true
;
第二个是:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
// put your error code here
#pragma clang diagnostic pop
我今天在 macOS 13.4.1 上尝试编译 Chromium 时遇到了同样的错误。我最终对 中的默认 clang 编译器参数进行了小幅修改,从而成功完成了构建。build/config/compiler/BUILD.gn
diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
--- a/build/config/compiler/BUILD.gn
--- b/build/config/compiler/BUILD.gn
@@ -1644,6 +1644,8 @@ config("default_warnings") {
# which we no longer use. Check if it makes sense to remove
# this as well. http://crbug.com/316352
"-Wno-unneeded-internal-declaration",
+
+ "-Wno-unguarded-availability-new",
]
if (!is_nacl || is_nacl_saigo) {
链接到 Chromium 的 GitHub 镜像上的行:https://github.com/chromium/chromium/blob/4378d583b52c891b6429ae704bf5ecb252375997/build/config/compiler/BUILD.gn#L1742C6-L1742C6
通常,修复可用性警告是值得的,但对于我的用例,我为自己构建了 Chromium,而不打算在早期版本的 macOS 上将其分发给其他人。
评论