martinezjavier / ldd3

Linux Device Drivers 3 examples updated to work in recent kernels
http://examples.oreilly.com/9780596005900/
Other
2.35k stars 905 forks source link

build error with Linux v5.9-rc8 #58

Closed michaelbaly closed 3 years ago

michaelbaly commented 3 years ago

mike@atel:~/git_rep/ldd3/sbull$ make make -C /home/mike/git_rep/linux M=/home/mike/git_rep/ldd3/sbull modules make[1]: Entering directory '/home/mike/git_rep/linux' CC [M] /home/mike/git_rep/ldd3/sbull/sbull.o /home/mike/git_rep/ldd3/sbull/sbull.c:94:25: error: unknown type name ‘make_request_fn’ blk_generic_alloc_queue(make_request_fn make_request, int node_id) ^ /home/mike/git_rep/ldd3/sbull/sbull.c:376:2: error: unknown field ‘media_changed’ specified in initializer .media_changed = sbull_media_changed, ^ /home/mike/git_rep/ldd3/sbull/sbull.c:376:21: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types] .media_changed = sbull_media_changed, ^ /home/mike/git_rep/ldd3/sbull/sbull.c:376:21: note: (near initialization for ‘sbull_ops.rw_page’) /home/mike/git_rep/ldd3/sbull/sbull.c: In function ‘setup_device’: /home/mike/git_rep/ldd3/sbull/sbull.c:426:17: error: implicit declaration of function ‘blk_generic_alloc_queue’ [-Werror=implicit-function-declaration] dev->queue = blk_generic_alloc_queue(sbull_make_request, NUMA_NO_NODE); ^ /home/mike/git_rep/ldd3/sbull/sbull.c:426:14: warning: assignment makes pointer from integer without a cast [-Wint-conversion] dev->queue = blk_generic_alloc_queue(sbull_make_request, NUMA_NO_NODE); ^ /home/mike/git_rep/ldd3/sbull/sbull.c: At top level: cc1: warning: unrecognized command line option ‘-Wno-implicit-fallthrough’ cc1: some warnings being treated as errors scripts/Makefile.build:283: recipe for target '/home/mike/git_rep/ldd3/sbull/sbull.o' failed make[2]: [/home/mike/git_rep/ldd3/sbull/sbull.o] Error 1 Makefile:1784: recipe for target '/home/mike/git_rep/ldd3/sbull' failed make[1]: [/home/mike/git_rep/ldd3/sbull] Error 2 make[1]: Leaving directory '/home/mike/git_rep/linux' Makefile:27: recipe for target 'default' failed make: *** [default] Error 2

jypan-ccu commented 3 years ago

Try https://github.com/jypan-ccu/ldd3

dwalkes commented 3 years ago

@michaelbaly please try with the latest master branch and changes I've just merged from @jypan-ccu

Geo25rey commented 3 years ago

@dwalkes Building works fine on Linux hostname 5.9.10-arch1-1 #1 SMP PREEMPT Sun, 22 Nov 2020 14:16:59 +0000 x86_64 GNU/Linux

dwalkes commented 3 years ago

Thanks @Geo25rey !

michaelbaly commented 3 years ago

@dwalkes @jypan-ccu I tried and found out it works with v5.9 only after I update my gcc and make version to 9 and 4.3 respectively, but with v5.10-*, some compile error still exist. Anyway, thanks for all your help!

jypan-ccu commented 3 years ago

@michaelbaly Try the new version. @dwalkes has merged the version without compiling error in v.5.10-r6.

michaelbaly commented 3 years ago

@jypan-ccu With the latest code(v5.10-rc6), there still has compiling error. I don't know where the problem lies, try to confirm it if you wish. Thanks!

CC [M] /home/mike/git_rep/ldd3/misc-modules/complete.mod.o In file included from ././include/linux/compiler_types.h:65, from : /home/mike/git_rep/ldd3/misc-modules/complete.mod.c:13:11: error: expected expression before ‘.’ token 13 | section(.gnu.linkonce.this_module) = { | ^ ./include/linux/compiler_attributes.h:257:68: note: in definition of macro ‘section’ 257 | #define section(section) attribute((section(section))) | ^~~ /home/mike/git_rep/ldd3/misc-modules/complete.mod.c:13:11: error: section attribute argument not a string constant 13 | section(.gnu.linkonce.this_module) = { | ^ ./include/linux/compiler_attributes.h:257:68: note: in definition of macro ‘section’ 257 | #define section(section) attribute((section__(section))) | ^~~ /home/mike/git_rep/ldd3/misc-modules/complete.mod.c:27:18: error: ‘versions’ undeclared here (not in a function) 27 | used section(versions) = { | ^~~~~~ ./include/linux/compiler_attributes.h:257:68: note: in definition of macro ‘section’ 257 | #define section(section) attribute((section(section))) | ^~~ /home/mike/git_rep/ldd3/misc-modules/complete.mod.c:27:1: error: section attribute argument not a string constant 27 | used section(versions) = { | ^~ make[4]: [scripts/Makefile.modfinal:28: /home/mike/git_rep/ldd3/misc-modules/complete.mod.o] Error 1 make[3]: [scripts/Makefile.modpost:117: __modpost] Error 2 make[2]: [Makefile:1701: modules] Error 2 make[2]: Leaving directory '/home/mike/git_rep/linux' make[1]: [Makefile:20: modules] Error 2 make[1]: Leaving directory '/home/mike/git_rep/ldd3/misc-modules' make: *** [Makefile:10: subdirs] Error 1 mike@atel:~/git_rep/ldd3$ gcc --version gcc (Ubuntu 9.3.0-10ubuntu2~16.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

mike@atel:~/git_rep/ldd3$ make --version GNU Make 4.3 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Geo25rey commented 3 years ago

@michaelbaly I see you're still running Ubuntu 16.04. Might I recommend upgrading to Ubuntu 20.04? Doing so will enable you to update your gcc and make to later versions.

jypan-ccu commented 3 years ago

@michaelbaly Do you set any options after "git clone" ? My messages are as follows when make in misc-modules/

Standard-PC-i440FX-PIIX-1996:~/ldd3/misc-modules$ make make -C /lib/modules/5.10.0-rc6/build M=/home/kernel510/ldd3/misc-modules modules make[1]: Entering directory '/usr/src/linux-5.10-rc6' CC [M] /home/kernel510/ldd3/misc-modules/hello.o CC [M] /home/kernel510/ldd3/misc-modules/hellop.o CC [M] /home/kernel510/ldd3/misc-modules/seq.o CC [M] /home/kernel510/ldd3/misc-modules/jiq.o CC [M] /home/kernel510/ldd3/misc-modules/sleepy.o CC [M] /home/kernel510/ldd3/misc-modules/complete.o CC [M] /home/kernel510/ldd3/misc-modules/silly.o CC [M] /home/kernel510/ldd3/misc-modules/faulty.o CC [M] /home/kernel510/ldd3/misc-modules/kdatasize.o CC [M] /home/kernel510/ldd3/misc-modules/kdataalign.o CC [M] /home/kernel510/ldd3/misc-modules/jit.o MODPOST /home/kernel510/ldd3/misc-modules/Module.symvers CC [M] /home/kernel510/ldd3/misc-modules/complete.mod.o LD [M] /home/kernel510/ldd3/misc-modules/complete.ko CC [M] /home/kernel510/ldd3/misc-modules/faulty.mod.o LD [M] /home/kernel510/ldd3/misc-modules/faulty.ko CC [M] /home/kernel510/ldd3/misc-modules/hello.mod.o LD [M] /home/kernel510/ldd3/misc-modules/hello.ko CC [M] /home/kernel510/ldd3/misc-modules/hellop.mod.o LD [M] /home/kernel510/ldd3/misc-modules/hellop.ko CC [M] /home/kernel510/ldd3/misc-modules/jiq.mod.o LD [M] /home/kernel510/ldd3/misc-modules/jiq.ko CC [M] /home/kernel510/ldd3/misc-modules/jit.mod.o LD [M] /home/kernel510/ldd3/misc-modules/jit.ko CC [M] /home/kernel510/ldd3/misc-modules/kdataalign.mod.o LD [M] /home/kernel510/ldd3/misc-modules/kdataalign.ko CC [M] /home/kernel510/ldd3/misc-modules/kdatasize.mod.o LD [M] /home/kernel510/ldd3/misc-modules/kdatasize.ko CC [M] /home/kernel510/ldd3/misc-modules/seq.mod.o LD [M] /home/kernel510/ldd3/misc-modules/seq.ko CC [M] /home/kernel510/ldd3/misc-modules/silly.mod.o LD [M] /home/kernel510/ldd3/misc-modules/silly.ko CC [M] /home/kernel510/ldd3/misc-modules/sleepy.mod.o LD [M] /home/kernel510/ldd3/misc-modules/sleepy.ko make[1]: Leaving directory '/usr/src/linux-5.10-rc6' Standard-PC-i440FX-PIIX-1996:~/ldd3/misc-modules$

Standard-PC-i440FX-PIIX-1996:~/ldd3/misc-modules$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) Standard-PC-i440FX-PIIX-1996:~/ldd3/misc-modules$ make -v GNU Make 4.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.