在新版linux上编译老版本的kernel出现kernel/timeconst.h] Error 255

解决Ubuntu16.04编译Linux-2.6.31内核时的时间常数错误
在尝试编译Linux-2.6.31内核时,博主遇到了一个错误,错误提示涉及到了kernel/timeconst.pl文件的第373行。错误信息表明不能使用'defined(@array)'。为了解决这个问题,博主建议删除该行中的'defined()',只保留@val,这一修改使得内核编译得以继续并成功完成。

在使用ubuntu16.4编译Linux-2.6.31内核时出现这样的错误可以修改timeconst.pl的内容后正常编译。

以下是编译错误提示的内容:

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
/opt/ARM/mini6410/linux/linux-2.6.38/kernel/Makefile:140: recipe for target 'kernel/timeconst.h' failed
make[1]: *** [kernel/timeconst.h] Error 255
Makefile:916: recipe for target 'kernel' failed
make: *** [kernel] Error 2

将kernel/timeconst.pl中第373行的defined()去掉只留下@val就可以了

=========== copy iot-security from local =============== touch /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/.prepared_ff3f946004efdf04c05e4df40af18419 (cd /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/./; if [ -x ./configure ]; then /usr/bin/find /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/ -name config.guess | xargs -r chmod u+w; /usr/bin/find /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/ -name config.guess | xargs -r -n1 cp /home/tplink/code/be900v2/Iplatform/openwrt/scripts/config.guess; /usr/bin/find /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/ -name config.sub | xargs -r chmod u+w; /usr/bin/find /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/ -name config.sub | xargs -r -n1 cp /home/tplink/code/be900v2/Iplatform/openwrt/scripts/config.sub; AR=arm-buildroot-linux-gnueabi-ar AS="arm-buildroot-linux-gnueabi-gcc -c " LD=arm-buildroot-linux-gnueabi-ld NM=arm-buildroot-linux-gnueabi-nm CC="arm-buildroot-linux-gnueabi-gcc" GCC="arm-buildroot-linux-gnueabi-gcc" CXX="arm-buildroot-linux-gnueabi-g++" RANLIB=arm-buildroot-linux-gnueabi-ranlib STRIP=arm-buildroot-linux-gnueabi-strip OBJCOPY=arm-buildroot-linux-gnueabi-objcopy OBJDUMP=arm-buildroot-linux-gnueabi-objdump SIZE=arm-buildroot-linux-gnueabi-size CFLAGS=" -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include" -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include"/uapi" CXXFLAGS=" -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include" -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include"/uapi" CPPFLAGS="-I/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/target-arm-openwrt-linux-uclibc-be900v2/usr/include -I/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/target-arm-openwrt-linux-uclibc-be900v2/include -I/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/usr-be900v2/include -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/toolchain/opt/toolchains/crosstools-arm_softfp-gcc-10.3-linux-4.19-glibc-2.32-binutils-2.36.1/usr/include " LDFLAGS="-L/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/target-arm-openwrt-linux-uclibc-be900v2/usr/lib -L/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/target-arm-openwrt-linux-uclibc-be900v2/lib -Wl,-rpath-link,/home/tplink/code/be900v2/Iplatform/openwrt/staging_dir/target-arm-openwrt-linux-uclibc-be900v2/usr/lib -L/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/toolchain/opt/toolchains/crosstools-arm_softfp-gcc-10.3-linux-4.19-glibc-2.32-binutils-2.36.1/usr/lib -L/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/toolchain/opt/toolchains/crosstools-arm_softfp-gcc-10.3-linux-4.19-glibc-2.32-binutils-2.36.1/lib " ./configure --target=arm-openwrt-linux-uclibc --host=arm-openwrt-linux-uclibc --build=x86_64-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls ; fi; ) rm -f /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/.configured_* touch /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/.configured_ make -C "/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19" M="/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0" EXTRA_CFLAGS="-I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include" -I/home/tplink/code/be900v2/Iplatform/openwrt/../../bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19/../"bcmkernel/include"/uapi" modules make[4]: Entering directory '/home/tplink/code/be900v2/bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19' $KERNELPATH is [/opt/prpl_xgb834v/sdk_an7581_an7551/prplos/prplos-v3.0.1/build_dir/target-aarch64_cortex-a53_musl/linux-airoha_an7581/linux-5.4.55] $PRIVATE_MODULES_PATH is [] CC [M] /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.o In file included from ././include/linux/compiler_types.h:64:0, from <command-line>:0: ./include/linux/compiler-gcc.h:20:3: error: #error Sorry, your version of GCC is too old - please use 5.1 or newer. # error Sorry, your version of GCC is too old - please use 5.1 or newer. ^ In file included from ./arch/x86/include/asm/pgtable_types.h:348:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/asm-generic/pgtable-nopud.h:21:0: warning: "PUD_SHIFT" redefined #define PUD_SHIFT P4D_SHIFT ^ In file included from ./arch/x86/include/asm/pgtable_types.h:251:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/pgtable_64_types.h:83:0: note: this is the location of the previous definition #define PUD_SHIFT 30 ^ In file included from ./arch/x86/include/asm/pgtable_types.h:348:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/asm-generic/pgtable-nopud.h:22:0: warning: "PTRS_PER_PUD" redefined #define PTRS_PER_PUD 1 ^ In file included from ./arch/x86/include/asm/pgtable_types.h:251:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/pgtable_64_types.h:84:0: note: this is the location of the previous definition #define PTRS_PER_PUD 512 ^ In file included from ./arch/x86/include/asm/pgtable_types.h:348:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/asm-generic/pgtable-nopud.h:23:0: warning: "PUD_SIZE" redefined #define PUD_SIZE (1UL << PUD_SHIFT) ^ In file included from ./arch/x86/include/asm/pgtable_types.h:251:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/pgtable_64_types.h:100:0: note: this is the location of the previous definition #define PUD_SIZE (_AC(1, UL) << PUD_SHIFT) ^ In file included from ./arch/x86/include/asm/pgtable_types.h:348:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/asm-generic/pgtable-nopud.h:24:0: warning: "PUD_MASK" redefined #define PUD_MASK (~(PUD_SIZE-1)) ^ In file included from ./arch/x86/include/asm/pgtable_types.h:251:0, from ./arch/x86/include/asm/processor.h:19, from ./arch/x86/include/asm/cpufeature.h:5, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/pgtable_64_types.h:101:0: note: this is the location of the previous definition #define PUD_MASK (~(PUD_SIZE - 1)) ^ In file included from ./arch/x86/include/asm/cpufeature.h:5:0, from ./arch/x86/include/asm/thread_info.h:53, from ./include/linux/thread_info.h:39, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/processor.h: In function 'load_cr3': ./arch/x86/include/asm/processor.h:251:2: error: implicit declaration of function '__sme_pa' [-Werror=implicit-function-declaration] write_cr3(__sme_pa(pgdir)); ^ In file included from ./include/linux/cache.h:6:0, from ./include/linux/printk.h:9, from ./include/linux/kernel.h:14, from ./include/linux/list.h:9, from ./include/linux/module.h:9, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/processor.h: At top level: ./arch/x86/include/asm/cache.h:8:25: error: 'CONFIG_X86_L1_CACHE_SHIFT' undeclared here (not in a function) #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) ^ ./arch/x86/include/asm/cache.h:9:30: note: in expansion of macro 'L1_CACHE_SHIFT' #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) ^ ./include/linux/cache.h:13:25: note: in expansion of macro 'L1_CACHE_BYTES' #define SMP_CACHE_BYTES L1_CACHE_BYTES ^ ./include/linux/cache.h:35:58: note: in expansion of macro 'SMP_CACHE_BYTES' #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES))) ^ ./include/linux/percpu-defs.h:149:2: note: in expansion of macro '____cacheline_aligned' ____cacheline_aligned ^ ./arch/x86/include/asm/processor.h:433:1: note: in expansion of macro 'DECLARE_PER_CPU_ALIGNED' DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); ^ In file included from ./include/asm-generic/percpu.h:7:0, from ./arch/x86/include/asm/percpu.h:544, from ./arch/x86/include/asm/preempt.h:6, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/processor.h:433:32: error: requested alignment is not an integer constant DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); ^ ./include/linux/percpu-defs.h:101:38: note: in definition of macro 'DECLARE_PER_CPU_SECTION' extern __PCPU_ATTRS(sec) __typeof__(type) name ^ ./arch/x86/include/asm/processor.h:433:1: note: in expansion of macro 'DECLARE_PER_CPU_ALIGNED' DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); ^ In file included from ./arch/x86/include/asm/preempt.h:7:0, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/linux/thread_info.h:116:19: error: redefinition of 'arch_within_stack_frames' static inline int arch_within_stack_frames(const void * const stack, ^ In file included from ./include/linux/thread_info.h:39:0, from ./arch/x86/include/asm/preempt.h:7, from ./include/linux/preempt.h:81, from ./include/linux/spinlock.h:51, from ./include/linux/seqlock.h:36, from ./include/linux/time.h:6, from ./include/linux/stat.h:19, from ./include/linux/module.h:10, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/thread_info.h:186:19: note: previous definition of 'arch_within_stack_frames' was here static inline int arch_within_stack_frames(const void * const stack, ^ In file included from ./include/linux/cache.h:6:0, from ./include/linux/printk.h:9, from ./include/linux/kernel.h:14, from ./include/linux/list.h:9, from ./include/linux/module.h:9, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/cache.h:13:31: error: 'CONFIG_X86_INTERNODE_CACHE_SHIFT' undeclared here (not in a function) #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT ^ ./include/linux/cache.h:72:35: note: in expansion of macro 'INTERNODE_CACHE_SHIFT' __attribute__((__aligned__(1 << (INTERNODE_CACHE_SHIFT)))) ^ ./include/linux/mmzone.h:112:3: note: in expansion of macro '____cacheline_internodealigned_in_smp' } ____cacheline_internodealigned_in_smp; ^ In file included from ./include/linux/gfp.h:6:0, from ./include/linux/umh.h:4, from ./include/linux/kmod.h:22, from ./include/linux/module.h:13, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/linux/mmzone.h:112:1: error: requested alignment is not an integer constant } ____cacheline_internodealigned_in_smp; ^ ./include/linux/mmzone.h:509:1: error: requested alignment is not an integer constant } ____cacheline_internodealigned_in_smp; ^ In file included from ./include/linux/ktime.h:25:0, from ./include/linux/timer.h:6, from ./include/linux/workqueue.h:9, from ./include/linux/srcu.h:34, from ./include/linux/notifier.h:16, from ./include/linux/memory_hotplug.h:7, from ./include/linux/mmzone.h:749, from ./include/linux/gfp.h:6, from ./include/linux/umh.h:4, from ./include/linux/kmod.h:22, from ./include/linux/module.h:13, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/linux/jiffies.h:80:1: error: requested alignment is not an integer constant extern u64 __cacheline_aligned_in_smp jiffies_64; ^ ./include/linux/jiffies.h:81:1: error: requested alignment is not an integer constant extern unsigned long volatile __cacheline_aligned_in_smp __jiffy_arch_data jiffies; ^ In file included from ./include/linux/srcu.h:62:0, from ./include/linux/notifier.h:16, from ./include/linux/memory_hotplug.h:7, from ./include/linux/mmzone.h:749, from ./include/linux/gfp.h:6, from ./include/linux/umh.h:4, from ./include/linux/kmod.h:22, from ./include/linux/module.h:13, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./include/linux/srcutree.h:43:2: error: requested alignment is not an integer constant spinlock_t __private lock ____cacheline_internodealigned_in_smp; ^ In file included from ./include/linux/elf.h:5:0, from ./include/linux/module.h:15, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/elf.h: In function 'elf_common_init': ./arch/x86/include/asm/elf.h:180:3: error: 'struct thread_struct' has no member named 'fsbase' t->fsbase = t->gsbase = 0; ^ ./arch/x86/include/asm/elf.h:180:15: error: 'struct thread_struct' has no member named 'gsbase' t->fsbase = t->gsbase = 0; ^ ./arch/x86/include/asm/elf.h: At top level: ./arch/x86/include/asm/elf.h:381:1: error: requested alignment is not an integer constant } ____cacheline_aligned; ^ In file included from ./include/linux/module.h:26:0, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20: ./arch/x86/include/asm/module.h:67:2: error: #error unknown processor family #error unknown processor family ^ In file included from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:20:0: ./include/linux/module.h:486:1: error: requested alignment is not an integer constant } ____cacheline_aligned __randomize_layout; ^ In file included from ./include/linux/fs.h:8:0, from ./include/linux/net.h:27, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/dcache.h:149:1: error: requested alignment is not an integer constant } ____cacheline_aligned; ^ In file included from ./include/linux/fs.h:13:0, from ./include/linux/net.h:27, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/list_lru.h:50:1: error: requested alignment is not an integer constant } ____cacheline_aligned_in_smp; ^ In file included from ./include/uapi/linux/sem.h:5:0, from ./include/linux/sem.h:5, from ./include/linux/sched.h:15, from ./include/linux/ioprio.h:5, from ./include/linux/fs.h:39, from ./include/linux/net.h:27, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/ipc.h:29:1: error: requested alignment is not an integer constant } ____cacheline_aligned_in_smp __randomize_layout; ^ In file included from ./include/linux/sched.h:20:0, from ./include/linux/ioprio.h:5, from ./include/linux/fs.h:39, from ./include/linux/net.h:27, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/hrtimer.h:159:1: error: requested alignment is not an integer constant } __hrtimer_clock_base_align; ^ ./include/linux/hrtimer.h:221:1: error: requested alignment is not an integer constant } ____cacheline_aligned; ^ In file included from ./include/linux/ioprio.h:5:0, from ./include/linux/fs.h:39, from ./include/linux/net.h:27, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/sched.h:408:1: error: requested alignment is not an integer constant } ____cacheline_aligned; ^ In file included from ./include/linux/net.h:27:0, from ./include/linux/skbuff.h:29, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/fs.h:1468:9: error: requested alignment is not an integer constant struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; ^ ./include/linux/fs.h:1469:9: error: requested alignment is not an integer constant struct list_lru s_inode_lru ____cacheline_aligned_in_smp; ^ ./include/linux/fs.h:1481:2: error: requested alignment is not an integer constant spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; ^ ./include/linux/fs.h:1819:1: error: requested alignment is not an integer constant } ____cacheline_aligned; ^ In file included from ./include/linux/skbuff.h:29:0, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./include/linux/net.h:104:1: error: requested alignment is not an integer constant } ____cacheline_aligned_in_smp; ^ In file included from ./arch/x86/include/asm/realmode.h:15:0, from ./arch/x86/include/asm/acpi.h:33, from ./arch/x86/include/asm/fixmap.h:29, from ./arch/x86/include/asm/pgtable_64.h:17, from ./arch/x86/include/asm/pgtable.h:698, from ./include/linux/memremap.h:7, from ./include/linux/mm.h:27, from ./include/linux/scatterlist.h:8, from ./include/linux/dma-mapping.h:11, from ./include/linux/skbuff.h:34, from ./include/linux/netfilter.h:6, from /home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.c:23: ./arch/x86/include/asm/io.h:44:31: fatal error: asm/early_ioremap.h: No such file or directory #include <asm/early_ioremap.h> ^ cc1: some warnings being treated as errors compilation terminated. scripts/Makefile.build:303: recipe for target '/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.o' failed make[5]: *** [/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/iot_main.o] Error 1 Makefile:1586: recipe for target '_module_/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0' failed make[4]: *** [_module_/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0] Error 2 make[4]: Leaving directory '/home/tplink/code/be900v2/bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19' Makefile:37: recipe for target '/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/.built' failed make[3]: *** [/home/tplink/code/be900v2/Iplatform/openwrt/build_dir/linux-model_brcm_bcm490x/iot-security-1.0.0/.built] Error 2 make[3]: Leaving directory '/home/tplink/code/be900v2/prplos/platform/feeds/private/iot-security' package/Makefile:133: recipe for target 'package/feeds/feed_private/iot-security/compile' failed make[2]: *** [package/feeds/feed_private/iot-security/compile] Error 2 make[2]: Leaving directory '/home/tplink/code/be900v2/Iplatform/openwrt' /home/tplink/code/be900v2/Iplatform/openwrt/include/toplevel.mk:184: recipe for target 'package/iot-security/compile' failed make[1]: *** [package/iot-security/compile] Error 2 make[1]: Leaving directory '/home/tplink/code/be900v2/Iplatform/openwrt' Makefile:232: recipe for target 'iplatform_package/iot-security/compile' failed make: *** [iplatform_package/iot-security/compile] Error 2
最新发布
11-05
<think>我们再次面临编译错误,但这次错误信息更复杂。核心问题仍然是GCC版本过低(要求5.1+),但出现了更多衍生错误,包括: 1. 头文件重定义警告(如PUD_SHIFT) 2. 未定义的内核配置宏(如CONFIG_X86_L1_CACHE_SHIFT) 3. 结构体成员缺失(如thread_struct没有fsbase/gsbase) 4. 对齐请求不是整数常量错误 5. asm/early_ioremap.h头文件缺失 根本原因:编译ARM架构模块时错误地包含了x86架构的内核头文件。证据: - 错误中频繁出现`./arch/x86/include/...`路径 - 打印的`$KERNELPATH`是ARM64路径(但实际编译命令指定的是ARM内核路径) 深层分析:Makefile中`KERNELPATH`变量被硬编码为ARM64路径(/opt/prpl_xgb834v/.../linux-5.4.55),而实际编译命令使用的内核源码路径是ARM路径(/home/tplink/.../linux-4.19)。这导致: 1. 编译时通过`-I`选项引入了ARM64的头文件(与ARM架构冲突) 2. ARM工具链尝试编译x86架构的代码,引发连锁错误 解决方案: 1. **强制修正KERNELPATH** 在Makefile中覆盖`KERNELPATH`变量,使其指向实际使用的ARM内核路径(即编译命令中的路径): ```makefile KERNELPATH := /home/tplink/code/be900v2/bcm504L04/bcm963xx_5.04L.04/kernel/linux-4.19 ``` 或通过环境变量传递: ```bash export KERNELPATH=/正确路径; make ``` 2. **清理残留头文件影响** 执行彻底清理,删除所有编译中间文件及配置缓存: ```bash make clean # 在模块目录 rm -rf /build_dir/.../iot-security-1.0.0/.configured_* # 删除标记文件强制重新配置 ``` 3. **验证工具链兼容性** 确认交叉编译器与目标内核版本匹配: ```bash arm-buildroot-linux-gnueabi-gcc --version # 应≥5.1 ``` 若仍有头文件错误,检查Makefile中`EXTRA_CFLAGS`是否包含不必要路径(如x86相关),可暂时清空调试。 §§相关问题§§ 1. 如何检测Makefile中哪些变量被错误覆盖导致编译路径错误? 2. 当交叉编译内核模块时,如何确保架构头文件优先级高于宿主机的头文件? 3. 遇到"requested alignment is not an integer constant"错误的具体原因和解决方法有哪些? 4. 在OpenWrt编译系统中,如何正确传递内核路径变量给第三方模块? </think>根据最新的编译输出,核心问题仍然是**GCC版本过低导致的内核头文件兼容性问题**,但出现了更复杂的衍生错误。以下是关键分析和解决方案: ### 核心问题分析 1. **GCC版本过低(致命错误)** ```./include/linux/compiler-gcc.h:20:3: error: #error Sorry, your version of GCC is too old``` 明确要求GCC 5.1+,但您的工具链版本过低(输出中显示为`arm_softfp-gcc-10.3`,但实际可能未生效) 2. **架构混淆引发连锁错误** - 编译ARM模块时错误包含x86架构头文件(如`./arch/x86/include/`路径) - 导致宏重定义(如`PUD_SHIFT`)、结构体缺失成员(如`thread_struct`无`fsbase`) - 未定义配置项(如`CONFIG_X86_L1_CACHE_SHIFT`在ARM编译中无效) 3. **头文件路径污染** 编译命令中的`-I`参数包含冲突路径: ```EXTRA_CFLAGS="-I.../linux-4.19/../bcmkernel/include"``` 可能引入与目标架构不兼容的头文件 ### 解决方案 #### 步骤1:强制更新工具链 ```bash # 确认当前GCC版本 arm-buildroot-linux-gnueabi-gcc --version # 若版本<5.1,更新工具链(示例) sudo apt install gcc-10 export CC="arm-buildroot-linux-gnueabi-gcc-10" # 指定高版本编译器 ``` #### 步骤2:修复架构冲突 在Makefile中添加架构过滤: ```makefile # 在EXTRA_CFLAGS前添加 EXTRA_CFLAGS += -Uarch_x86 -U__x86_64__ # 显式取消x86定义 EXTRA_CFLAGS += -D__arm__ -DCONFIG_ARM # 强制定义ARM架构 ``` #### 步骤3:清理并重建 ```bash # 彻底清理 make clean rm -rf /home/tplink/.../iot-security-1.0.0/.configured_* # 重建时隔离问题路径 make -C "内核路径" M="模块路径" EXTRA_CFLAGS="-I正确头文件路径" modules ``` ### 附加排查 若仍失败,尝试: 1. **检查内核配置** 确认`linux-4.19/.config`中存在: ```CONFIG_ARM=y``` ```CONFIG_CPU_V7=y```(根据具体芯片) 2. **验证头文件完整性** 检查缺失的头文件`asm/early_ioremap.h`是否存在于目标内核路径 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值