Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Aug 27, 2019

Description

Now that we build the engine with bitcode on CI, we should no longer require local engine builds in the tool to enable bitcode.

It is still not turned on by default - a user would have to update their Xcode project to set ENABLE_BITCODE to YES, or explicitly pass --bitcode to flutter build aot.

I've also cleaned up some unnecessary changes around the dsym util - apparently it doesn't make sense to have symbols anyway with bitcode, and it was failing locally without some changes for me.

Unfortunately, this no longer validates that bitcode is present in the binary because the method used doesn't work on FAT binaries. We could still validate them by e.g. running xcrun bitcode_strip on the binary and validating that the output is different from the input, but it seems excessive and would slow down build times.

Related Issues

Fixes #15288 (!)

Filed #39356 to track the remaining work once this has had some time to bake.

Tests

I added the following tests:

Updated existing tests for the new changes/removed code.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

@fluttergithubbot fluttergithubbot added d: examples Sample code and demos c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Aug 27, 2019
@dnfield dnfield added t: xcode "xcodebuild" on iOS and general Xcode project management platform-ios iOS applications specifically labels Aug 27, 2019
'-miphoneos-version-min=8.0',
];

final List<String> bitcodeArgs = <String>['-fembed-bitcode'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-using this list seems likely to cause errors in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to a const string and an expanded single use list below.


import 'dart:async';

import 'package:flutter_tools/src/base/common.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: relative import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ENABLE_BITCODE = NO;
ENABLE_BITCODE = YES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YES should be the default, remove the setting instead of overriding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

if (bitcode) {
final String iPhoneSdk = await xcode.iPhoneSdkLocation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know you need the iPhone SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A warning is generated otherwise. It may be harmless but I'd like to avoid it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this codepath is used for iphonesimulator and macosx too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather, will it be used for macosx in the future since bitcode is only set from xcode_backend. I believe this would need to be iphonesimulator in the Debug simulator case though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be used for simulator because it's AOT and specific to ARM.

It looks like it's already being used for macOS. I'll move this behind some guards similar to what's used for -miphoneos

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only support x64 desktop, but it is probably better to have semantically named selection

// gen_snapshot would provide an argument to do this automatically.
if (platform == TargetPlatform.ios && bitcode) {
final IOSink sink = fs.file('$assembly.bitcode').openWrite();
final IOSink sink = fs.file('$assembly.stripped.S').openWrite();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc will emit a warning if this file doesn't end with .S.

Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link

codecov bot commented Aug 27, 2019

Codecov Report

Merging #39357 into master will decrease coverage by 0.78%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #39357      +/-   ##
==========================================
- Coverage   56.76%   55.97%   -0.79%     
==========================================
  Files         195      195              
  Lines       18430    18413      -17     
==========================================
- Hits        10461    10306     -155     
- Misses       7969     8107     +138
Flag Coverage Δ
#flutter_tool 55.97% <50%> (-0.79%) ⬇️
Impacted Files Coverage Δ
packages/flutter_tools/lib/src/macos/xcode.dart 57.14% <0%> (-3.58%) ⬇️
packages/flutter_tools/lib/src/base/build.dart 68.06% <100%> (+0.03%) ⬆️
...ages/flutter_tools/lib/src/commands/build_aot.dart 37.5% <66.66%> (-1.76%) ⬇️
...s/flutter_tools/lib/src/tester/flutter_tester.dart 13.4% <0%> (-57.74%) ⬇️
packages/flutter_tools/lib/src/bundle.dart 31.81% <0%> (-43.94%) ⬇️
packages/flutter_tools/lib/src/base/net.dart 59.57% <0%> (-25.54%) ⬇️
packages/flutter_tools/lib/src/version.dart 73.68% <0%> (-19.14%) ⬇️
packages/flutter_tools/lib/src/device.dart 55.42% <0%> (-1.81%) ⬇️
packages/flutter_tools/lib/src/cache.dart 43.02% <0%> (-0.73%) ⬇️
packages/flutter_tools/lib/src/base/terminal.dart 70.32% <0%> (-0.64%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f71ce2...f186393. Read the comment docs.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Please ignore patch coverage, it is bad. Someday, I'll figure out how to fix it....

@dnfield dnfield merged commit 202c1b4 into flutter:master Aug 28, 2019
@dnfield dnfield deleted the bitcode_for_all branch August 28, 2019 17:27
jonahwilliams pushed a commit that referenced this pull request Aug 28, 2019
jonahwilliams pushed a commit that referenced this pull request Aug 28, 2019
dnfield added a commit to dnfield/flutter that referenced this pull request Aug 28, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: examples Sample code and demos platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Bitcode support for iOS

5 participants