diff --git a/.github/workflows/autogen.yml b/.github/workflows/autogen.yml index 486c2b5e35..1e24fe2167 100644 --- a/.github/workflows/autogen.yml +++ b/.github/workflows/autogen.yml @@ -84,7 +84,7 @@ jobs: - name: Regenerate autogen files run: | rm tinygrad/runtime/autogen/metal.py tinygrad/runtime/autogen/iokit.py tinygrad/runtime/autogen/corefoundation.py - LIBCLANG_PATH=/opt/homebrew/opt/llvm@20/lib/libclang.dylib python3 -c "from tinygrad.runtime.autogen import metal, iokit, corefoundation" + python3 -c "from tinygrad.runtime.autogen import metal, iokit, corefoundation" - name: Check for differences run: | if ! git diff --quiet; then diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6ab08f1ac..f400d38ec1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -792,8 +792,6 @@ jobs: ocelot: 'true' llvm: 'true' - name: Run unit tests - env: - LIBCLANG_PATH: '/opt/homebrew/opt/llvm@20/lib/libclang.dylib' run: METAL=1 python -m pytest -n=auto test/unit/ --durations=20 - name: Run ONNX run: METAL=1 python -m pytest -n=auto test/external/external_test_onnx_backend.py --durations=20 diff --git a/tinygrad/runtime/autogen/__init__.py b/tinygrad/runtime/autogen/__init__.py index fe4aa885bd..6390e34fd4 100644 --- a/tinygrad/runtime/autogen/__init__.py +++ b/tinygrad/runtime/autogen/__init__.py @@ -10,6 +10,7 @@ macossdk = "/var/db/xcode_select_link/Platforms/MacOSX.platform/Developer/SDKs/M llvm_lib = (r"'C:\\Program Files\\LLVM\\bin\\LLVM-C.dll' if WIN else '/opt/homebrew/opt/llvm@20/lib/libLLVM.dylib' if OSX else " + repr(['LLVM'] + [f'LLVM-{i}' for i in reversed(range(14, 21+1))])) +clang_lib = "'/opt/homebrew/opt/llvm@20/lib/libclang.dylib' if OSX else ['clang-20', 'clang']" webgpu_lib = "os.path.join(sysconfig.get_paths()['purelib'], 'pydawn', 'lib', 'libwebgpu_dawn.dll') if WIN else 'webgpu_dawn'" nv_lib_path = "[f'/{pre}/cuda/targets/{sysconfig.get_config_vars().get(\"MULTIARCH\", \"\").rsplit(\"-\", 1)[0]}/lib' for pre in ['opt', 'usr/local']]" @@ -135,9 +136,9 @@ def __getattr__(nm): tarball="https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-25.2.7/mesa-25.2.7.tar.gz", prolog=["import gzip, base64"], epilog=lambda path: [system(f"{root}/extra/mesa/lvp_nir_options.sh {path}")]) case "libclang": - return load("libclang", "['clang-20', 'clang']", + return load("libclang", clang_lib, lambda: [f"{system('llvm-config-20 --includedir')}/clang-c/{s}.h" for s in ["Index", "CXString", "CXSourceLocation", "CXFile"]], - args=lambda: system("llvm-config-20 --cflags").split()) + prolog=["from tinygrad.helpers import OSX"], args=lambda: system("llvm-config-20 --cflags").split()) case "metal": return load("metal", "'Metal'", [f"{macossdk}/System/Library/Frameworks/Metal.framework/Headers/MTL{s}.h" for s in ["ComputeCommandEncoder", "ComputePipeline", "CommandQueue", "Device", "IndirectCommandBuffer", "Resource", "CommandEncoder"]], diff --git a/tinygrad/runtime/autogen/libclang.py b/tinygrad/runtime/autogen/libclang.py index 85bf14a14e..e0f8fae0fb 100644 --- a/tinygrad/runtime/autogen/libclang.py +++ b/tinygrad/runtime/autogen/libclang.py @@ -4,7 +4,8 @@ import ctypes from typing import Annotated, Literal, TypeAlias from tinygrad.runtime.support.c import _IO, _IOW, _IOR, _IOWR from tinygrad.runtime.support import c -dll = c.DLL('libclang', ['clang-20', 'clang']) +from tinygrad.helpers import OSX +dll = c.DLL('libclang', '/opt/homebrew/opt/llvm@20/lib/libclang.dylib' if OSX else ['clang-20', 'clang']) CXIndex: TypeAlias = ctypes.c_void_p class struct_CXTargetInfoImpl(ctypes.Structure): pass CXTargetInfo: TypeAlias = c.POINTER[struct_CXTargetInfoImpl]