Stonyx / QNAP-EC

GNU General Public License v3.0
65 stars 16 forks source link

`make module` fails on 6.6.44-production+truenas #21

Closed mcab closed 1 month ago

mcab commented 1 month ago

Version

# uname -a
Linux nas 6.6.44-production+truenas #1 SMP PREEMPT_DYNAMIC Mon Oct 28 20:15:46 UTC 2024 x86_64 GNU/Linux

# cat /etc/version
24.10.0

Issue

After unlocking dev mode [1] on a 24.10 TrueNAS installation, running make module fails. The shell output roughly runs 800k+ characters, before it has enough.

Running remake -d module doesn't tell much.

Searching for terms related to this (makefile, kernel module) under iXsystems' public bug tracker [2] doesn't reveal much.

I understand that this repo is intended for general Linux, but previous issues (#4, #12) demonstrate that this worked on the previous version. I can attest that this was working on TrueNAS's 24.04.

Appendix

Output of shell, truncated ```shell # make module make -C /lib/modules/6.6.44-production+truenas/build M=/home/admin/QNAP-EC MODULE_CFLAGS= modules make[1]: Entering directory '/usr/src/linux-headers-6.6.44-production+truenas' sudo: argv[2] mismatch, expected "set -e; echo ' CC [M] /home/admin/QNAP-EC/qnap-ec.o'; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - HUP; kill -s HUP $$' HUP; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - INT; kill -s INT $$' INT; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - QUIT; kill -s QUIT $$' QUIT; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - TERM; kill -s TERM $$' TERM; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - PIPE; kill -s PIPE $$' PIPE; gcc -Wp,-MMD,/home/admin/QNAP-EC/.qnap-ec.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -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 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -falign-functions=16 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-restrict -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-overflow -Wno-stringop-truncation -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g -Wall -O2 -lgcc -DMODULE -DKBUILD_BASENAME='"qnap_ec"' -DKBUILD_MODNAME='"qnap_ec"' -D__KBUILD_MODNAME=kmod_qnap_ec -c -o /home/admin/QNAP-EC/qnap-ec.o /home/admin/QNAP-EC/qnap [...] make[3]: *** [scripts/Makefile.build:243: /home/admin/QNAP-EC/qnap-ec.o] Killed make[2]: *** [/usr/src/linux-headers-6.6.44-production+truenas/Makefile:1924: /home/admin/QNAP-EC] Error 2 make[1]: *** [Makefile:237: __sub-make] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-6.6.44-production+truenas' make: *** [Makefile:82: module] Error 2 ```
Snippet of remake -d module ``` /usr/src/linux-headers-6.6.44-production+truenas/scripts/Makefile.build:490 FORCE[3] File 'FORCE' was considered already. Finished prerequisites of target file '/home/admin/QNAP-EC/qnap-ec.o'. Must remake target '/home/admin/QNAP-EC/qnap-ec.o'. scripts/Makefile.build:243: update target '/home/admin/QNAP-EC/qnap-ec.o' due to: /home/admin/QNAP-EC/qnap-ec.c FORCE ##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> set -e; echo ' CC [M] /home/admin/QNAP-EC/qnap-ec.o'; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - HUP; kill -s HUP $$' HUP; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - INT; kill -s INT $$' INT; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - QUIT; kill -s QUIT $$' QUIT; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - TERM; kill -s TERM $$' TERM; trap 'rm -f /home/admin/QNAP-EC/qnap-ec.o; trap - PIPE; kill -s PIPE $$' PIPE; gcc -Wp,-MMD,/home/admin/QNAP-EC/.qnap-ec.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -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 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -falign-functions=16 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-restrict -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-overflow -Wno-stringop-truncation -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g -Wall -O2 -lgcc -DMODULE -DKBUILD_BASENAME='"qnap_ec"' -DKBUILD_MODNAME='"qnap_ec"' -D__KBUILD_MODNAME=kmod_qnap_ec -c -o /home/admin/QNAP-EC/qnap-ec.o /home/admin/QNAP-EC/qnap-ec.c ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --ibt --orc --retpoline --rethunk --sls --static-call --uaccess --prefix=16 --link --module /home/admin/QNAP-EC/qnap-ec.o; scripts/basic/fixdep /home/admin/QNAP-EC/.qnap-ec.o.d /home/admin/QNAP-EC/qnap-ec.o 'gcc -Wp,-MMD,/home/admin/QNAP-EC/.qnap-ec.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -fmacro-prefix-map=./= -Werror -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=branch -fno-jump-tables -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 -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -mindirect-branch-cs-prefix -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fno-stack-clash-protection -pg -mrecord-mcount -mfentry -DCC_USING_FENTRY -falign-functions=16 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-restrict -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-overflow -Wno-stringop-truncation -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g -Wall -O2 -lgcc -DMODULE -DKBUILD_BASENAME='\''"qnap_ec"'\'' -DKBUILD_MODNAME='\''"qnap_ec"'\'' -D__KBUILD_MODNAME=kmod_qnap_ec -c -o /home/admin/QNAP-EC/qnap-ec.o /home/admin/QNAP-EC/qnap-ec.c ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --ibt --orc --retpoline --rethunk --sls --static-call --uaccess --prefix=16 --link --module /home/admin/QNAP-EC/qnap-ec.o' > /home/admin/QNAP-EC/.qnap-ec.o.cmd; rm -f /home/admin/QNAP-EC/.qnap-ec.o.d ##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ```

[^1] https://www.truenas.com/docs/scale/scaletutorials/systemsettings/advanced/developermode/ [^2] https://ixsystems.atlassian.net/jira/software/c/projects/NAS/issues/

mcab commented 1 month ago

🤦

I tried running this process as a regular user, and it worked. I did have to tweak the build steps.

Fix

  1. Grab the libuLinux_hal.so from a QuTS (hero) image of your machine, or use the one present in the repo.
  2. Apply the patch.
  3. Run MODULE_EXTRA_CFLAGS=-Wno-int-conversion make install.

sensors should show qnap_ec:

$ sensors
qnap_ec-isa-0000
Adapter: ISA adapter
fan1:         975 RPM
fan2:         997 RPM
fan7:         642 RPM
temp1:        +59.0°C
temp6:        +50.0°C
temp7:        +37.0°C
temp8:         +9.0°C

Appendix

Patch to install on TrueNAS Electric Eel ```patch diff --git a/Makefile b/Makefile index f2a1563..811cda0 100755 --- a/Makefile +++ b/Makefile @@ -33,9 +33,9 @@ CONTROL_FILE := control CONTROL_PATH := /DEBIAN SLACK_DESC_FILE := slack-desc SLACK_DESC_PATH := /install -DEPMOD_COMMAND := $(shell which depmod) -INSTALL_COMMAND := $(shell which install) -MODPROBE_COMMAND := $(shell which modprobe) +DEPMOD_COMMAND := $(shell sudo which depmod) +INSTALL_COMMAND := $(shell sudo which install) +MODPROBE_COMMAND := $(shell sudo which modprobe) # Set the helper compiler flags, add target specific flags, and add any extra flags HELPER_CFLAGS := -Wall -O2 -export-dynamic -ldl @@ -83,13 +83,13 @@ module: # Define the install target install: clean helper module - $(INSTALL_COMMAND) --owner=root --group=root --mode=644 $(LIBRARY_BINARY_FILE) \ + sudo $(INSTALL_COMMAND) --owner=root --group=root --mode=644 $(LIBRARY_BINARY_FILE) \ $(LIBRARY_COMPILED_PATH)/$(LIBRARY_BINARY_FILE) - $(INSTALL_COMMAND) --strip --owner=root --group=root --mode=755 $(HELPER_BINARY_FILE) \ + sudo $(INSTALL_COMMAND) --strip --owner=root --group=root --mode=755 $(HELPER_BINARY_FILE) \ $(HELPER_COMPILED_PATH)/$(HELPER_BINARY_FILE) - $(MAKE) -C $(KDIR) M=$(PWD) modules_install - $(DEPMOD_COMMAND) --quick - -$(MODPROBE_COMMAND) $(MODULE_NAME) + sudo $(MAKE) -C $(KDIR) M=$(PWD) modules_install + sudo $(DEPMOD_COMMAND) --quick + -sudo $(MODPROBE_COMMAND) $(MODULE_NAME) check-for-chip=no # Define the package target package: clean helper module ```