Describe the issue:
Related issues
Environment
|
|
| OS |
macOS 27.0 Developer Beta (arm64) |
| Chip |
Apple M3 Pro (11 cores: 5P + 6E), 36GB RAM |
| Python |
3.12.13 (via mise) |
| PyMC |
6.0.1 |
| PyTensor |
3.0.7 |
| NumPy |
2.4.6 |
| Clang |
/usr/bin/clang++ (clang-2100.3.23.3) |
Root cause (as understood)
-ld64 in pytensor/link/c/cmodule.py is meant to select the classic macOS
linker (ld64) over Apple's new linker (ld/lld). On macOS 27 Beta, Clang
parses this as -l d64 (link against library d64) rather than as a linker
selection flag, because the flag syntax changed in the Xcode toolchain bundled
with this beta OS version.
Workaround (confirmed working)
Setting pytensor.config.cxx = "" before importing PyMC forces PyTensor to
use its Python-mode backend (no C compilation), bypassing the Clang flag entirely.
import pytensor
pytensor.config.cxx = "" # must be set before `import pymc`
import pymc as pm
# ... rest of code works normally
Performance impact on Apple Silicon (M3 Pro, Python-mode vs C-compiled):
- Observed: ~920 draws/s in Python mode
- This was sufficient for practical use (1600 draws in ~2 seconds)
- Python mode may be significantly slower on less capable hardware
Alternatively, via environment variable before running the script:
export PYTENSOR_FLAGS="cxx="
python your_script.py
Reproducable code example:
python
import pymc as pm
import numpy as np
with pm.Model():
mu = pm.Normal("mu", mu=0, sigma=1)
pm.sample(100, tune=100, chains=2)
Error message:
pytensor.link.c.exceptions.CompileError: Compilation failed (return status=1):
clang++ -dynamiclib -g -Wno-c++11-narrowing -fno-exceptions -fno-unwind-tables
-fno-asynchronous-unwind-tables -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION
-fPIC -undefined dynamic_lookup -ld64
-I/.../numpy/_core/include
-I/.../python3.12/include/python3.12
-I/.../pytensor/link/c/c_code
-L/.../python3.12/lib
-fvisibility=hidden
-o ...lazylinker_ext.so ...mod.cpp
ld: library 'd64' not found
clang++: error: linker command failed with exit code 1
PyTensor version information:
Name: pytensor
Version: 3.0.7
Apple clang version 21.0.0 (clang-2100.3.23.3)
Target: arm64-apple-darwin27.0.0
Thread model: posix
Context for the issue:
This issue appears to affect all recent macOS versions (15.3+, 15.4, and now 27
Beta), with slightly different error messages depending on exact Xcode/Clang
version. The common root is the -ld64 flag in PyTensor's compile command being
incompatible with Apple's evolving linker toolchain. A more robust fix would be
to detect the macOS linker version at compile time and either omit -ld64 or
replace it with -Wl,-ld_classic on macOS versions where the latter is supported.
Describe the issue:
Related issues
-ld64root cause, different linker error message)This is a distinct manifestation of the same issue: PyTensor passes
-ld64as a compiler flag, but on macOS 27 Beta (Sequoia successor, arm64), theClang linker interprets
-ld64as-l d64(i.e. "link against a library namedd64") rather than as the linker-selector flag. This produces a different errormessage than BUG: Compatibility Issue for pytensor on macOS 15.4 #1342/BUG: clang linker fails #1347, suggesting the flag's interpretation changed again in
the newer Xcode/Clang shipped with macOS 27.
Environment
/usr/bin/clang++(clang-2100.3.23.3)Root cause (as understood)
-ld64inpytensor/link/c/cmodule.pyis meant to select the classic macOSlinker (
ld64) over Apple's new linker (ld/lld). On macOS 27 Beta, Clangparses this as
-l d64(link against libraryd64) rather than as a linkerselection flag, because the flag syntax changed in the Xcode toolchain bundled
with this beta OS version.
Workaround (confirmed working)
Setting
pytensor.config.cxx = ""before importing PyMC forces PyTensor touse its Python-mode backend (no C compilation), bypassing the Clang flag entirely.
Performance impact on Apple Silicon (M3 Pro, Python-mode vs C-compiled):
Alternatively, via environment variable before running the script:
Reproducable code example:
Error message:
PyTensor version information:
Name: pytensor
Version: 3.0.7
Apple clang version 21.0.0 (clang-2100.3.23.3)
Target: arm64-apple-darwin27.0.0
Thread model: posix
Context for the issue:
This issue appears to affect all recent macOS versions (15.3+, 15.4, and now 27
Beta), with slightly different error messages depending on exact Xcode/Clang
version. The common root is the
-ld64flag in PyTensor's compile command beingincompatible with Apple's evolving linker toolchain. A more robust fix would be
to detect the macOS linker version at compile time and either omit
-ld64orreplace it with
-Wl,-ld_classicon macOS versions where the latter is supported.