luainkernel / lunatik

Lunatik is a framework for scripting the Linux kernel with Lua.
GNU General Public License v2.0
501 stars 29 forks source link

suppress `__NR_*` redefinition warnings #179

Closed sav closed 4 days ago

sav commented 1 week ago

example: ./include/uapi/asm-generic/unistd.h:862: warning: "__NR_truncate" redefined

lneto commented 1 week ago

Can you give full log of this warning.. it's hard to tell which line in the code base is generating it based only on the sample provided

sav commented 1 week ago

sure thing...

compilation.txt

lneto commented 1 week ago

Can you try to comment this line? If it removes the warnings, can you try the systrack example to check if it is still working?

https://github.com/luainkernel/lunatik/blob/master/lib/luasyscall.c#L11

sav commented 1 week ago
sav@clair:~/l$ make 
make -C /lib/modules/6.8.0-41-generic/build M=/home/sav/l CONFIG_LUNATIK=m  \
CONFIG_LUNATIK_RUN=m CONFIG_LUNATIK_RUNTIME=y CONFIG_LUNATIK_DEVICE=m   \
CONFIG_LUNATIK_LINUX=m CONFIG_LUNATIK_NOTIFIER=m CONFIG_LUNATIK_SOCKET=m \
CONFIG_LUNATIK_RCU=m CONFIG_LUNATIK_THREAD=m CONFIG_LUNATIK_FIB=m \
CONFIG_LUNATIK_DATA=m CONFIG_LUNATIK_PROBE=m CONFIG_LUNATIK_SYSCALL=m \
CONFIG_LUNATIK_XDP=m CONFIG_LUNATIK_FIFO=m CONFIG_LUNATIK_XTABLE=m
make[1]: Entering directory '/usr/src/linux-headers-6.8.0-41-generic'
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
  You are using:           gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
  CC [M]  /home/sav/l/lib/luasyscall.o
/home/sav/l/lib/luasyscall.c:296:35: error: ‘__NR_arch_specific_syscall’ undeclared here (not in a function)
  296 |         {"arch_specific_syscall", __NR_arch_specific_syscall},
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/sav/l/lib/luasyscall.c:16:
/home/sav/l/lunatik.h:211:5: warning: no previous prototype for ‘luaopen_syscall’ [-Wmissing-prototypes]
  211 | int luaopen_##libname(lua_State *L)                                             \
      |     ^~~~~~~~
/home/sav/l/lib/luasyscall.c:437:1: note: in expansion of macro ‘LUNATIK_NEWLIB’
  437 | LUNATIK_NEWLIB(syscall, luasyscall_lib, NULL, luasyscall_flags);
      | ^~~~~~~~~~~~~~
make[3]: *** [scripts/Makefile.build:243: /home/sav/l/lib/luasyscall.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.8.0-41-generic/Makefile:1926: /home/sav/l] Error 2
make[1]: *** [Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.8.0-41-generic'
make: *** [Makefile:14: all] Error 2
sav@clair:~/l$ 
lneto commented 1 week ago

Can you comment this line as well? https://github.com/luainkernel/lunatik/blob/c2750644286972e6ea92e7e40f2d7859bfa96142/lib/luasyscall.c#L296

lneto commented 1 week ago

it looks like that's safe to remove both lines.. the proper platform header will be included by linux/module.h and __NR_arch_specific_syscall sounds like a delimiter only.. not a actual syscall.. I tested on my end and it's working just fine.. I think you can go ahead with this fix..

sav commented 1 week ago

looks good indeed.

lneto commented 4 days ago

https://github.com/luainkernel/lunatik/pull/182