blob: 4e7077227b6812c94cbe4c9059791b1c07bf6c9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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" <<EOF
@@ -58,8 +68,8 @@ EOF
# Append the actual test code from stdin
cat >> "$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
|