我是为 Android 构建内核的新手。我遇到了一个问题,好几天都没能解决。错误如下:../kernel/cgroup/cpuset.c:1794:16:错误:声明“str...
我是为 Android 构建内核的新手。我遇到了一个问题,好几天都无法解决。错误如下:
../kernel/cgroup/cpuset.c:1794:16: error: declaration of 'struct cs_target' will not be visible outside of this function [-Werror,-Wvisibility]
struct cs_target tgt, size_t nbytes,
^
../kernel/cgroup/cpuset.c:1794:26: error: variable has incomplete type 'struct cs_target'
struct cs_target tgt, size_t nbytes,
^
../kernel/cgroup/cpuset.c:1794:16: note: forward declaration of 'struct cs_target'
struct cs_target tgt, size_t nbytes,
我该如何解决这个问题? 来源
以下是我的步骤:
cd /home/me/kuroneko_r_mt6765
export ARCH=arm64
export SUBARCH=arm
export CLANG_TRIPLE=aarch64-linux-gnu-
export CROSS_COMPILE=aarch64-linux-gnu-
export CROSS_COMPILE_ARM32=arm-linux-gnueabi-
make blossom_defconfig O=out
make -j4 CC=clang O=out
我有相同的存储库,用于在 ubuntu 20.04 和 ubuntu 24.04 上交叉编译 Linux 内核。更准确地说,我这样做:make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules -j4在两个发行版上,...
我有相同的存储库,用于在 ubuntu 20.04 和 ubuntu 24.04 上交叉编译 Linux 内核。更准确地说,我这样做:
使 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- 图像模块 -j4
在两个发行版上,我都使用 amd64 gcc 9.5 和相同的交叉编译工具链。
在 Ubuntu 24.04 上,即使没有更改任何文件,编译也会每次重新编译所有内容。在 Ubuntu 20.04 上不会发生这种情况。
在 ubuntu 24.04 上:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules -j4
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CC scripts/mod/empty.o
CC scripts/mod/devicetable-offsets.s
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/modpost.o
HOSTCC scripts/mod/sumversion.o
GEN scripts/mod/devicetable-offsets.h
HOSTCC scripts/mod/file2alias.o
CHK include/generated/utsrelease.h
CHK include/generated/timeconst.h
CC kernel/bounds.s
CHK include/generated/bounds.h
CC arch/arm64/kernel/asm-offsets.s
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
HOSTLD scripts/mod/modpost
CC init/main.o
....
文件戳未更改,其他一切相同。换句话说,唯一的区别是 Ubuntu 24.04 与 Ubuntu 20.04。
怎么可能所有内容都在 24.04 上重新编译,而在 20.04 上却没有(这是预期的行为)?
#################################################### ########
编辑1
我已将 Ubuntu 20.04 和 Ubuntu 24.04 的输出与评论中建议的选项 -j1 和 V=1 进行比较。在 Ubuntu 24.04 上,很早以前,我有一个额外的编译行:
set -e; : ' CHK include/config/kernel.release'; mkdir -p include/config/; echo "4.4.71$(/bin/bash ./scripts/setlocalversion .)" < include/config/auto.conf > include/config/kernel.release.tmp; if [ -r include/config/kernel.release ] && cmp -s include/config/kernel.release include/config/kernel.release.tmp; then rm -f include/config/kernel.release.tmp; else : ' UPD include/config/kernel.release'; mv -f include/config/kernel.release.tmp include/config/kernel.release; fi
make -f ./scripts/Makefile.asm-generic \
src=asm obj=arch/arm64/include/generated/asm
make -f ./scripts/Makefile.asm-generic \
src=uapi/asm obj=arch/arm64/include/generated/uapi/asm
set -e; : ' CHK include/generated/uapi/linux/version.h'; mkdir -p include/generated/uapi/linux/; (echo \#define LINUX_VERSION_CODE 263239; echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) < Makefile > include/generated/uapi/linux/version.h.tmp; if [ -r include/generated/uapi/linux/version.h ] && cmp -s include/generated/uapi/linux/version.h include/generated/uapi/linux/version.h.tmp; then rm -f include/generated/uapi/linux/version.h.tmp; else : ' UPD include/generated/uapi/linux/version.h'; mv -f include/generated/uapi/linux/version.h.tmp include/generated/uapi/linux/version.h; fi
rm -f include/linux/version.h
set -e; : ' CHK include/generated/utsrelease.h'; mkdir -p include/generated/; if [ `echo -n "4.4.71-00005-g2fc62ed91813-dirty" | wc -c ` -gt 64 ]; then echo '"4.4.71-00005-g2fc62ed91813-dirty" exceeds 64 characters' >&2; exit 1; fi; (echo \#define UTS_RELEASE \"4.4.71-00005-g2fc62ed91813-dirty\";) < include/config/kernel.release > include/generated/utsrelease.h.tmp; if [ -r include/generated/utsrelease.h ] && cmp -s include/generated/utsrelease.h include/generated/utsrelease.h.tmp; then rm -f include/generated/utsrelease.h.tmp; else : ' UPD include/generated/utsrelease.h'; mv -f include/generated/utsrelease.h.tmp include/generated/utsrelease.h; fi
mkdir -p .tmp_versions ; rm -f .tmp_versions/*
make -f ./scripts/Makefile.build obj=scripts/basic
(cat /dev/null; ) > scripts/basic/modules.order
rm -f .tmp_quiet_recordmcount
make -f ./scripts/Makefile.build obj=.
(cat /dev/null; ) > modules.order
mkdir -p kernel/
此编译行仅存在于 Ubuntu 24.04:
aarch64-linux-gnu-gcc -Wp,-MD,kernel/.bounds.s.d -nostdinc -isystem /home/gregoire/tmp-inout/gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/5.3.1/include -I./arch/arm64/include -Iarch/arm64/include/generated/uapi -Iarch/arm64/include/generated -Iinclude -I./arch/arm64/include/uapi -Iarch/arm64/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mgeneral-regs-only -DCONFIG_AS_LSE=1 -mpc-relative-literal-loads -fno-delete-null-pointer-checks -Wno-maybe-uninitialized -Os --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(bounds)" -D"KBUILD_MODNAME=KBUILD_STR(bounds)" -fverbose-asm -S -o kernel/bounds.s kernel/bounds.c
下一行在两个环境中是相同的:
set -e; : ' CHK include/generated/bounds.h'; mkdir -p include/generated/; (set -e; echo "#ifndef __LINUX_BOUNDS_H__"; echo "#define __LINUX_BOUNDS_H__"; echo "/*"; echo " * DO NOT MODIFY."; echo " *"; echo " * This file was generated by Kbuild"; echo " */"; echo ""; sed -ne "/^->/{s:->#\(.*\):/* \1 */:; s:^->\([^ ]*\) [\$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; echo ""; echo "#endif" ) < kernel/bounds.s > include/generated/bounds.h.tmp; if [ -r include/generated/bounds.h ] && cmp -s include/generated/bounds.h include/generated/bounds.h.tmp; then rm -f include/generated/bounds.h.tmp; else : ' UPD include/generated/bounds.h'; mv -f include/generated/bounds.h.tmp include/generated/bounds.h; fi
在 Ubuntu 24.04 上,我有:
Ubuntu 24.04:
File: kernel/bounds.c
Size: 703 Blocks: 8 IO Block: 4096 regular file
Device: 259,2 Inode: 14559530 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/gregoire) Gid: ( 1000/gregoire)
Access: 2024-05-14 10:05:28.629197631 -0700
Modify: 2017-09-23 09:19:33.558726253 -0700
Change: 2024-05-07 15:44:11.170012538 -0700
Birth: 2024-04-26 08:54:22.911042385 -0700
File: kernel/bounds.s
Size: 14617 Blocks: 32 IO Block: 4096 regular file
Device: 259,2 Inode: 14559336 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/gregoire) Gid: ( 1000/gregoire)
Access: 2024-05-14 10:26:03.478134345 -0700
Modify: 2024-05-14 10:26:03.467134218 -0700
Change: 2024-05-14 10:26:03.467134218 -0700
Birth: 2024-05-04 21:27:59.503527455 -0700
至于文件系统:
Ubuntu 24.04:
/dev/nvme0n1p2 on / type ext4 (rw,relatime,stripe=32)
Ubuntu 20.04:
/dev/sda5 on / type ext4 (rw,relatime,errors=remount-ro)