mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
Runs the unmodified upstream Linux amdgpu and amdkfd drivers on Apple Silicon Macs inside a DriverKit system extension, for AMD GPUs attached over Thunderbolt. The Linux sources come from a pinned submodule and are compiled against linuxu, a userspace implementation of the Linux kernel APIs they use. Includes the HSA runtime, the host installer app, the setup and firmware fetch scripts, and the offline test suite.
27 lines
1.1 KiB
Bash
27 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
work=$(mktemp -d)
|
|
trap 'rm -rf "$work"' EXIT
|
|
python3 - "$work/kfd_interrupt_helpers.inc" <<'PY'
|
|
from pathlib import Path
|
|
import sys
|
|
source = Path('third_party/linux/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c').read_text()
|
|
functions = []
|
|
for signature in ('bool enqueue_ih_ring_entry(', 'static bool dequeue_ih_ring_entry('):
|
|
assert source.count(signature) == 1
|
|
begin = source.index(signature)
|
|
end = source.index('\n}\n', begin) + 3
|
|
functions.append(source[begin:end])
|
|
Path(sys.argv[1]).write_text('\n'.join(functions))
|
|
PY
|
|
clang -w -std=gnu11 -D__KERNEL__ -include linux/autoconf.h \
|
|
-include linux/kernel.h -include linux/bug.h \
|
|
-g -O1 -fsanitize=address,undefined -fno-sanitize-recover=all \
|
|
-ffunction-sections -fdata-sections -Ilinuxu/headers -I"$work" \
|
|
linuxu/tests/test_kernel_helpers.c third_party/linux/lib/kfifo.c \
|
|
third_party/linux/lib/list_sort.c third_party/linux/lib/crc/crc16.c \
|
|
linuxu/src/kmem/kmemalloc.c linuxu/src/kmem/kmemcheck.c linuxu/src/bug.c \
|
|
-Wl,-dead_strip -lpthread -o "$work/test_kernel_helpers"
|
|
"$work/test_kernel_helpers"
|