Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux内核模块编译 #1923

Closed
zt449569708 opened this issue Dec 17, 2021 · 48 comments
Closed

linux内核模块编译 #1923

zt449569708 opened this issue Dec 17, 2021 · 48 comments
Milestone

Comments

@zt449569708
Copy link

看了新发布的2.6.2介绍,支持linux内核模块编译,但是内核以及相关的工具都是从网上去拉取。而对于嵌入式场景,内核是定制化的,源码都在本地,并且相应的环境也是搭建好的,所以是否可以支持指定本地内核源码路径来编译内核模块?

@waruqi
Copy link
Member

waruqi commented Dec 18, 2021

你可以覆盖内置的 linux-headers 重写路径指向你的源码路径

package("linux-headers")
    on_fetch(function (package, opt)
        return {includedirs = "/usr/src/linux-headers-5.0/include"}
    end)
package_end()

add_requires("linux-headers")

target("test")
    add_rules("platform.linux.driver")
    add_rules("src/*.c")
    add_packages("linux-headers")

@waruqi
Copy link
Member

waruqi commented Dec 18, 2021

刚改进了下,可以更加简单的传递自己的路径,如果不走包模式的话。

target("hello")
    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "/usr/src/linux-headers-5.11.0-41-generic")

我们也可以通过定义 option 选项,将 linux-headers 路径作为 xmake f --linux-headers=/usr/src/linux-headers 的方式传入。

option("linux-headers", {showmenu = true, description = "Set linux-headers path."})
target("hello")
    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "$(linux-headers)")

@waruqi waruqi added improvement and removed bug labels Dec 18, 2021
@waruqi waruqi added this to the v2.6.3 milestone Dec 18, 2021
@zt449569708
Copy link
Author

问题:在命令行里面我只传入平台参数xmake f -p arm64,然后在xmake.lua文件里面去指定架构,如图:
1639965680666

然后出现如下错误:如图,
1639965757699
从图中可以看出,编译用的gcc不对

@waruqi
Copy link
Member

waruqi commented Dec 20, 2021

仔细看下文档 examples 。。指定 cross 平台

https://xmake.io/#/zh-cn/guide/project_examples?id=%e4%ba%a4%e5%8f%89%e7%bc%96%e8%af%91

@zt449569708
Copy link
Author

1.通过命令行的方式,xmake f -p cross -a arm64 --sdk=.....是可以找到正确交叉编译链的。但是编译的时候,会提示很多警告和错误,但是我用makefile就不会有问题。部分错误截图:
1639984401948

2.其实很多时候,一个驱动可能用于多个平台,如果编译内核模块,还是和编译应用一样,可以把交叉编译配置写到xmake.lua文件就好了,并且-p 可以切换,如上午评论里图片的写法:
Screenshot_20211220_152232

@waruqi
Copy link
Member

waruqi commented Dec 22, 2021

1.通过命令行的方式,xmake f -p cross -a arm64 --sdk=.....是可以找到正确交叉编译链的。但是编译的时候,会提示很多警告和错误,但是我用makefile就不会有问题。部分错误截图:

我只在在 linux kernel 5.x 上测过,回头其他版本测下

2.其实很多时候,一个驱动可能用于多个平台,如果编译内核模块,还是和编译应用一样,可以把交叉编译配置写到xmake.lua文件就好了,并且-p 可以切换,如上午评论里图片的写法:

那也应改是切工具连,而不是平台,-p cross --toolchain=xxx

@waruqi
Copy link
Member

waruqi commented Dec 22, 2021

不过你那么配置应该也是可以的,只是 driver 那个 rule 内部 on_load 里面提前取了 toolchain 导致交叉工具链获取失效了。。这块回头有空可以改进下。。

@waruqi
Copy link
Member

waruqi commented Dec 22, 2021

我改进了下 可以更新到 dev再试试

@zt449569708
Copy link
Author

我改进了下 可以更新到 dev再试试

这个试了可以,谢谢。然后就是,我验证了一下其他的架构,目前不支持mips和powerpc,这个后面可以支持么?

@zt449569708
Copy link
Author

我改进了下 可以更新到 dev再试试

这个试了可以,谢谢。然后就是,我验证了一下mips和powerpc的架构,提示不支持,这个后面可以支持么?

@waruqi
Copy link
Member

waruqi commented Dec 23, 2021

我改进了下 可以更新到 dev再试试

这个试了可以,谢谢。然后就是,我验证了一下mips和powerpc的架构,提示不支持,这个后面可以支持么?

我暂时没工具链和环境测试,最近也没空搞了,你可以直接提个 pr 过来

https://github.com/xmake-io/xmake/blob/master/xmake/rules/platform/linux/driver/driver_modules.lua

里面对其他 arch 判断下就行了

@waruqi
Copy link
Member

waruqi commented Dec 24, 2021

mips powerpc 加上了

@waruqi waruqi closed this as completed Dec 24, 2021
@zt449569708
Copy link
Author

不要意思,pr以前没弄过,本来想的周末有时间学习下,来弄这个mips和powerpc的pr。然后就是今天发现有以下问题,然后记录了一下。

xmake编译内核模块错误记录

这里通过两种编译方式来说明,第一种是在xmake.lua里面配置架构和交叉编译链,第二种是通过命令行传递的方式,两种方式都用同一xmake.lua文件,然后测试代码为xmake里面的hello例子,内核源码为4.19。

toolchain("gcc-arm32")
    set_kind("standalone")
    set_sdkdir("/opt/gcc-arm")
toolchain_end()

if is_plat("arm32") then
    set_toolchains("gcc-arm32")
    set_arch("arm")
end


target("hello")
    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "../linux-xlnx")
    set_license("GPL-2.0")

第一种:

命令行输入xmake f -p arm32 -c,然后再输入xmake -v,编译出来的部分错误信息如下:

image-20211225115138125

第二种:

1、命令行输入xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,然后再输入xmake -v,编译出来的部分错误信息如下:

image-20211225115053786

2、改一下xmake.lua里面的内核路径,使用绝对路径,再次使用xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,然后再输入xmake -v,编译结果如下:(使用第一种编译方法的时候,改成绝对路径,错误还是和相对路径一样的)
image-20211225115756636

@waruqi
Copy link
Member

waruqi commented Dec 29, 2021

前两图只有一些警告,没看到具体错误,最后一个问题,我改进了下,应该可以了,更新下再试试

@zt449569708
Copy link
Author

前两图只有一些警告,没看到具体错误,最后一个问题,我改进了下,应该可以了,更新下再试试

其实错误就是我以前发的图片的错误,其实我想说明的是,前两个图片的编译和后最后一个图片的编译区别很大,最后一个图片的编译有很多编译属性的,但是前两个就没有。所以说,前两个图片编译出错,是不是就是因为缺少这些编译属性导致的。

@waruqi
Copy link
Member

waruqi commented Dec 29, 2021

最好给完整编译错误,完整执行命令,以及详细输出还有完整 xmake.lua 配置,不要图片,否则不好查问题,我都不知道到底那个问题对哪个。。另外最后一个问题 刚修复的,请确认下

@zt449569708
Copy link
Author

最好给完整编译错误,完整执行命令,以及详细输出还有完整 xmake.lua 配置,不要图片,否则不好查问题,我都不知道到底那个问题对哪个。。另外最后一个问题 刚修复的,请确认下

好的,那我晚上把整个日志附上

@zt449569708
Copy link
Author

xmake内核编译错误记录

这里通过两种编译方式来说明,第一种是在xmake.lua里面配置架构和交叉编译链,第二种是通过命令行传递的方式,两种方式都用同一xmake.lua文件,然后测试代码为xmake里面的hello例子,内核源码为4.19。xmake.lua如下:

toolchain("gcc-arm32")
    set_kind("standalone")
    set_sdkdir("/opt/gcc-arm")
toolchain_end()

if is_plat("arm32") then
    set_toolchains("gcc-arm32")
    set_arch("arm")
end


target("hello")
    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "../linux-xlnx")
    set_license("GPL-2.0")

第一种方法

命令行输入xmake f -p arm32 -c,然后再输入xmake -v,编译出来的错误日志如下:

1.txt

第二种方法

1、命令行输入xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,然后再输入xmake -v,编译出来的错误日志如下:

3.txt

2、改一下xmake.lua里面的内核路径,使用绝对路径,再次使用xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,然后再输入xmake -v,编译结果如下:(使用第一种编译方法的时候,改成绝对路径,错误还是和相对路径一样的)
2.txt

@waruqi
Copy link
Member

waruqi commented Dec 30, 2021

set_values("linux.driver.linux-headers", "../linux-xlnx")

第一,第二种,你都用了相对路径,不是这么设置的,目前只有 add_files add_headerfiles 此类路径接口,才支持基于当前 xmake.lua 的相对路径,内部会给你做自动路径变换,生成正确的绝对路径。。

但是 其他设置接口,只会把它当做 string 直接传入编译器,所以如果编译器执行的当前路径变动都会导致失败。。

你得改成:

set_values("linux.driver.linux-headers", os.join(os.scriptdir(), "..", "linux-xlnx"))

来设置基于当前脚本路径,或者干脆基于工程根目录

set_values("linux.driver.linux-headers", "$(projectdir)/linux-xlnx")

2、改一下xmake.lua里面的内核路径,使用绝对路径,再次使用xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,然后再输入xmake -v,编译结果如下:(使用第一种编译方法的时候,改成绝对路径,错误还是和相对路径一样的)

这个我没看到完整 link output ,按理 -v 应该会输出 link args 才对。。看到了,我才能知道哪里有问题

或者你切到 makefile 版本,给我一份带 verbose 的完整输出。。我对下 flags

@waruqi
Copy link
Member

waruqi commented Dec 31, 2021

关于最后那个问题,我大概知道原因,但是没有 4.x 的 kernel 。。你这整个 hello module makefile ,开下 V=1 然后切到你的 kernel 上去,执行后,给我一份完整的输出,我需要分析后才能做改进

或者用这个 module demo 切到 makefile 上开下 V=1

https://github.com/xmake-io/xmake/blob/master/tests/projects/linux/driver/hello_makefile/Makefile

@zt449569708
Copy link
Author

通过Makefile编译的日志如下:
4.txt

@waruqi
Copy link
Member

waruqi commented Jan 1, 2022

我改进过了 再试试

@zt449569708
Copy link
Author

xmake update -s master到最新,还是有问题,错误如下,看ld的地方,感觉像是没有链接脚本:

zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ xmake f -p cross -a arm --sdk=/opt/gcc-arm -c
zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ 
zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ 
zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ 
zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ xmake -v
checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc ... ok
checking for flags (-fPIC) ... ok
checking for ccache ... /usr/bin/ccache
[ 20%]: ccache compiling.release src/hello.c
/usr/bin/ccache /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -c -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/generated/uapi -DKBUILD_MODNAME=\"hello\" -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/kconfig.h -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME=\"hello\" -o build/.objs/hello/cross/arm/release/src/hello.c.o src/hello.c
[ 20%]: ccache compiling.release src/add.c
/usr/bin/ccache /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -c -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/generated/uapi -DKBUILD_MODNAME=\"hello\" -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/kconfig.h -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME=\"add\" -o build/.objs/hello/cross/arm/release/src/add.c.o src/add.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for arm-none-linux-gnueabihf-g++ ... /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++
checking for the linker (ld) ... arm-none-linux-gnueabihf-g++
checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++ ... ok
checking for flags (-fPIC) ... ok
[ 60%]: linking.release build/cross/arm/release/hello.ko
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/src/hello.c.o build/.objs/hello/cross/arm/release/src/add.c.o
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000010094
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o: in function `init_module':
hello.c:(.text+0x20): undefined reference to `printk'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o: in function `cleanup_module':
hello.c:(.text+0x3c): undefined reference to `printk'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/add.c.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
error: execv(/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/src/hello.c.o build/.objs/hello/cross/arm/release/src/add.c.o) failed(1)

@waruqi
Copy link
Member

waruqi commented Jan 1, 2022

怪了,按理应该可以了,你更新到 test 分支,再给我一份 -v 的输出,我看下。。xmake update -s github:xmake-io/xmake#test

@zt449569708
Copy link
Author

xmake update -s github:xmake-io/xmake#test 操作之后,xmake -v结果如下:

zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ xmake -v
line:  make: Entering directory '/home/zhangting/workspace/project/xmaketest/linux-xlnx'
ldflags: 
line:  test -e include/generated/autoconf.h -a -e include/config/auto.conf || (		\
ldflags: 
line:  echo >&2;							\
ldflags: 
line:  echo >&2 "  ERROR: Kernel configuration is invalid.";		\
ldflags: 
line:  echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
ldflags: 
line:  echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";	\
ldflags: 
line:  echo >&2 ;							\
ldflags: 
line:  /bin/false)
ldflags: 
line:  mkdir -p /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.tmp_versions ; rm -f /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.tmp_versions/*
ldflags: 
line:  /usr/bin/make -f ./scripts/Makefile.build obj=/dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir
ldflags: 
line:  (cat /dev/null;   echo kernel//dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.ko;) > /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/modules.order
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -Wp,-MD,/dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.stub.o.d  -nostdinc -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned  -DMODULE  -DKBUILD_BASENAME='"stub"' -DKBUILD_MODNAME='"stub"' -c -o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.tmp_stub.o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.c
ldflags: 
line:  /usr/bin/make -f ./scripts/Makefile.modpost
ldflags: 
line:    find /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.tmp_versions -name '*.mod' | xargs -r grep -h '\.ko$' | sort -u | sed 's/\.ko$/.o/' | scripts/mod/modpost -m  -i ./Module.symvers -I /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/Module.symvers  -o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/Module.symvers -S  -w  -s -T -
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -Wp,-MD,/dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/.stub.mod.o.d  -nostdinc -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned  -DKBUILD_BASENAME='"stub.mod"' -DKBUILD_MODNAME='"stub"' -DMODULE  -c -o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.mod.o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.mod.c
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -r  -EL -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds  --build-id  -o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.ko /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.o /dev/shm/.xmake1000/220101/_0253968D37C54F208C678520696F1260.dir/stub.mod.o ;  true
ldflags:  -r  -EL -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds  --build-id 
ko:  9
 > ldflag:  -r
 > ldflag ko:  -r
 > ldflag:  -EL
 > ldflag ko:  -EL
 > ldflag:  -T
 > ldflag ko:  -T
 > ldflag:  ./scripts/module-common.lds
 > ldflag ko:  /home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds
 > ldflag:  -T
 > ldflag ko:  -T
 > ldflag:  ./arch/arm/kernel/module.lds
 > ldflag ko:  /home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds
 > ldflag:  --build-id
 > ldflag ko:  --build-id
line:  make: Leaving directory '/home/zhangting/workspace/project/xmaketest/linux-xlnx'
ldflags: 
ldflags_ko { 
  "-r",
  "-EL",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds",
  "--build-id" 
}

checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc ... ok
checking for flags (-fPIC) ... ok
checking for ccache ... /usr/bin/ccache
[ 20%]: ccache compiling.release src/hello.c
/usr/bin/ccache /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -c -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/generated/uapi -DKBUILD_MODNAME=\"hello\" -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/kconfig.h -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME=\"hello\" -o build/.objs/hello/cross/arm/release/src/hello.c.o src/hello.c
[ 20%]: ccache compiling.release src/add.c
/usr/bin/ccache /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -c -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/generated/uapi -DKBUILD_MODNAME=\"hello\" -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/kconfig.h -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME=\"add\" -o build/.objs/hello/cross/arm/release/src/add.c.o src/add.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for arm-none-linux-gnueabihf-g++ ... /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++
checking for the linker (ld) ... arm-none-linux-gnueabihf-g++
checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++ ... ok
checking for flags (-fPIC) ... ok
[ 60%]: linking.release build/cross/arm/release/hello.ko
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/src/hello.c.o build/.objs/hello/cross/arm/release/src/add.c.o
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000010094
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o: in function `init_module':
hello.c:(.text+0x20): undefined reference to `printk'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o: in function `cleanup_module':
hello.c:(.text+0x3c): undefined reference to `printk'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/hello.c.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld: build/.objs/hello/cross/arm/release/src/add.c.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
error: execv(/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/src/hello.c.o build/.objs/hello/cross/arm/release/src/add.c.o) failed(1)
zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ 

@waruqi
Copy link
Member

waruqi commented Jan 1, 2022

我改了下,再更新下 test 分支给我一份 log

@zt449569708
Copy link
Author

更新之后,通过xmake f -p cross -a arm --sdk=/opt/gcc-arm -c,编译成功了。

zhangting@zhangting-ubuntu:~/workspace/project/xmaketest/hello$ xmake -v
line:  make: Entering directory '/home/zhangting/workspace/project/xmaketest/linux-xlnx'
ldflags: 
line:  test -e include/generated/autoconf.h -a -e include/config/auto.conf || (		\
ldflags: 
line:  echo >&2;							\
ldflags: 
line:  echo >&2 "  ERROR: Kernel configuration is invalid.";		\
ldflags: 
line:  echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
ldflags: 
line:  echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";	\
ldflags: 
line:  echo >&2 ;							\
ldflags: 
line:  /bin/false)
ldflags: 
line:  mkdir -p /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/.tmp_versions ; rm -f /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/.tmp_versions/*
ldflags: 
line:  /usr/bin/make -f ./scripts/Makefile.build obj=/dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir
ldflags: 
line:  (cat /dev/null;   echo kernel//dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.ko;) > /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/modules.order
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -Wp,-MD,/dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/.stub.o.d  -nostdinc -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned  -DMODULE  -DKBUILD_BASENAME='"stub"' -DKBUILD_MODNAME='"stub"' -c -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/.tmp_stub.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/stub.c
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -Wp,-MD,/dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/.foo.o.d  -nostdinc -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned  -DMODULE  -DKBUILD_BASENAME='"foo"' -DKBUILD_MODNAME='"stub"' -c -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/.tmp_foo.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/foo.c
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld  -EL    -r -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/stub.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/src/foo.o 
ldflags:   -EL    -r
ko: 
 > ldflag:  -EL
 > ldflag:  -r
line:  /usr/bin/make -f ./scripts/Makefile.modpost
ldflags: 
line:    find /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/.tmp_versions -name '*.mod' | xargs -r grep -h '\.ko$' | sort -u | sed 's/\.ko$/.o/' | scripts/mod/modpost -m  -i ./Module.symvers -I /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/Module.symvers  -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/Module.symvers -S  -w  -s -T -
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -Wp,-MD,/dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/.stub.mod.o.d  -nostdinc -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -I./arch/arm/include -I./arch/arm/include/generated  -I./include -I./arch/arm/include/uapi -I./arch/arm/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned  -DKBUILD_BASENAME='"stub.mod"' -DKBUILD_MODNAME='"stub"' -DMODULE  -c -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.mod.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.mod.c
ldflags: 
line:    /opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -r  -EL -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds  --build-id  -o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.ko /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.o /dev/shm/.xmake1000/220102/_5E6CEA7765AA4010812ECB9904987720.dir/stub.mod.o ;  true
ldflags:  -r  -EL -T ./scripts/module-common.lds -T ./arch/arm/kernel/module.lds  --build-id 
ko:  9
 > ldflag:  -r
 > ldflag ko:  -r
 > ldflag:  -EL
 > ldflag ko:  -EL
 > ldflag:  -T
 > ldflag ko:  -T
 > ldflag:  ./scripts/module-common.lds
 > ldflag ko:  /home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds
 > ldflag:  -T
 > ldflag ko:  -T
 > ldflag:  ./arch/arm/kernel/module.lds
 > ldflag ko:  /home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds
 > ldflag:  --build-id
 > ldflag ko:  --build-id
ldflags_o { 
  "-EL",
  "-r" 
}

ldflags_ko { 
  "-r",
  "-EL",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds",
  "--build-id" 
}

checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc ... ok
checking for flags (-fPIC) ... ok
checking for arm-none-linux-gnueabihf-g++ ... /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++
checking for the linker (ld) ... arm-none-linux-gnueabihf-g++
checking for /opt/gcc-arm/bin/arm-none-linux-gnueabihf-g++ ... ok
checking for flags (-fPIC) ... ok
[ 60%]: linking.release build/cross/arm/release/hello.ko
/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -EL -r -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/src/hello.c.o build/.objs/hello/cross/arm/release/src/add.c.o
/home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/mod/modpost -m -a -o build/.objs/hello/cross/arm/release/build/cross/arm/release/Module.symvers -e -N -T -
checking for ccache ... /usr/bin/ccache
/usr/bin/ccache /opt/gcc-arm/bin/arm-none-linux-gnueabihf-gcc -c -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/include/generated/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/uapi -I/home/zhangting/workspace/project/xmaketest/linux-xlnx/include/generated/uapi -DKBUILD_MODNAME=\"hello\" -isystem /opt/gcc-arm/bin/../lib/gcc/arm-none-linux-gnueabihf/9.2.1/include -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/kconfig.h -include /home/zhangting/workspace/project/xmaketest/linux-xlnx/include/linux/compiler_types.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -fno-PIE -DCC_HAVE_ASM_GOTO -fno-dwarf2-cfi-asm -fno-ipa-sra -mabi=aapcs-linux -mfpu=vfp -funwind-tables -marm -Wa,-mno-warn-deprecated -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-float -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Wno-maybe-uninitialized -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -Wno-stringop-truncation -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=./= -Wno-packed-not-aligned -DMODULE -o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.mod.o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.mod.c
checking for flags (-fdiagnostics-color=always) ... ok
get ldflags_ko { 
  "-r",
  "-EL",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds",
  "--build-id" 
}

{ 
  "-r",
  "-EL",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds",
  "-T",
  "/home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds",
  "--build-id",
  "-o",
  "build/cross/arm/release/hello.ko",
  "build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o",
  "build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.mod.o" 
}

/opt/gcc-arm/bin/arm-none-linux-gnueabihf-ld -r -EL -T /home/zhangting/workspace/project/xmaketest/linux-xlnx/scripts/module-common.lds -T /home/zhangting/workspace/project/xmaketest/linux-xlnx/arch/arm/kernel/module.lds --build-id -o build/cross/arm/release/hello.ko build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.o build/.objs/hello/cross/arm/release/build/cross/arm/release/hello.ko.mod.o
[100%]: build ok!


但是通过xmake f -p arm32 -c的方式编不通过,错误还是和以前一样的。

@waruqi
Copy link
Member

waruqi commented Jan 2, 2022

但是通过xmake f -p arm32 -c的方式编不通过,错误还是和以前一样的。

凡事先贴完整输出和错误,我哪知道是以前的哪个错误

@zt449569708
Copy link
Author

好的,错误如下:
1.txt

@waruqi
Copy link
Member

waruqi commented Jan 2, 2022

加了点 log 再更新下 test 分支,给我个完整输出

@zt449569708
Copy link
Author

ok,更新后输出日志如下:
1.txt

我有个疑问,想请教一下:xmake里面编译内核模块,是通过解析内核源码的Makefile来实现的,还是说通过Makefile编译的make V=1的输出信息来适配的。假如说是通过make V=1来不停地去适配不同的内核版本,感觉这个方向就有点偏了,后面可能就是不停的去适配内核版本了。

@waruqi
Copy link
Member

waruqi commented Jan 2, 2022

改了下,在更新下 test 试试,如果还是不行,再给份输出

我有个疑问,想请教一下:xmake里面编译内核模块,是通过解析内核源码的Makefile来实现的,还是说通过Makefile编译的make V=1的输出信息来适配的。假如说是通过make V=1来不停地去适配不同的内核版本,感觉这个方向就有点偏了,后面可能就是不停的去适配内核版本了。

分析的 make V=1 ,这反而是兼容性最好的方案,只要迭代几个版本,基本就能完全稳定。。

现在因为是初步支持,之前的实现逻辑,还存在一些硬编码,所以才会有些问题,最近几次改进,已经删除这部分硬编码 flags,完全适配 make V=1 输出,所以兼容性更好了。。

而你现在最后一个问题,也跟这个没啥关系,是你 -p arm64,设置的平台不符合我当初的要求, 没设置我之前需要的 cross 平台,所以内部仅判断 cross plat 导致的问题,跟解析 V=1 没任何关系

所以,目前的方案是最不会根据 kernel 版本做各种适配的,兼容性最好。。

而且,其他也没更好的方案:

  1. 如果走 makefile 解析,兼容性只会更差,即使 kernel 版本固定,也需要解析不同 configs 下的各种状态条件下 flags 变动,而且解析更复杂,会存在更多的硬编码。。
  2. 之前走过不依赖 make,全硬编码适配 flags,也完全不行

如果你有更好的方案,可以提出来,但是我目前想到的,就当前这个最好,而且现在跟你调的各种问题,也跟kernel版本兼容性无关,都是其他地方的问题,以及原本解析逻辑存在的问题修复而已。

@zt449569708
Copy link
Author

改了下,在更新下 test 试试,如果还是不行,再给份输出

我有个疑问,想请教一下:xmake里面编译内核模块,是通过解析内核源码的Makefile来实现的,还是说通过Makefile编译的make V=1的输出信息来适配的。假如说是通过make V=1来不停地去适配不同的内核版本,感觉这个方向就有点偏了,后面可能就是不停的去适配内核版本了。

分析的 make V=1 ,这反而是兼容性最好的方案,只要迭代几个版本,基本就能完全稳定。。

现在因为是初步支持,之前的实现逻辑,还存在一些硬编码,所以才会有些问题,最近几次改进,已经删除这部分硬编码 flags,完全适配 make V=1 输出,所以兼容性更好了。。

而你现在最后一个问题,也跟这个没啥关系,是你 -p arm64,设置的平台不符合我当初的要求, 没设置我之前需要的 cross 平台,所以内部仅判断 cross plat 导致的问题,跟解析 V=1 没任何关系

所以,目前的方案是最不会根据 kernel 版本做各种适配的,兼容性最好。。

而且,其他也没更好的方案:

1. 如果走 makefile 解析,兼容性只会更差,即使 kernel 版本固定,也需要解析不同 configs 下的各种状态条件下 flags 变动,而且解析更复杂,会存在更多的硬编码。。

2. 之前走过不依赖 make,全硬编码适配 flags,也完全不行

如果你有更好的方案,可以提出来,但是我目前想到的,就当前这个最好,而且现在跟你调的各种问题,也跟kernel版本兼容性无关,都是其他地方的问题,以及原本解析逻辑存在的问题修复而已。

新改的可以通过xmake f -p arm32 -c编译过了,谢谢了。。。。我也没有好的方案,只是这几天通过这些问题,有了一些疑问,所以问一下,了解一下。

@waruqi
Copy link
Member

waruqi commented Jan 4, 2022

那你更新到 dev 分支吧,昨天已经同步过去了 这些改动

@zt449569708
Copy link
Author

换了个平台龙芯2K的,内核是3.10版本,gcc是4.9.3,xmake.lua如下:

toolchain("gcc-arm32")
    set_kind("standalone")
    set_sdkdir("/opt/gcc-arm")
toolchain_end()

toolchain("gcc-mips")
    set_kind("standalone")
    set_sdkdir("/opt/gcc-4.9.3-64-gnu64")
toolchain_end()

if is_plat("arm32") then
    set_toolchains("gcc-arm32")
    set_arch("arm")
    set_values("linux.driver.linux-headers", "/home/zhangting/workspace/project/xmaketest/linux-xlnx")
end

if is_plat("ls2k") then
    set_toolchains("gcc-mips")
    set_arch("mips")
    set_values("linux.driver.linux-headers", "/home/zhangting/workspace/project/sh-ls2k/linux-3.10")
end

target("hello")
    add_rules("platform.linux.driver")
    add_files("src/*.c")
--    set_values("linux.driver.linux-headers", "/home/zhangting/workspace/project/xmaketest/linux-xlnx")
    set_license("GPL-2.0")

通过xmake f -p ls2k -c,错误日志如下:

1.txt

通过Makefile,日志如下:

2.txt

@waruqi
Copy link
Member

waruqi commented Jan 4, 2022

2.txt 下载不了

@zt449569708
Copy link
Author

2.txt 下载不了

可能是这个github总是网络访问出问题,我重新上传2.txt。
2.txt

@waruqi
Copy link
Member

waruqi commented Jan 4, 2022

现在这个问题是由于 includedirs 我目前还没走 make V=1 提取,还是尝试硬编码自己拼的路径列表,原本以为不同 kernel 下差异不会太大,所以没去动。。看来也要全走 make V=1 才能自动适配不同 kernel 版本的 includedirs 路径。。

我明天抽空也改下就好了。

@waruqi
Copy link
Member

waruqi commented Jan 5, 2022

我 dev 改过了,全走 V=1 提取了,再试试,xmake update -s github:xmake-io/xmake#dev

@zt449569708
Copy link
Author

还是有点问题,错误如下:
图片

@waruqi
Copy link
Member

waruqi commented Jan 5, 2022

再给个 make V=1的输出给我看下呢

@zt449569708
Copy link
Author

好的,日志如下:
1.txt

@waruqi
Copy link
Member

waruqi commented Jan 5, 2022

再试试

@zt449569708
Copy link
Author

先通过xmake update -s github:xmake-io/xmake#dev更新,然后编译,还是有错误,如下:
图片

@waruqi
Copy link
Member

waruqi commented Jan 5, 2022

再试试

@zt449569708
Copy link
Author

可以了,谢谢

@wangzhankun
Copy link
Contributor

我正在编译一个helloworld的Linux驱动但是遇到了很多问题。

环境

  • ubuntu 22.04
  • 5.15.0-57-generic
  • gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
  • xmake v2.7.3+HEAD.b35ff31

第一种配置文件无法正常安装

add_requires("linux-headers")



target("hello")
    -- add_includedirs("/usr/src/linux-headers-5.15.0-57/include",
    --     "/usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated", 
    --     "/usr/src/linux-headers-5.15.0-57/arch/x86/include"
    -- )

    add_rules("platform.linux.driver")
    add_files("src/*.c")
    -- set_values("linux.driver.linux-headers", "/usr/src/linux-headers-5.15.0-57/include")
    add_packages("linux-headers")
    -- set_license("GPL-2.0")
[ 25%]: cache compiling.release src/main.c
/usr/bin/gcc -c -DKBUILD_MODNAME=\"hello\" -isystem /usr/lib/gcc/x86_64-linux-gnu/11/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/generated -I/usr/src/linux-headers-5.11.10-051110-generic/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/include/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/include/generated/uapi -include /usr/src/linux-headers-5.11.10-051110-generic/include/linux/kconfig.h -include /usr/src/linux-headers-5.11.10-051110-generic/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -fno-allow-store-data-races -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -DMODULE -DKBUILD_BASENAME=\"main\" -o build/.objs/hello/linux/x86_64/release/src/main.c.o src/main.c
[ 50%]: linking.release build/linux/x86_64/release/hello.ko
/usr/bin/ld -m elf_x86_64 -r -m elf_x86_64 -r -m elf_x86_64 -r -o build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/hello.ko.o build/.objs/hello/linux/x86_64/release/src/main.c.o
/usr/src/linux-headers-5.11.10-051110-generic/scripts/mod/modpost -m -a -o build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/Module.symvers -e -N -w -T -
WARNING: modpost: Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.
/usr/bin/gcc -c -DKBUILD_MODNAME=\"hello\" -isystem /usr/lib/gcc/x86_64-linux-gnu/11/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/generated -I/usr/src/linux-headers-5.11.10-051110-generic/include -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/arch/x86/include/generated/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/include/uapi -I/usr/src/linux-headers-5.11.10-051110-generic/include/generated/uapi -include /usr/src/linux-headers-5.11.10-051110-generic/include/linux/kconfig.h -include /usr/src/linux-headers-5.11.10-051110-generic/include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -DCONFIG_X86_X32_ABI -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -fno-allow-store-data-races -Wframe-larger-than=1024 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -mrecord-mcount -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -DMODULE -o build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/hello.ko.mod.o build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/hello.ko.mod.c
/usr/bin/ld -r -m elf_x86_64 --build-id=sha1 -T /usr/src/linux-headers-5.11.10-051110-generic/scripts/module.lds -o build/linux/x86_64/release/hello.ko build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/hello.ko.o build/.objs/hello/linux/x86_64/release/build/linux/x86_64/release/hello.ko.mod.o
[100%]: build ok!

使用insmod安装报错如下

insmod: ERROR: could not insert module build/linux/x86_64/release/hello.ko: Unknown symbol in module

第二种配置无法找到头文件

add_requires("linux-headers", {configs = {driver_modules = true}})

package("linux-headers")
    on_fetch(function (package, opt)
        return {includedirs = "/usr/src/linux-headers-5.15.0-57/include"}
    end)
package_end()

add_requires("linux-headers")



target("hello")
    -- add_includedirs("/usr/src/linux-headers-5.15.0-57/include",
    --     "/usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated", 
    --     "/usr/src/linux-headers-5.15.0-57/arch/x86/include"
    -- )

    add_rules("platform.linux.driver")
    add_files("src/*.c")
    -- set_values("linux.driver.linux-headers", "/usr/src/linux-headers-5.15.0-57/include")
    add_packages("linux-headers")
    -- set_license("GPL-2.0")
checking for gcc ... /usr/bin/gcc
checking for dmd ... no
checking for ldc2 ... no
checking for gdc ... no
checking for zig ... no
checking for zig ... no
checking for unzip ... /usr/bin/unzip
checking for git ... /usr/bin/git
checking for gzip ... /usr/bin/gzip
checking for tar ... /usr/bin/tar
checking for ::linux-headers ... linux-headers 
error: kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing.

而该文件是存在的,/usr/src/linux-headers-5.15.0-57-generic/include/generated/autoconf.h。即使我添加了该路径add_includedirs("/usr/src/linux-headers-5.15.0-57-generic")依然是无法找到该文件。

第三种配置,头文件丢失

target("hello")
    -- add_includedirs("/usr/src/linux-headers-5.15.0-57/include",
    --     "/usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated", 
    --     "/usr/src/linux-headers-5.15.0-57/arch/x86/include"
    -- )

    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "/usr/src/linux-headers-5.15.0-57/include")
    -- add_packages("linux-headers")
    -- set_license("GPL-2.0")
checking for gcc ... /usr/bin/gcc
checking for dmd ... no
checking for ldc2 ... no
checking for gdc ... no
checking for zig ... no
checking for zig ... no
checking for gcc ... /usr/bin/gcc
checking for the c compiler (cc) ... gcc
checking for make ... /usr/bin/make
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
[ 25%]: cache compiling.release src/main.c
/usr/bin/gcc -c -m64 -DKBUILD_MODNAME=\"hello\" -DKBUILD_BASENAME=\"main\" -o build/.objs/hello/linux/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
error: src/main.c:1:10: fatal error: linux/init.h: 没有那个文件或目录
    1 | #include <linux/init.h>
      |          ^~~~~~~~~~~~~~
compilation terminated.

即使我添加了头文件路径

target("hello")
    add_includedirs("/usr/src/linux-headers-5.15.0-57/include",
        "/usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated"
    )

    add_rules("platform.linux.driver")
    add_files("src/*.c")
    set_values("linux.driver.linux-headers", "/usr/src/linux-headers-5.15.0-57/include")

又会产生如下报错:

checking for gcc ... /usr/bin/gcc
checking for dmd ... no
checking for ldc2 ... no
checking for gdc ... no
checking for zig ... no
checking for zig ... no
checking for gcc ... /usr/bin/gcc
checking for the c compiler (cc) ... gcc
checking for make ... /usr/bin/make
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
[ 25%]: cache compiling.release src/main.c
/usr/bin/gcc -c -m64 -I/usr/src/linux-headers-5.15.0-57/include -I/usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated -DKBUILD_MODNAME=\"hello\" -DKBUILD_BASENAME=\"main\" -o build/.objs/hello/linux/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
error: In file included from /usr/src/linux-headers-5.15.0-57/include/linux/kcsan-checks.h:13,
                 from /usr/src/linux-headers-5.15.0-57/include/asm-generic/rwonce.h:27,
                 from /usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated/asm/rwonce.h:1,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/compiler.h:255,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/init.h:5,
                 from src/main.c:1:
/usr/src/linux-headers-5.15.0-57/include/linux/compiler_attributes.h:54: warning: "__always_inline" redefined
   54 | #define __always_inline                 inline __attribute__((__always_inline__))
      | 
In file included from /usr/src/linux-headers-5.15.0-57/include/linux/stddef.h:5,
                 from /usr/include/linux/posix_types.h:5,
                 from /usr/src/linux-headers-5.15.0-57/include/uapi/linux/types.h:14,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/types.h:6,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/kasan-checks.h:5,
                 from /usr/src/linux-headers-5.15.0-57/include/asm-generic/rwonce.h:26,
                 from /usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated/asm/rwonce.h:1,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/compiler.h:255,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/init.h:5,
                 from src/main.c:1:
/usr/src/linux-headers-5.15.0-57/include/uapi/linux/stddef.h:8: note: this is the location of the previous definition
    8 | #define __always_inline inline
      | 
In file included from /usr/src/linux-headers-5.15.0-57-generic/arch/x86/include/generated/asm/rwonce.h:1,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/compiler.h:255,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/init.h:5,
                 from src/main.c:1:
/usr/src/linux-headers-5.15.0-57/include/asm-generic/rwonce.h:64:31: error: expected ‘;’ before ‘unsigned’
   64 | static __no_sanitize_or_inline
      |                               ^
      |                               ;
   65 | unsigned long __read_once_word_nocheck(const void *addr)
      | ~~~~~~~~                       
/usr/src/linux-headers-5.15.0-57/include/asm-generic/rwonce.h:82:28: error: expected ‘;’ before ‘unsigned’
   82 | static __no_kasan_or_inline
      |                            ^
      |                            ;
   83 | unsigned long read_word_at_a_time(const void *addr)
      | ~~~~~~~~                    
In file included from /usr/src/linux-headers-5.15.0-57/include/linux/kernel.h:8,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/list.h:9,
                 from /usr/src/linux-headers-5.15.0-57/include/linux/module.h:12,
                 from src/main.c:2:
/usr/src/linux-headers-5.15.0-57/include/linux/linkage.h:8:10: fatal error: asm/linkage.h: 没有那个文件或目录
    8 | #include <asm/linkage.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.

@waruqi
Copy link
Member

waruqi commented Jan 11, 2023

新问题,单独开 issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants