Skip to content

build: fix installation failures of dependencies for macOS#4504

Open
felixtensor wants to merge 2 commits intollvm:mainfrom
felixtensor:fix/macos-dep
Open

build: fix installation failures of dependencies for macOS#4504
felixtensor wants to merge 2 commits intollvm:mainfrom
felixtensor:fix/macos-dep

Conversation

@felixtensor
Copy link
Copy Markdown

@felixtensor felixtensor commented Mar 17, 2026

Add platform-specific dependency declarations for torch and torchvision to fix installation failures of dependencies on macOS. This aligns with PyTorch's upstream wheel naming convention, where macOS builds are published to PyPI without a local version specifier, while Linux and Windows CPU builds carry the +cpu suffix (e.g., 2.x.x+cpu) in PyTorch's dedicated WHL index. Use versions with the +cpu suffix on Linux and Windows, and versions without this suffix on macOS, to accommodate the pre-built package naming conventions across different platforms.

Add platform-specific dependency declarations for torch and torchvision. This
aligns with PyTorch's upstream wheel naming convention, where macOS builds are
published to PyPI without a local version specifier, while Linux and Windows CPU
builds carry the +cpu suffix (e.g., 2.x.x+cpu) in PyTorch's dedicated WHL index.
Use versions with the +cpu suffix on Linux and Windows, and versions without
this suffix on macOS, to accommodate the pre-built package naming conventions
across different platforms.

- [Ref](pytorch/pytorch#110004)
The LTC backend was built with Linux-only linker flags on all platforms,
so it never actually worked on macOS. Fix this by using platform-specific
properties in CMakeLists:

- On macOS: drop the hardcoded SUFFIX ".so" and swap -rdynamic for
  -undefined dynamic_lookup, so PyTorch symbols (FLAGS_torch_lazy_* etc.)
  are resolved at load time through the host Python process.
- Use @loader_path instead of $ORIGIN in reference_lazy_backend rpath,
  since $ORIGIN is Linux-only.

Also expand the autogen LTC op blacklist with a handful of ops that broke
codegen against recent PyTorch: rrelu_with_noise and _assert_tensor_metadata
changed return types, and a few scalar/metadata-only ops were never
meaningful to lower through LTC anyway.

While at it, bring the macOS packaging scripts up to date:
- Python 3.9 dropped, add 3.12.
- build_macos_packages.sh now picks up Python from the active environment
  (conda, pyenv, brew) rather than hard-requiring a python.org Framework
  install. Falls back to /Library/Frameworks for CI. CMAKE_OSX_ARCHITECTURES
  now defaults to the host arch instead of a fat binary.
- install_macos_deps.sh: switch PYTHON_SPECS to a version-keyed map,
  fix a zsh word-splitting bug that silently broke multi-version installs,
  clean up .pkg files after install.
- Remove build_upload_m1_snapshot.sh, which has been dead since GH Actions
  gained arm64 runners.
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.

1 participant