On recent 14-CURRENT (FreeBSD 14.0-CURRENT #34 main-n251260-156fbc648579: Thu Dec 2 15:31:48 CET 2021 amd64) the compilation of x11/nvidia-driver fails due to the error shown below: [...] ===> src/nvidia-modeset (all) machine -> /usr/src/sys/amd64/include x86 -> /usr/src/sys/x86/include touch opt_global.h cc -O2 -pipe -march=native -fno-strict-aliasing -DNV_VERSION_STRING=\"470.86\" -DNV_SPECTRE_V2=1 -Werror=undef -march=native -Werror -D_KERNEL -DKLD_MODULE -nostdinc -Imachine -I/usr/src/sys/sys -I../common/inc -incl ude /usr/obj/usr/src/amd64.amd64/sys/THOR/usr/ports/x11/nvidia-driver/work/NVIDIA-FreeBSD-x86_64-470.86/src/nvidia-modeset/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common -fno-omit-frame-p ointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -MD -MF.depend.nvidia-modeset-freebsd.o -MTnvidia-modeset-freebsd.o -mcm odel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpoin ter-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=par entheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length -mno-aes -mno-avx -std=iso 9899:1999 -c nvidia-modeset-freebsd.c -o nvidia-modeset-freebsd.o In file included from nvidia-modeset-freebsd.c:12: /usr/src/sys/sys/module.h:262:13: error: use of undeclared identifier 'MAXPATHLEN' char name[MAXMODNAME]; ^ /usr/src/sys/sys/module.h:258:20: note: expanded from macro 'MAXMODNAME' #define MAXMODNAME MAXMODNAMEV3 ^ /usr/src/sys/sys/module.h:257:22: note: expanded from macro 'MAXMODNAMEV3' #define MAXMODNAMEV3 MAXPATHLEN ^ 1 error generated. *** Error code 1
Created attachment 230027 [details] path for src main after git: df38ada2931f After git src main df38ada2931f, sys/module.h SHALL be included AFTER sys/param.h. Attached patch moves sys/param.h just before sys/modules.h. Tested only on main (aka 14-current) and nvidia-driver 470.86, amd64.
The patch works as expected on my box with 14.0-CURRENT amd64, main-n251591-6102f43cf06. Many thanks to Tomoaki AOKI :)
Works here too. Could these be committed? The nvidia drivers aren't being packaged right now.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=c1eb97fea020ac09dc329651c4f33436e071997b commit c1eb97fea020ac09dc329651c4f33436e071997b Author: Alexey Dokuchaev <danfe@FreeBSD.org> AuthorDate: 2021-12-15 03:02:06 +0000 Commit: Alexey Dokuchaev <danfe@FreeBSD.org> CommitDate: 2021-12-15 03:02:06 +0000 x11/nvidia-driver: try to unbreak the build on recent -CURRENT After src commit df38ada2931f, `sys/module.h' must be included after `sys/param.h'. PR: 260318 x11/nvidia-driver/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
ALL of the nvidia driver ports now build and I reinstalled the one I was using just in case and everything seems to work fine. Thanks!
Hmmm... I may need to take some (additional) evasive action. After a hiatus (since 01 October; long story), I have started to try to resume daily updates of certain machines, including a laptop. The machine is currently running: g1-64(14.0-C)[1] uname -aUK FreeBSD g1-64.catwhisker.org 14.0-CURRENT FreeBSD 14.0-CURRENT #33 main-n249803-ca4a6606f0b8: Fri Oct 1 04:04:14 PDT 2021 root@g1-64.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/CANARY amd64 1400034 1400034 I have updated sources to main-n251803-33d56e57ece8; ports updated to main-n568451-abcff57bed85. I have: g1-64(14.0-C)[10] grep -i port /etc/src.conf PORTS_MODULES+=x11/nvidia-driver so I am trying to rebuild x11/nvidia0driver as part of the "make buildkernel" process. Reality-checking: g1-64(14.0-C)[11] git show c1eb97fea020ac09dc329651c4f33436e071997b commit c1eb97fea020ac09dc329651c4f33436e071997b Author: Alexey Dokuchaev <danfe@FreeBSD.org> Date: Wed Dec 15 03:02:06 2021 +0000 x11/nvidia-driver: try to unbreak the build on recent -CURRENT After src commit df38ada2931f, `sys/module.h' must be included after `sys/param.h'. PR: 260318 diff --git a/x11/nvidia-driver/Makefile b/x11/nvidia-driver/Makefile index 6899b455b65c..e7de4d18e89a 100644 --- a/x11/nvidia-driver/Makefile +++ b/x11/nvidia-driver/Makefile @@ -168,6 +168,12 @@ post-patch: .SILENT ${REINPLACE_CMD} -e '/^#include/s:lock\.h:mutex.h:' \ ${WRKSRC}/src/nvidia-modeset/nvidia-modeset-freebsd.c .endif +# After src df38ada2931f, `sys/module.h' must be included after `sys/param.h' +.if ${OSVERSION} >= 1400042 && ${NVVERSION} >= 358.009 + @${REINPLACE_CMD} -e '/^#include <sys\/module/ { x; \ + s:^:#include <sys/param.h>:; G; }; 14d' \ + ${WRKSRC}/src/nvidia-modeset/nvidia-modeset-freebsd.c +.endif # Disable installation of Linux libraries (provided by the corresponding # `x11/linux-nvidia-libs' port or its slaves) ${REINPLACE_CMD} -e 's/exists(\/.*/& \&\& 0/' \ g1-64(14.0-C)[12] make -V OSVERSION -V NVVERSION 1400034 470.086 g1-64(14.0-C)[13] dirs /usr/ports/x11/nvidia-driver ~ g1-64(14.0-C)[14] And /usr/ports/x11/nvidia-driver looks clean: g1-64(14.0-C)[14] cd .. g1-64(14.0-C)[15] ls -Fa nvidia-driver* nvidia-driver: ./ files/ pkg-descr ../ Makefile pkg-plist distinfo Makefile.common nvidia-driver-304: ./ ../ Makefile nvidia-driver-340: ./ ../ Makefile nvidia-driver-390: ./ ../ Makefile g1-64(14.0-C)[16] git -C nvidia-driver status . On branch main Your branch is up to date with 'origin/main'. nothing to commit, working tree clean g1-64(14.0-C)[17] Despite that, I see: ===> src/nvidia-modeset (all) machine -> /usr/src/sys/amd64/include x86 -> /usr/src/sys/x86/include touch opt_global.h cc -O2 -pipe -fno-strict-aliasing -DNV_VERSION_STRING=\"470.86\" -DNV_SPECTRE_V2=1 -Werror=undef -Werror -D_KERNEL -DKLD_MODULE -nostdinc -Imachine -I/usr/src/sys/sys -I../common/inc -include /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/x11/nvidia-driver/work/NVIDIA-FreeBSD-x86_64-470.86/src/nvidia-modeset/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -MD -MF.depend.nvidia-modeset-freebsd.o -MTnvidia-modeset-freebsd.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length -mno-aes -mno-avx -std=iso9899:1999 -c nvidia-modeset-freebsd.c -o nvidia-modeset-freebsd.o In file included from nvidia-modeset-freebsd.c:12: /usr/src/sys/sys/module.h:262:13: error: use of undeclared identifier 'MAXPATHLEN' char name[MAXMODNAME]; ^ /usr/src/sys/sys/module.h:258:20: note: expanded from macro 'MAXMODNAME' #define MAXMODNAME MAXMODNAMEV3 ^ /usr/src/sys/sys/module.h:257:22: note: expanded from macro 'MAXMODNAMEV3' #define MAXMODNAMEV3 MAXPATHLEN ^ 1 error generated. *** Error code 1 Stop. make[7]: stopped in /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/x11/nvidia-driver/work/NVIDIA-FreeBSD-x86_64-470.86/src/nvidia-modeset *** Error code 1 Stop. make[6]: stopped in /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/x11/nvidia-driver/work/NVIDIA-FreeBSD-x86_64-470.86/src *** Error code 1
(In reply to david from comment #6) It is because unneeded OSVERSION check is done. As Bjoern A. Zeeb commented at freebsd-ports ML [1], sys/param.h is suggested to be included AFTER sys/cdefs.hsys/cdefs.h and BEFORE anything else on style.9 man page. # I've missed that types.h is included by sys/param.h, but as it's guarded by # #ifndef LOCORE and sys/types.h has doble-inclusion guard, I considered it # as no harm. If somehow LOCORE is defined, sys/types.h could be missed. This suggestion is already there at least on 13-RELEASE man page. [2] Moreover, at least emulators/virtualbox-ose-kmod, sysutils/sysctlbyname-improved-kmod and sysutils/sysctlinfo-kmod did the right thing from before git src main df38ada2931f. [1] https://lists.freebsd.org/archives/freebsd-ports/2021-December/001160.html [2] https://www.freebsd.org/cgi/man.cgi?query=style&apropos=0&sektion=9&manpath=FreeBSD+13.0-RELEASE+and+Ports&arch=default&format=html
Ah -- thanks! I hand-edited ports/x11/nvidia-driver/Makefile: # After src df38ada2931f, `sys/module.h' must be included after `sys/param.h' ## .if ${OSVERSION} >= 1400042 && ${NVVERSION} >= 358.009 .if ${NVVERSION} >= 358.009 @${REINPLACE_CMD} -e '/^#include <sys\/module/ { x; \ s:^:#include <sys/param.h>:; G; }; 14d' \ ${WRKSRC}/src/nvidia-modeset/nvidia-modeset-freebsd.c .endif and that seems to have worked.
After a successful update: FreeBSD g1-70.catwhisker.org 12.3-STABLE FreeBSD 12.3-STABLE #1148 stable/12-n234569-4772e4135cb: Wed Dec 22 04:45:58 PST 2021 root@g1-70.catwhisker.org:/common/S1/obj/usr/src/amd64.amd64/sys/CANARY amd64 1203502 1203502 the OSVERSION test is no longer a problem: I was able to revert x11/nvidia-driver/Makefile back to the pristine c1eb97fea020ac09dc329651c4f33436e071997b version without problems.
Ugh; sorry: I normally use stable/12 for routine work on the machine. I had actually been running: FreeBSD 14.0-CURRENT #371 main-n251872-49912693698e: Tue Dec 21 03:59:17 PST 2021 root@g1-70.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/CANARY amd64 1400045 1400045 when I did the successful update in question, and built (and smoke-tested): FreeBSD 14.0-CURRENT #372 main-n251888-d34632a235dc: Wed Dec 22 05:15:10 PST 2021 root@g1-70.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/CANARY amd64 1400045 1400045
Created attachment 230578 [details] Fix for stable/13 at (and after) git a34668185ba7e5428bc6298c633c9d4f8317134b git main df38ada2931f is now MFC'ed to stable/13 as git stable/13 a34668185ba7, and OSVERSION check is now become harmful. Attached patch fixes the issue. While here, change script a bit because the one currently in x11/nvidia-driver/Makefile deletes old param.h entry by "14d", seems to be fragile if upstream inserts or deletes some line. Instead, clear existing param.h line first. This would be safer if sys/param.h is included on only single place.
Created attachment 230617 [details] Log from failed poudriere attempt to build x11/nvidia-driver for/under stable/13 The build machine was running FreeBSD 13.0-STABLE #1403 stable/13-n248793-375fdb6e161: Sat Jan 1 05:35:06 PST 2022 root@freebeast.catwhisker.org:/common/S3/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1300523 1300523 at the time. x11/nvidia-driver was at c1eb97fea020ac09dc329651c4f33436e071997b ("x11/nvidia-driver: try to unbreak the build on recent -CURRENT"). The build machine had (earlier) built packages for stable/12 without issue; it was running FreeBSD 12.3-STABLE #1362 stable/12-n234662-6d16489da84: Thu Dec 30 03:33:04 PST 2021 root@freebeast.catwhisker.org:/common/S1/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1203505 1203505 at the time.
(In reply to Tomoaki AOKI from comment #11) > git main df38ada2931f is now MFC'ed to stable/13 as git stable/13 > a34668185ba7, and OSVERSION check is now become harmful. Hmm, you're right and we should remove it as it turned out to be overzealous; it was not very accurate anyway. I'll commit once my all tinderbox runs pass.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=0375fc8f10e7ebcee63258c57abcd80e3c84333f commit 0375fc8f10e7ebcee63258c57abcd80e3c84333f Author: Alexey Dokuchaev <danfe@FreeBSD.org> AuthorDate: 2022-01-02 15:47:24 +0000 Commit: Alexey Dokuchaev <danfe@FreeBSD.org> CommitDate: 2022-01-02 15:47:24 +0000 x11/nvidia-driver: lax the check when applying fix for src df38ada293 It turns out that NVVERSION check is not very accurate and may easily break the build in various circumstances. Also, do not use the line number as an anchor, just spell out the #include line in its entirety when removing it. PR: 260318 x11/nvidia-driver/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
(In reply to commit-hook from comment #14) Thanks! This can be closed after merging to 2022Q1. It would need this, too.
On current I added #include <sys/param.h> to sys/sys/module.h to fix driver 495.46 not finding MAXPATHLEN. No issue on 13.0. I'm not sure what to think because sys/param.h defines MAXPATHLEN, and the driver in question includes such header, but it doesn't build otherwise.
We're on 2022Q2 stable branch now so closing this as fixed.