gnguralnick opened a new pull request, #18884: URL: https://github.com/apache/tvm/pull/18884
## Summary Fix false rejection of `apple-m1`, `apple-m2`, and `apple-m3` as LLVM CPU names when building TVM with LLVM 22+. ## Behavior After following the [installation from source instructions](https://tvm.apache.org/docs/install/from_source.html) and building against LLVM 22, every `import tvm` produces spurious error messages: ``` Error: Using LLVM 22.1.0 with `-mcpu=apple-m1` is not valid in `-mtriple=arm64-apple-macos`, using default `-mcpu=generic` Error: Using LLVM 22.1.0 with `-mcpu=apple-m2` is not valid in `-mtriple=arm64-apple-macos`, using default `-mcpu=generic` ``` These are triggered by the Metal target tag registrations in `python/tvm/target/tag_registry/metal.py`, which use `apple-m1` and `apple-m2` as the host `-mcpu`. The CPUs are silently downgraded to `generic`. ## Root cause LLVM 22 reorganized its AArch64 processor table. `apple-m1` through `apple-m3` are now CPU **aliases** — fully valid and accepted by `createTargetMachine` and `isCPUStringValid()`, but no longer returned by `MCSubtargetInfo::getAllProcessorDescriptions()`. TVM's `LLVMTargetInfo` constructor validates `-mcpu` by enumerating `getAllProcessorDescriptions()` and checking membership, so it misses alias-only names. ## Fix Replace the enumeration-based check with a new `IsValidCPU()` method that uses `MCSubtargetInfo::isCPUStringValid()`, which correctly handles both primary names and aliases. This API has been available since at least LLVM 7, well before TVM's minimum supported version. ## Validation - Built and tested on macOS (Apple Silicon) with LLVM 22.1.0 - `python -c "import tvm; print(tvm.__file__)"` produces clean output with no error messages -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
