Skip to content

[Build] Use brew clang compiler on mac#8704

Merged
bobcao3 merged 3 commits into
taichi-dev:masterfrom
hughperkins:hp/use-brew-clang
May 5, 2025
Merged

[Build] Use brew clang compiler on mac#8704
bobcao3 merged 3 commits into
taichi-dev:masterfrom
hughperkins:hp/use-brew-clang

Conversation

@hughperkins
Copy link
Copy Markdown
Contributor

@hughperkins hughperkins commented Apr 30, 2025

Issue: #

Brief Summary

Use brew clang compiler on mac

copilot:summary

Walkthrough

When building on latest Macs, e.g. Sequoia, the system clang is 16.0.0, or 17.0.0, depending on whether using XCode (16.0.0), or command line tools (17.0.0). Either way, the bytecode generated at python/taichi/_lib/runtime/runtime_arm64.bc is not loadable by llvm 15. Trying to load the clang-15/16 compiled runtime_arm64.bc with llvm 15 gives an error about unknown attribute (86). llvm 15 is the version of llvm used by taichi currently. therefore, building using system clang on macos sequoia prevents taichi from loading/running.

Example failure:

https://github.com/taichi-dev/taichi/actions/runs/14742813933/job/41384420135?pr=8688

Screenshot 2025-04-30 at 7 28 39 AM

To fix this, we use the clang from the brew installed llvm@15 instead. This then runs ok.

We assume in compile.py that brew has already been used earlier in the script to install llvm@15. We use brew config to locate brew, and then assume the clang path as {HOMEBREW_PREFIX}/opt/llvm@15/bin/clang, and similarly for clang++.

copilot:walkthrough

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 30, 2025

CLA assistant check
All committers have signed the CLA.

@hughperkins
Copy link
Copy Markdown
Contributor Author

In the M1 build logs, we can see this is correctly using the brew llvm15 clang 🙌 :

Screenshot 2025-04-30 at 7 22 42 AM

@hughperkins
Copy link
Copy Markdown
Contributor Author

hughperkins commented May 1, 2025

@feisuzhu thoughts on this? Anything you'd like me to check / test / modify / add / etc first, before we merge this? I think this is a first important step to being able to support building on Mac OS X Sequoia, 15.4.1., the latest/current version.

Copy link
Copy Markdown
Collaborator

@bobcao3 bobcao3 left a comment

Choose a reason for hiding this comment

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

This looks correct, so... let's just merge! Thanks

@bobcao3 bobcao3 merged commit 3b9bdd8 into taichi-dev:master May 5, 2025
16 checks passed
@hughperkins
Copy link
Copy Markdown
Contributor Author

Awesome, thank you 🙌

@hughperkins hughperkins deleted the hp/use-brew-clang branch May 5, 2025 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants