Skip to content

Don't use iOS toolchain on macOS #12578

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

Closed
wants to merge 1 commit into from

Conversation

swolchok
Copy link
Contributor

I don't know why we were doing this, but it seems wrong. Let's see if tests pass.

[ghstack-poisoned]
@swolchok swolchok requested a review from larryliu0820 as a code owner July 17, 2025 00:50
@swolchok swolchok requested a review from kirklandsign as a code owner July 17, 2025 00:50
Copy link

pytorch-bot bot commented Jul 17, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/12578

Note: Links to docs will display an error until the docs builds have been completed.

❌ 11 New Failures, 3 Unrelated Failures

As of commit 4ac87e3 with merge base 986be2a (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 17, 2025
swolchok added a commit that referenced this pull request Jul 17, 2025
I don't know why we were doing this, but it seems wrong. Let's see if tests pass.


ghstack-source-id: 26d2882
ghstack-comment-id: 3081988867
Pull-Request: #12578
@swolchok swolchok requested a review from jathu July 17, 2025 00:51
@swolchok swolchok added the release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc. label Jul 17, 2025
@swolchok
Copy link
Contributor Author

swolchok commented Jul 17, 2025

might want to pick this to release, not sure. comes from #10768

@swolchok swolchok mentioned this pull request Jul 17, 2025
@jathu
Copy link
Contributor

jathu commented Jul 17, 2025

I think ios.toolchain.cmake is probably poor naming, but it is a general Apple cmake toolchain to build for all of their platforms (controlled via PLATFORMS): https://github.com/leetal/ios-cmake

@swolchok
Copy link
Contributor Author

I think ios.toolchain.cmake is probably poor naming, but it is a general Apple cmake toolchain to build for all of their platforms (controlled via PLATFORMS): https://github.com/leetal/ios-cmake

using this toolchain breaks sentencepiece's build in the next PR. Why aren't CMake's default settings on macOS sufficient?

@jathu
Copy link
Contributor

jathu commented Jul 17, 2025

@shoumikhin do you have context on why we use the toolchain instead of relying the on the default host configs?

@@ -12,7 +12,6 @@
"inherits": ["common"],
"generator": "Xcode",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
Copy link
Contributor

@shoumikhin shoumikhin Jul 17, 2025

Choose a reason for hiding this comment

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

iirc, this is not iOS-only toolchain, we use it to build mac targets too.
It contains a bunch of useful declarations to simplify our live, e.g. the very MAC_ARM64 platform definition.

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 is not the normal way that CMake projects expect to build for Mac though. concretely, sentencepiece's build does not like CMAKE_MACOSX_BUNDLE being set on non-iOS platforms, and it wouldn't be set on macOS if not for the use of this toolchain. IMO we should keep everything standard and defaulted unless we have a reason not to. Why do we need to use this to build for Mac?

Copy link
Contributor

Choose a reason for hiding this comment

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

So we rely on that toolchain platform definitions with the extra cmake flags they add to build frameworks for iOS and macOS. So far they worked well. If you believe there's a better approach, let's explore it too.
I guess we can disabled CMAKE_MACOSX_BUNDLE for sentencepiece specifically when building for mac, that's what we do with the custom script build phase in Xcode when building extension/llm third-party deps.
Screenshot 2025-07-16 at 18 40 40

Copy link
Contributor Author

@swolchok swolchok Jul 17, 2025

Choose a reason for hiding this comment

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

I guess we can disabled CMAKE_MACOSX_BUNDLE for sentencepiece specifically when building for mac, that's what we do with the custom script build phase in Xcode when building extension/llm third-party deps.

I agree that we can work around this and it's straightforward to do so. My concern is that the setting of this toolchain cost me half an hour of debugging time to track down, because it was surprising that 1) any toolchain was active for macos, since builds work fine without it when not using presets, and 2) "ios.toolchain.cmake" in particular was active. This will presumably continue to be surprising to others in the future.

What if instead we set the CMAKE_TOOLCHAIN_FILE only in build_apple_frameworks.sh? Do we need it anywhere else? (Long-term I think we should investigate using CMake's built-in support for producing Apple frameworks, but I don't see a particular reason to prioritize that.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t have a strong preference - so long as we can build the frameworks as usual, I’m happy either way.
Just a few quick notes:

  • Despite its name, this toolchain isn’t limited to iOS.
  • The last time I tried building the frameworks by manually setting all the macOS-specific flags myself - it ended up costing way more time 😅
  • Otherwise, this toolchain has worked well so far.

Maybe just disable that particular flag like in #12594

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, maybe #12594 will unblock me. If not I'll see if I can find another way to unblock export since I've found out that this is here for a reason and not just a mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I rebased and it looks like we don't need this.

@swolchok
Copy link
Contributor Author

build-frameworks-ios error:

2025-07-17T01:17:59.6638640Z Merging libraries:
2025-07-17T01:17:59.6638760Z libexecutorch.a
2025-07-17T01:17:59.6638860Z libexecutorch_core.a
2025-07-17T01:17:59.6638970Z libextension_apple.a
2025-07-17T01:17:59.6639080Z libextension_data_loader.a
2025-07-17T01:17:59.6639210Z libextension_flat_tensor.a
2025-07-17T01:17:59.6639330Z libextension_module.a
2025-07-17T01:17:59.6639440Z libextension_tensor.a
2025-07-17T01:17:59.6639560Z from simulator/Release
2025-07-17T01:17:59.6639880Z into library /Users/runner/work/executorch/executorch/pytorch/executorch/cmake-out/libexecutorch_simulator.a
2025-07-17T01:17:59.6640280Z File simulator/Release/libextension_apple.a does not exist

so I guess this script might need CMAKE_TOOLCHAIN_FILE put back?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/binaries ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: build Changes related to build, including dependency upgrades, build flags, optimizations, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants