Open
Bug 1480171
Opened 7 years ago
Updated 3 years ago
Update Mac build config to use -Wunguarded-availability
Categories
(Core :: Widget: Cocoa, defect, P2)
Tracking
()
NEW
People
(Reporter: haik, Unassigned)
References
Details
clang Objective-C now includes support for an @available keyword[1] to be used with the -Wunguarded-availability LLVM flag to better handle use of newer API's not available on older OS versions. See also this discussion[2] on the chromium-dev alias. This sounds like something we could adopt in our codebase to improve dealing with older SDKs.
From the clang docs:
Before LLVM 5.0, when calling a function that exists only in the OS that’s newer than the target OS (as determined by the minimum deployment version), programmers had to carefully check if the function exists at runtime, using null checks for weakly-linked C functions, +class for Objective-C classes, and -respondsToSelector: or +instancesRespondToSelector: for Objective-C methods. If such a check was missed, the program would compile fine, run fine on newer systems, but crash on older systems.
As of LLVM 5.0, -Wunguarded-availability uses the availability attributes together with the new @available() keyword to assist with this issue. When a method that’s introduced in the OS newer than the target OS is called, a -Wunguarded-availability warning is emitted if that call is not guarded
1. https://clang.llvm.org/docs/LanguageExtensions.html#objective-c-available
2. https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/iZsW1jAsc2A
| Reporter | ||
Updated•7 years ago
|
See Also: → mojave-sdk
Updated•7 years ago
|
Priority: -- → P2
Comment 1•7 years ago
|
||
Haik, I can no longer build Firefox after upgrading to macOS 10.14 because I hit -Wunguarded-availability-new warnings-as-errors.
Is this bug about fixing -Wunguarded-availability-new warnings like this? Or should I file a new bug specifically about these -Wunguarded-availability-new warnings-as-errors? The warnings are in code added in authorizationStatusForMediaType bug 1487204.
widget/cocoa/nsCocoaUtils.mm:1229:24: error: 'authorizationStatusForMediaType:' is only available on macOS 10.14 or newer [-Werror,-Wunguarded-availability-new]
[AVCaptureDevice authorizationStatusForMediaType:aMediaType]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:1479:1: note: 'authorizationStatusForMediaType:' has been explicitly marked partial here
+ (AVAuthorizationStatus)authorizationStatusForMediaType:(AVMediaType)mediaType API_AVAILABLE(macos(10.14), ios(7.0));
^
widget/cocoa/nsCocoaUtils.mm:1229:24: note: enclose 'authorizationStatusForMediaType:' in an @available check to silence this warning
[AVCaptureDevice authorizationStatusForMediaType:aMediaType]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
widget/cocoa/nsCocoaUtils.mm:1304:19: error: 'AVAuthorizationStatusNotDetermined' is only available on macOS 10.14 or newer [-Werror,-Wunguarded-availability-new]
(int)AVAuthorizationStatusNotDetermined);
| Reporter | ||
Comment 2•7 years ago
|
||
(In reply to Chris Peterson [:cpeterson] from comment #1)
> Haik, I can no longer build Firefox after upgrading to macOS 10.14 because I
> hit -Wunguarded-availability-new warnings-as-errors.
>
> Is this bug about fixing -Wunguarded-availability-new warnings like this? Or
> should I file a new bug specifically about these
> -Wunguarded-availability-new warnings-as-errors? The warnings are in code
> added in authorizationStatusForMediaType bug 1487204.
I think you should file a new bug for the compilation issues and make it blocking for Mojave bug 1466336.
To clarify, my intent with this bug wasn't specific to Mojave. It was to explore building with -Wunguarded-availability-new and shifting to using @available instead of the respondsToSelector methods. Then, if a developer adds a call to an API that is available in their local (newer) SDK, but not one of the other earlier OS version SDKs that the build is set to target, a build error occurs.
Flags: needinfo?(haftandilian)
Comment 3•7 years ago
|
||
(In reply to Haik Aftandilian [:haik] from comment #2)
> I think you should file a new bug for the compilation issues and make it
> blocking for Mojave bug 1466336.
Thanks. I filed bug 1494851.
See Also: 1492210 →
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•