Linux kernel timeconst

安卓内核编译错误 kernel/timeconst.h defined(@val)
错误情况

今天编译安卓内核出现错误,

$ ./mk -k
#
# configuration written to .config
#
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: 'include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
TIMEC kernel/timeconst.h
Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
/run/media/playpeng/Devel/AndroidDevel/Android4_4/kernel/kernel/Makefile:140: recipe for target 'kernel/timeconst.h' failed
make[1]: *** [kernel/timeconst.h] Error 255
Makefile:948: recipe for target 'kernel' failed
make: *** [kernel] Error 2
make: *** Waiting for unfinished jobs....

解决方法

Google一番,跟自己猜测的一致,就是perl新版本语法有变化,不支持 defined(@val) 这种用法了, 直接改成 if (@val)这种即可,google到老外网站,是如下的patch

diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl
index eb51d76..0461239 100644
--- a/kernel/timeconst.pl
+++ b/kernel/timeconst.pl
@@ -370,7 +370,7 @@ if ($hz eq '--can') {
}

@val = @{$canned_values{$hz}};
- if (!defined(@val)) {
+ if (!@val) {
@val = compute_values($hz);
}
output($hz, @val);
--

Комментарии