File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,22 @@ mkdir -p "$OUTPUT_DIR"
3434CCC=" xcrun -sdk macosx metal -x metal"
3535HDRS=$( $CCC -I" $SRC_DIR " -I" $JIT_INCLUDES " -DMLX_METAL_JIT -E -P -CC -C -H " $INPUT_FILE " $CFLAGS -w 2>&1 1> /dev/null )
3636
37+ # Fail early if the Metal compiler returned errors instead of header paths.
38+ # Valid lines start with '.' chars (depth indicators); anything else means
39+ # xcrun/metal failed (e.g. missing SDK, misconfigured toolchain).
40+ if [ -n " $HDRS " ]; then
41+ invalid_lines=$( echo " $HDRS " | grep -v ' ^\.*\.' || true)
42+ if [ -n " $invalid_lines " ]; then
43+ echo " Error: Metal compiler header resolution failed for ${INPUT_FILE} " >&2
44+ echo " Expected lines starting with '.' but got:" >&2
45+ echo " $invalid_lines " >&2
46+ echo " " >&2
47+ echo " This usually means xcrun or the Metal toolchain is not configured correctly." >&2
48+ echo " Try running: xcrun -sdk macosx metal --version" >&2
49+ exit 1
50+ fi
51+ fi
52+
3753# Remove any included system frameworks (for MetalPerformancePrimitive headers)
3854HDRS=$( echo " $HDRS " | grep -v " Xcode" )
3955
You can’t perform that action at this time.
0 commit comments