Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default apple_platform_type to macOS #6366

Closed
wants to merge 3 commits into from

Conversation

keith
Copy link
Member

@keith keith commented Oct 11, 2018

When using rules for Apple platforms that aren't platform specific, such
as swift_binary, the default of iOS doesn't make sense, instead we
should default this to the current platform, which currently can only be
macOS.

More details about this issue can be found here bazelbuild/rules_swift#51

@allevato
Copy link
Member

This change would have very broad ranging implications within Google. I believe there is a significant amount of cleanup that would need to be done before we could flip this switch, which is why we haven't done it yet.

@keith
Copy link
Member Author

keith commented Oct 11, 2018

What other rules are affected by this?

@allevato
Copy link
Member

All the objc_* rules would be affected by this.

The reason for the iOS default is entirely historical (the first users of Apple support in Bazel were building iOS apps, and today it's still the case that that's the majority of our users), so it "made sense" at the time (in fact, iOS was the only supported target for a while).

It's not so much the rules themselves that matter here, but all the implicit assumptions elsewhere that assume that a flagless build will target iOS that would break.

@irengrig irengrig added the WIP label Oct 12, 2018
@lberki lberki requested review from sergiocampama and removed request for lberki October 12, 2018 12:45
@lberki lberki assigned sergiocampama and unassigned lberki Oct 12, 2018
@lberki
Copy link
Contributor

lberki commented Oct 12, 2018

I only touched AppleCommandLineOptions only due to my interest in C++ rules and because I did a cleanup out of general desire for cleanliness.

I think it would be worthwhile to eventually unify the configuration distinguisher and the platform type, but that would require adding the "unspecified Apple" platform type. But since I don't actually know much about Apple rules, much less about how this change would affect Google-internal use cases, I'll defer to Sergio.

@keith
Copy link
Member Author

keith commented Oct 12, 2018

Does this mean google internally is using this undocumented flag as well? It seems like we should either add a way for rules to specify this, or publicize this flag

@ulfjack
Copy link
Contributor

ulfjack commented Oct 15, 2018

Yes, the flag is definitely used. It seems to be set on an ios config (in a bazelrc); if everyone is using that, changing the default would be safe.

@sergiocampama
Copy link
Contributor

While it is set in the bazelrc for some ios and macos configs, most teams do not use flags when building objc_library targets, which the majority of them are for iOS internally. We would need to set it by default in the bazelrc, without any config setting.

@keith
Copy link
Member Author

keith commented Oct 15, 2018

I assume there would be a problem there too where if you had a target that you built for macOS for tools, it would need to have that overridden (but maybe that's already happening so it would be ok)

@keith
Copy link
Member Author

keith commented Nov 20, 2018

Any thoughts on how we can get to the point where you can build some targets like swift_binary without having to specify this flag? Maybe an alternative is to allow setting the platform type (or just defaulting it) on those rules?

@jin jin added the z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple label Dec 10, 2018
@sergiocampama
Copy link
Contributor

One thing that the bazel team could do is to copybara this change so that bazel by default is MACOS, while internally it's still IOS. Another thing would be to make it MACOS by default and add IOS as the default in bazelrc files.

@keith
Copy link
Member Author

keith commented Jan 4, 2019

@aragos do you have any thoughts on the possible solutions here?

@keith keith force-pushed the ks/default-platform-type branch from ef76e0c to 34029f4 Compare January 4, 2019 19:39
@keith
Copy link
Member Author

keith commented Jan 4, 2019

I've updated the tests that were relying on the iOS default to pass --apple_platform_type explicitly.

@@ -41,12 +41,12 @@ public void testToolchainSelectionDefault() throws Exception {

assertThat(cppConfig.getRuleProvidingCcToolchainProvider().toString())
.isEqualTo("//tools/osx/crosstool:crosstool");
assertThat(cppConfig.getTransformedCpuFromOptions()).isEqualTo("ios_x86_64");
assertThat(cppConfig.getTransformedCpuFromOptions()).isEqualTo("darwin_x86_64");
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only test I intentionally changed the behavior of, I believe that we want to now test the default is macOS (and therefore is this default arch)

@aragos
Copy link
Contributor

aragos commented Jan 7, 2019

Looks good to me in principle, I can take care of explicitly setting the Google-internal default so that this change doesn't cause any behavioral differences there.

We should also test (and fix) any other downstream projects that may be affected, this can be done following this guide: https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md. EDIT: I think this can only be done with owner privileges so I'll take care of this step as well once the tests (see below) are fixed.

Finally there still appear to be some failing tests in Bazel's buildkite, please fix those as well.

Once the two buildkite verifications are done I'll import the PR.

@keith
Copy link
Member Author

keith commented Jan 7, 2019

Sounds good. Quick question @aragos should I follow those word for word and create a new branch with this same change, or can we trigger that build on this branch when we're ready?

@aragos
Copy link
Contributor

aragos commented Jan 7, 2019

@keith I believe we'll need a fresh branch with this same change. Feel free to create it and run the downstream projects if you have the necessary permissions, otherwise let me know and I can help.

@keith
Copy link
Member Author

keith commented Jan 7, 2019

Sounds good. I've emailed bazel_dev asking for the right permissions. If I don't get them by the time I'm ready I'll ask, thanks!

keith added 2 commits January 7, 2019 13:33
When using rules for Apple platforms that aren't platform specific, such
as `swift_binary`, the default of iOS doesn't make sense, instead we
should default this to the current platform, which currently can only be
macOS.
@keith keith force-pushed the ks/default-platform-type branch from 34029f4 to f2fd7c9 Compare January 7, 2019 21:45
@keith
Copy link
Member Author

keith commented Jan 7, 2019

Oh actually, the recommendation is to create that branch on the bazel repo itself, not my fork, which isn't something I can do without having push access to this repo. I've pushed a branch with the naming suggested in that doc to my fork master...keith:keith-test-feature-platform-default @aragos is this something you can mirror to the bazel repo so we can run the tests (we might want to wait until all other tests are green here first though)

@keith keith force-pushed the ks/default-platform-type branch from f2fd7c9 to 7a24b2d Compare January 7, 2019 23:13
@keith
Copy link
Member Author

keith commented Jan 8, 2019

Ok, it passed, so @aragos I guess we're good to start the others

@aragos
Copy link
Contributor

aragos commented Jan 8, 2019

Great! I imported and pushed your changes to https://github.com/bazelbuild/bazel/tree/aragos-test-macos-default-platform and started a buildkite run with that at https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/735. This may take a while, let's see how it goes.

@keith
Copy link
Member Author

keith commented Jan 8, 2019 via email

@aragos
Copy link
Contributor

aragos commented Jan 8, 2019

Downstream tests have passed. I'm currently working on preserving the old default internally then I'll merge the PR.

@bazel-io bazel-io closed this in f70d266 Jan 9, 2019
@keith
Copy link
Member Author

keith commented Jan 9, 2019

🎉 thanks a ton everyone!

@keith keith deleted the ks/default-platform-type branch January 9, 2019 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes z-team-Apple Deprecated. Send to rules_apple, or label team-Rules-CPP + platform:apple
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants