mastermakrela / kernel-dev

Template for Linux Kernel development on Apple Silicon (aarch64) using VS Code
2 stars 0 forks source link

Some warning and errors occurred #2

Open uudiin opened 3 weeks ago

uudiin commented 3 weeks ago
  CALL    scripts/checksyscalls.sh
<stdin>:247:2: warning: syscall restart_syscall not implemented [-W#warnings]
  247 | #warning syscall restart_syscall not implemented
      |  ^
<stdin>:250:2: warning: syscall exit not implemented [-W#warnings]
  250 | #warning syscall exit not implemented
      |  ^
<stdin>:256:2: warning: syscall read not implemented [-W#warnings]
  256 | #warning syscall read not implemented
      |  ^

... ...
  CC      lib/audit.o
In file included from lib/audit.c:13:
./include/asm-generic/audit_read.h:5:1: error: use of undeclared identifier '__NR_quotactl'
    5 | __NR_quotactl,
      | ^
./include/asm-generic/audit_read.h:6:1: error: use of undeclared identifier '__NR_listxattr'
    6 | __NR_listxattr,
      | ^
./include/asm-generic/audit_read.h:7:1: error: use of undeclared identifier '__NR_llistxattr'
    7 | __NR_llistxattr,
      | ^
./include/asm-generic/audit_read.h:8:1: error: use of undeclared identifier '__NR_flistxattr'
    8 | __NR_flistxattr,
      | ^

... ...

Looks like all syscall number definition are not found.

mastermakrela commented 3 weeks ago

@uudiin This is too little information for me to tell you something concrete.

One thing that comes to my mind is maybe a kernel version mismatch. This repo works only with v6.5.7 (git://git.kernel.org/pub/​scm/​linux/​kernel/​git/​stable/linux.git --depth 1 -b v6.5.7). So if you're using different version with different syscalls it might be the problem.

Also, the syscall numbers differ between arm and x86, so you might have to adapt your code accordingly.

uudiin commented 3 weeks ago

I compiled on master branch, it is 5be63fc19fcaa4c236b307420483578a56986a37 ("Linux 6.11-rc5"), mac_patch_6-5-7.patch was applied succeed, the build environment is Mac Book Pro 2023 with Apple Silicon M3 Pro, macOS Sonoma 14.6.1.

It seems that the asm-generic/unistd.h header file is not included correctly, and all syscall definitions like _NR are wrong.

mastermakrela commented 3 weeks ago

I've looked at the changes briefly and as I feared, a lot has changed between 6.5.7 and 6.11-rc5.

mac_patch_6-5-7.patch applies successfully, probably because the files it changes are still there, but now there are some new files one would have to patch to get the kernel to build on macOS. :|

If you need 6.11-rc5 it would probably be easier to use linux (or you can hunt for all the new patches by debugging the build process — which tbh is very tedious).

If not, you can try the old kernel version from:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git --depth 1 -b v6.5.7

(Full tutorial here)

uudiin commented 3 weeks ago

@mastermakrela I want to develop some new features, so I have to compile based on master. Thanks for your suggestion. I will see if I can solve it by debugging the build system.