./include/generated/compile.h:7:24: warning: missing terminating '"' character [-Winvalid-pp-token] #define LINUX_COMPILER "Android (7284624, based on r416183b) clang version 12.0.5 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee) ^ ./include/generated/compile.h:8:1: error: unknown type name 'Found'去看 error source,是在 kernel source 里:
kernel-4.19/include/generated/compile.h
在產生 compile.h 的時候...
#define LINUX_COMPILER "Android (7284624, based on r416183b) clang version 12.0.5 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee) Found CUDA installation: /usr/local/cuda, version 11.0, LLD 12.0.5 (/buildbot/src/android/llvm-toolchain/out/llvm-project/lld c935d99d7cf2016289302412d708641d52d2f7ee)"define 不支援斷行...
init/Makefile:
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \ "$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" \ "$(CC) $(KBUILD_CFLAGS)" "$(LD)"然後 mkcompile_h 中:
TARGET=$1 ARCH=$2 SMP=$3 PREEMPT=$4 CC=$5 LD=$6 .. ( echo /\* This file is auto generated, version $VERSION \*/ if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi echo \#define UTS_MACHINE \"$ARCH\" echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//') LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ | sed 's/[[:space:]]*$//') printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION" ) > .tmpcompile這個script 在 kernel 5.X 之後由 Kconfig 取代了。
測試一下 CC_VERSION 的產生: $CC -v
Android 這邊是用 prebuild 內的 clang。
執行結果:
prebuilts/clang/host/linux-x86/clang-3289846$ bin/clang -v Android clang version 3.8.275480 (based on LLVM 3.8.275480) Target: x86_64-unknown-linux Thread model: posix InstalledDir: /home/charles-chang/Android12/prebuilts/clang/host/linux-x86/clang-3289846/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 Found CUDA installation: /usr/local/cuda, version unknown果然出現 CUDA,因為也有 version 字樣,所以有出現在後面的 grep 結果。
所以把 grep ' version ' 改 'clang version ' 試試...
好像 OK, compile.h 有問題的部份變成...
#define LINUX_COMPILER "Android (7284624, based on r416183b) clang version 12.0.5 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee), LLD 12.0.5 (/buildbot/src/android/llvm-toolchain/out/llvm-project/lld c935d99d7cf2016289302412d708641d52d2f7ee)"--- 但是要是不是用 clang 就會 fail 吧...
改只取line 1 好了...
kernel-4.19$ git diff diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 19de4cdef1ec..b1e1d7540b9c 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -73,7 +73,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN" echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\" echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" - CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//') + CC_VERSION=$($CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//' | head -n 1) LD_VERSION=$($LD -v | head -n1 | sed 's/(compatible with [^)]*)//' \ | sed 's/[[:space:]]*$//') printf '#define LINUX_COMPILER "%s"\n' "$CC_VERSION, $LD_VERSION"
沒有留言:
張貼留言