Fix for configuration generator to support Clang-built kernels. Partially backports https://github.com/amd/xdna-driver/commit/539d1ba5dc3a46338af694ec07b06dfe4c052dc5 --- a/src/driver/tools/configure_kernel.sh +++ b/src/driver/tools/configure_kernel.sh @@ -42,6 +42,16 @@ try_compile() { tmpdir=$(mktemp -d /tmp/conftest-XXXXXX) conftest_c="$tmpdir/conftest.c" conftest_mk="$tmpdir/Makefile" + USE_LLVM="" + if [ -e /proc/config.gz ]; then + if zgrep -q "CONFIG_CC_IS_CLANG=y" /proc/config.gz 2>/dev/null; then + USE_LLVM="LLVM=1" + fi + elif [ -e "/boot/config-$KERNEL_VER" ]; then + if grep -q "CONFIG_CC_IS_CLANG=y" "/boot/config-$KERNEL_VER" 2>/dev/null; then + USE_LLVM="LLVM=1" + fi + fi # Minimal Kbuild for an external module cat > "$conftest_mk" <> "$conftest_c" - # Now build it like your real driver - if make -s -C "$KERNEL_SRC" M="$tmpdir" modules >/dev/null 2>&1; then + # Now build it like your real driver ($USE_LLVM intentionally unquoted to avoid empty arg) + if make -s -C "$KERNEL_SRC" M="$tmpdir" modules $USE_LLVM >/dev/null 2>&1; then echo "#define $macro 1" >> "$OUT" echo ">>> + $macro: yes" >&2 else