New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 742498 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 3
Type: Task

Blocked on:
issue 747726



Sign in to add a comment

Consider enabling -Wunguarded-availability on iOS?

Project Member Reported by thakis@chromium.org, Jul 13 2017

Issue description

Clang has a new feature where it can warn if a function is called that's only available in new OS versions, not all the way back to the deployment target.

https://reviews.llvm.org/D35379 has some in-progress documentation, and these slides from WWDC describe it: https://devstreaming-cdn.apple.com/videos/wwdc/2017/411a7o9phe4uekm/411/411_whats_new_in_llvm.pdf

By default, only ``-Wunguarded-availability-new`` is active, which only emits this warning for APIs
that have been introduced in macOS >= 10.13, iOS >= 11, watchOS >= 4 and
tvOS >= 11.

On Mac, we opt in to the warning for all APIs. Do we want to do the same on iOS?
 
I'd like to have this on iOS as well.

When did we enable the warning for Mac?  Did it find any unguarded calls?

It sounds like this flag is supported in Chromium's clang and Xcode9's clang.  We may need to be careful to keep it disabled when using Xcode8's clang (on current official builders).

Comment 2 by thakis@chromium.org, Jul 13 2017

We've had an older version of this flag that worked fairly differently enabled on mac since a little over 2 years ago (I added it to clang back then: http://llvm.org/viewvc/llvm-project?rev=232750&view=rev)

We felt that having something like that was a blocker for using a newer SDK than deployment target. So we never really were in a place where it could've found bugs, since we were bug-free in this area by construction.
I noticed this on beta3.  Interestingly, linking with @available(iOS 11.0, *) didn't initially work. sdefresne@ Looks like we need to add something along the lines of usr/lib/clang/9.0.0/lib/darwin/libclang_rt.ios.a to our linker list?

Comment 4 by thakis@chromium.org, Jul 17 2017

Re 3: Maybe you tried before https://chromium-review.googlesource.com/c/563157/ was landed? The driver should add that automatically from what I understand.

Comment 6 by pkl@chromium.org, Jul 17 2017

Owner: justincohen@chromium.org
Status: Assigned (was: Untriaged)
Components: Build
Labels: -Type-Bug Type-Task
Issue 744293 has been merged into this issue.
thakis@ from the dup-ped bug, a question about performance:
--
eugenbut@ Do we know if @available is good for performance and will not regress this?: 
https://codereview.chromium.org/2935973002/
--
Any thoughts?
thakis@ I still see:
Undefined symbols for architecture x86_64:
  "___isOSVersionAtLeast", referenced from:

clang version 5.0.0 (trunk 307486)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
Cc: jif@chromium.org
As expected, @availability doesn't work on Xcode8.  When we switch to Xcode9 (~M62 timeframe) we should be able to make this switch for first party code.  

jif@ for now code using @availability will need to be wrapped in iOS11 #define's.
Cc: p...@chromium.org
I have to look further, but it appears https://chromium-review.googlesource.com/c/563157 isn't adding the iOS files, maybe?
Project Member

Comment 14 by bugdroid1@chromium.org, Jul 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fa1dbd91a322d6d4ec345d6ac0973c99360326ac

commit fa1dbd91a322d6d4ec345d6ac0973c99360326ac
Author: Justin Cohen <justincohen@google.com>
Date: Thu Jul 20 16:05:15 2017

Always build arm in clang bootstrap.

bootstrap is used to build libclang_rt, and without this change
libclang_rt.ios.a will not be built.

Bug:  742498 
Change-Id: I8e964fc56aaa7dcec26cde5a0884a8a899e8342f
Reviewed-on: https://chromium-review.googlesource.com/575586
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Hans Wennborg <hans@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488258}
[modify] https://crrev.com/fa1dbd91a322d6d4ec345d6ac0973c99360326ac/tools/clang/scripts/update.py

Blockedon: 747726
Project Member

Comment 16 by bugdroid1@chromium.org, Jul 24 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/be5e4a49be6750de585fde529e80afe46aa9fdd7

commit be5e4a49be6750de585fde529e80afe46aa9fdd7
Author: Justin Cohen <justincohen@google.com>
Date: Mon Jul 24 13:11:40 2017

Also build arm64 in clang bootstrap.

Ensure libclang_rt.ios.a includes arm64.

Bug:  742498 ,  747726 
Change-Id: Id0dd67c5ad3ebc09cbf597a6ef494295d479df88
Reviewed-on: https://chromium-review.googlesource.com/582548
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488957}
[modify] https://crrev.com/be5e4a49be6750de585fde529e80afe46aa9fdd7/tools/clang/scripts/update.py

Project Member

Comment 17 by bugdroid1@chromium.org, Oct 3 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/63b940cc4386b67c50a84532e58f84a37d3cd4ab

commit 63b940cc4386b67c50a84532e58f84a37d3cd4ab
Author: Justin Cohen <justincohen@google.com>
Date: Tue Oct 03 19:45:04 2017

Enable -Wunguarded-availability on iOS.

Bug:  742498 
Change-Id: I04af798aa0f69956167597e637f30c08a5a0b2e9
Reviewed-on: https://chromium-review.googlesource.com/646447
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Rohit Rao (ping after 24h) <rohitrao@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Olivier Robin <olivierrobin@chromium.org>
Reviewed-by: Eugene But <eugenebut@chromium.org>
Reviewed-by: Elodie Banel <lod@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506145}
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/base/time/time_mac.cc
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/build/config/compiler/BUILD.gn
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/app/application_delegate/user_activity_handler.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/app/spotlight/spotlight_util.h
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/open_url_util.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/passwords/password_generation_prompt_view.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/payments/ios_payment_instrument_launcher.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/physical_web/physical_web_initial_state_recorder.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/browser/ui/uikit_ui_util.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/common/physical_web/physical_web_scanner.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/content_widget_extension/content_widget_view_controller.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/content_widget_extension/most_visited_tile_view.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/search_widget_extension/copied_url_view.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/chrome/search_widget_extension/search_widget_view_controller.mm
[modify] https://crrev.com/63b940cc4386b67c50a84532e58f84a37d3cd4ab/ios/web/web_state/ui/crw_web_controller.mm

Status: Fixed (was: Assigned)

Sign in to add a comment