Bug 279257 - emulators/virtualbox-ose-additions-legacy fails to build: error: ISO C++17 does not allow 'register' storage class specifier
Summary: emulators/virtualbox-ose-additions-legacy fails to build: error: ISO C++17 do...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Only Me
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-23 16:02 UTC by Mikhail Teterin
Modified: 2024-06-28 19:27 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (vbox)


Attachments
Eliminate the "register" keyword (6.01 KB, patch)
2024-05-24 15:10 UTC, Mikhail Teterin
no flags Details | Diff
Allow virtualbox-ose-additions-legacy to compile (1.25 KB, patch)
2024-05-24 17:03 UTC, Mikhail Teterin
no flags Details | Diff
fix build with llvm15+ on 13.2, 13.3 amd64, i386 (17.47 KB, patch)
2024-05-30 01:47 UTC, Vladimir Druzenko
no flags Details | Diff
fix build with llvm15+ on 13.2, 13.3 amd64, i386, add PAE option for i386 (19.68 KB, patch)
2024-06-25 19:41 UTC, Vladimir Druzenko
vvd: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikhail Teterin freebsd_committer freebsd_triage 2024-05-23 16:02:02 UTC
Trying to build the port inside a freshly upgraded VM:
FreeBSD kachka 14.1-STABLE FreeBSD 14.1-STABLE stable/14-n267772-5cbccac9f3d1 VBoxGuest i386

Getting the errors:
/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Runtime/common/log/logcom.cpp:123:9: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  123 |         register unsigned cMaxWait;
      |         ^~~~~~~~
/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Runtime/common/log/logcom.cpp:124:9: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  124 |         register uint8_t  u8;
      |         ^~~~~~~~
2 errors generated.
...
The failing command:
@c++ -c -O2 -g -pipe -pedantic -Wshadow -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-trigraphs -fdiagnostics-show-option -Wno-unused-parameter -Wno-language-extension-token  -Wno-gnu-folding-constant -Wno-gnu-anonymous-struct  -Wno-string-plus-int -Wno-nested-anon-types -Wno-variadic-macros -Wno-long-long -Wno-return-type-c-linkage -Wno-overloaded-virtual -Wno-variadic-macros -O2 -fno-omit-frame-pointer -fno-strict-aliasing -m32 -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Runtime/include -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/libs/liblzf-3.4 -I/opt/include -I/opt/include/libxml2 -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/include -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release -DVBOX -DVBOX_OSE -DVBOX_WITH_64_BITS_GUESTS -DVBOX_WITH_REM -DVBOX_WITH_RAW_MODE -DRT_OS_FREEBSD -D__FREEBSD__ -DRT_ARCH_X86 -D__X86__ -DVBOX_WITH_DEBUGGER -DVBOX_WITH_HARDENING -DRTPATH_APP_PRIVATE=\"/opt/lib/virtualbox\" -DRTPATH_APP_PRIVATE_ARCH=\"/opt/lib/virtualbox\" -DRTPATH_SHARED_LIBS=\"/opt/lib/virtualbox\" -DRTPATH_APP_DOCS=\"/opt/lib/virtualbox\" -D_REENTRANT -DIN_RING3 -DLOG_DISABLED -DIN_BLD_PROG -DIN_RT_R3 -DIN_ADV_BLD_PROG -DIN_RT_R3 -DLDR_WITH_NATIVE -DLDR_WITH_ELF32 -DLDR_WITH_LX -DLDR_WITH_MACHO -DLDR_WITH_PE -DRT_WITH_VBOX -DRT_NO_GIP -DRT_WITHOUT_NOCRT_WRAPPERS -DNOFILEID -DRT_WITH_ICONV_CACHE -DIPRT_WITHOUT_LDR_VERIFY -DRT_NO_GIP -Wp,-MD,/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/RuntimeBldProg/common/log/logcom.o.dep -Wp,-MT,/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/RuntimeBldProg/common/log/logcom.o -Wp,-MP -o /envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/RuntimeBldProg/common/log/logcom.o /envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Runtime/common/log/logcom.cpp

The -std=c++11 is present in LocalConfig.kmk, but -- judging by the above compiler command-line -- has no effect.

(I also need to add -DPAE for compiling the kernel-modules, any advice on how to do that?)
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-23 17:14:50 UTC
Try to replace:
.if ${COMPILER_TYPE} == clang
.if ${COMPILER_FEATURES:Mlibc++}
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
.endif
.endif

with:
.if ${CHOSEN_COMPILER_TYPE} == clang
.  if ${COMPILER_FEATURES:Mlibc++}
EXTRA_PATCHES+= ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk
.  endif
.  if ${OPSYS} == FreeBSD && \
    (${OSVERSION} < 1302505 || (${OSVERSION} >= 1400000 && ${OSVERSION} < 1400079) || \
    ${OSVERSION} >= 1400091)
# llvm 13, 14 and 16 included in FreeBSD fails to compile this legacy version of
# virtualbox-ose, force llvm 15 on all versions of the FreeBSD except lastest 13
# and several versions of 14 where the llvm 15 is included: PR#265539.
# Keep possibility to define different llvm via VBOX_LLVM_VER in make.conf.
BUILD_DEPENDS+= clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
CC=             clang${VBOX_LLVM_VER}
CXX=            clang++${VBOX_LLVM_VER}
VBOX_LLVM_VER?= 15
.  endif
.endif
Comment 2 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-23 18:15:05 UTC
Correct list of OSVERSIONs with stable/13:
.if ${CHOSEN_COMPILER_TYPE} == clang && ${OPSYS} == FreeBSD && \
    (${OSVERSION} < 1302505 || (${OSVERSION} >= 1302507 && ${OSVERSION} < 1400079) || \
    ${OSVERSION} >= 1400091)
# llvm 13, 14 and 16 included in FreeBSD fails to compile this legacy version of
# virtualbox-ose, force llvm 15 on all versions of the FreeBSD except lastest 13
# and several versions of 14 where the llvm 15 is included: PR#265539, 279257.
# Keep possibility to define different llvm via VBOX_LLVM_VER in make.conf.
BUILD_DEPENDS+= clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
CC=             clang${VBOX_LLVM_VER}
CXX=            clang++${VBOX_LLVM_VER}
VBOX_LLVM_VER?= 15
.endif

After 13.2 EOL and EOL of stable/14 before 14.0:
.if ${CHOSEN_COMPILER_TYPE} == clang && ${OPSYS} == FreeBSD)
# llvm 13, 14 and 16 included in FreeBSD fails to compile this legacy version of
# virtualbox-ose, force llvm 15 on all versions of the FreeBSD: PR#265539, 279257.
# Keep possibility to define different llvm via VBOX_LLVM_VER in make.conf.
BUILD_DEPENDS+= clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
CC=             clang${VBOX_LLVM_VER}
CXX=            clang++${VBOX_LLVM_VER}
VBOX_LLVM_VER?= 15
.endif
Comment 3 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 15:10:13 UTC
Created attachment 250922 [details]
Eliminate the "register" keyword

> Try to replace

Sorry, that's a bit too hairy for me -- could you attach an actual patch for me to apply?

> VBOX_LLVM_VER?= 15

Generally, I pick the LLVM-version to match the base compiler. So, in this case, I'm using llvm18. Are you suggesting, I must use llvm15 to build this one port? Wouldn't it be better, if the patches eliminated that need? Here is one patch -- that removes the "register" verb.

And I'm still wondering, why the settings in LocalConfig.mk aren't reflected in the compiler command-line...

Meanwhile I tried using gcc13 and it died in our own -- FreeBSD-specific -- code:

/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c:325:53: error: type of formal parameter 4 is incomplete
  325 |         error = vboxfs_alloc_node(mp, vboxfsmp, "", VDIR, 0,
      |                                                     ^~~~
kmk: *** [/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs/vboxvfs_vfsops.o] Error 1
The failing command:
@gcc13 -c -O2 -I/usr/src/sys/../sbin/mount -Wall -Wextra -Wno-missing-field-initializers -Wno-unused -Wno-trigraphs -fdiagnostics-show-option -Wno-unused-parameter -Wno-variadic-macros -Wpointer-arith -Winline -Wno-pointer-sign -fdiagnostics-show-option -Wstrict-prototypes -Wmissing-prototypes -Wstrict-prototypes -Wimplicit-function-declaration -Werror-implicit-function-declaration -O2 -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 -fno-stack-protector -O2 -mtune=generic -fno-omit-frame-pointer -nostdinc -std=c99 -include /envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/include/VBox/VBoxGuestMangling.h -m32 -mpreferred-stack-boundary=2 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Additions/freebsd/vboxvfs -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs -I/usr/src/sys -I/usr/src/sys/contrib/altq -I/usr/src/sys/../include -I/usr/include -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs/dtrace -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/include -I/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release -DVBOX -DVBOX_OSE -DVBOX_WITH_64_BITS_GUESTS -DVBOX_WITH_REM -DVBOX_WITH_RAW_MODE -DRT_OS_FREEBSD -D__FREEBSD__ -DRT_ARCH_X86 -D__X86__ -DVBOX_WITH_DEBUGGER -DVBOX_WITH_HARDENING -DRTPATH_APP_PRIVATE=\"/opt/lib/virtualbox\" -DRTPATH_APP_PRIVATE_ARCH=\"/opt/lib/virtualbox\" -DRTPATH_SHARED_LIBS=\"/opt/lib/virtualbox\" -DRTPATH_APP_DOCS=\"/opt/lib/virtualbox\" -DIN_RING0 -DIN_RT_R0 -DHC_ARCH_BITS=32 -DGC_ARCH_BITS=64 -D_KERNEL -DKLD_MODULE -DIN_GUEST -DIN_GUEST_R0 -DVBOX_WITH_HGCM -Wp,-MD,/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs/vboxvfs_vfsops.o.dep -Wp,-MT,/envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs/vboxvfs_vfsops.o -Wp,-MP -o /envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/out/freebsd.x86/release/obj/vboxvfs/vboxvfs_vfsops.o /envy/ports/emulators/virtualbox-ose-additions-legacy/work/VirtualBox-5.2.44/src/VBox/Additions/freebsd/vboxvfs/vboxvfs_vfsops.c
kmk: *** Waiting for unfinished jobs....
kmk: *** Exiting with status 2
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-24 15:49:32 UTC
(In reply to Mikhail Teterin from comment #3)
This block was copied&pasted from emulators/virtualbox-ose-legacy/Makefile.

Build port with devel/llvm15 by default, but with possibility to build with other versions of the llvm using VBOX_LLVM_VER=N in /etc/make.conf.
Comment 5 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 16:06:57 UTC
I'm confused... There is no mention of VBOX_LLVM_VER in the virtualbox-ose-legacy/Makefile -- and the port uses straight cc and c++ currently, not llvm-cc18 (or 15).

If you'd like me to try a change, could you attach it as as patch here, please?
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-24 16:47:15 UTC
(In reply to Mikhail Teterin from comment #5)
diff --git a/emulators/virtualbox-ose-additions-legacy/Makefile b/emulators/virtualbox-ose-additions-legacy/Makefile
index 249f4bfa6ef6..ba68c006e869 100644
--- a/emulators/virtualbox-ose-additions-legacy/Makefile
+++ b/emulators/virtualbox-ose-additions-legacy/Makefile
@@ -97,6 +97,19 @@ EXTRA_PATCHES+=      ${PATCHDIR}/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefil
 .endif
 .endif

+.if ${CHOSEN_COMPILER_TYPE} == clang && ${OPSYS} == FreeBSD && \
+    (${OSVERSION} < 1302505 || (${OSVERSION} >= 1302507 && ${OSVERSION} < 1400079) || \
+    ${OSVERSION} >= 1400091)
+# llvm 13, 14 and 16 included in FreeBSD fails to compile this legacy version of
+# virtualbox-ose, force llvm 15 on all versions of the FreeBSD except several
+# versions of 13 and 14 where the llvm 15 is included: PR#265539 279257.
+# Keep possibility to define different llvm via VBOX_LLVM_VER in make.conf.
+BUILD_DEPENDS+= clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
+CC=            clang${VBOX_LLVM_VER}
+CXX=           clang++${VBOX_LLVM_VER}
+VBOX_LLVM_VER?=        15
+.endif
+
 post-patch:
        @${ECHO_CMD} 'VBOX_ONLY_ADDITIONS = 1' > ${WRKSRC}/LocalConfig.kmk
        @${ECHO_CMD} 'VBOX_WITH_DRAG_AND_DROP = ${VBOX_WITH_X11}' >> \
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-24 16:48:12 UTC
(In reply to Mikhail Teterin from comment #5)
> There is no mention of VBOX_LLVM_VER in the virtualbox-ose-legacy/Makefile -- and the port uses straight cc and c++ currently, not llvm-cc18 (or 15).
???
VBOX_LLVM_VER?= 15
Comment 8 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 17:03:27 UTC
Created attachment 250923 [details]
Allow virtualbox-ose-additions-legacy to compile

The first hunk simply reduces the size of the WRKSRC by preventing some large -- but useless -- parts of the tarball from being extracted.

The second hunk adds the patch-register to the list of patches -- if the patch ought to live elsewhere, the line may need to be changed (or even removed altogether).

The last hunk replaces the use of "enum vtype" with "enum enum_vtype_uint8". I do not understand, why this is necessary -- the existing code under /sys still uses "enum vtype". Maybe, mjg@, who introduced the __enum_uint8_decl macro, can help us understand, how to correct the vboxfs-code properly.

The port now builds for me (using stock cc and c++), and the resulting vboxguest.ko actually loads without crashing the kernel right away :)

P.S. The Makefile currently has a line: ".if empty(ICONV_LIB)" -- I'm pretty sure, you meant to use "${ICONV_LIB}" in there, no?
Comment 9 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 17:07:07 UTC
(In reply to Vladimir Druzenko from comment #7)
> ???
> VBOX_LLVM_VER?= 15

Here is, what I have here (last git pull two hours ago):

root@kachka:/usr/ports/emulators/virtualbox-ose-additions-legacy # make -V VBOX_LLVM_VER

root@kachka:/usr/ports/emulators/virtualbox-ose-additions-legacy # grep VBOX_LLVM * | wc -w
       0
Comment 10 Mateusz Guzik freebsd_committer freebsd_triage 2024-05-24 17:16:33 UTC
s/enum vtype/__enum_uint8(vtype)/
Comment 11 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 17:37:09 UTC
(In reply to Mateusz Guzik from comment #10)
> s/enum vtype/__enum_uint8(vtype)/

Thanks, Mateusz. Would this replacement be unconditional, or dependent on __FreeBSD_version? Also, what about existing things under /usr/src? The lib/libprocstat/zfs_defs.c, for example, seems to (re)define its own vtype :(

And the man-pages -- like vaccess(9) -- still refer to "enum vtype".
Comment 12 Mateusz Guzik freebsd_committer freebsd_triage 2024-05-24 17:47:28 UTC
the man pages are hopelessly out of date

the replacement is dependent on the version
Comment 13 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-24 18:09:24 UTC
(In reply to Mikhail Teterin from comment #9)
I said emulators/virtualbox-ose-legacy, not emulators/virtualbox-ose-additions-legacy.
Comment 14 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 19:17:32 UTC
(In reply to Vladimir Druzenko from comment #6)
> VBOX_LLVM_VER?=        15
...
> I said emulators/virtualbox-ose-legacy, not emulators/virtualbox-ose-additions-legacy.

Oh, I see... Anyway, it seems wrong to require LLVM here at all -- especially LLVM of such an old version as 15.

Please, review the changes I propose in comment #8. Thank you!
Comment 15 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-24 19:56:55 UTC
(In reply to Mateusz Guzik from comment #12)
> the man pages are hopelessly out of date

It is in your power to fix them :-) I can file a separate PR for that, if you'd like.
Comment 16 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-25 10:52:46 UTC
(In reply to Mikhail Teterin from comment #14)
Why "EXTRA_PATCHES+=	${FILESDIR}/patch-register"?
It must work just with file "files/patch-register".
Also probably this can fix build emulators/virtualbox-ose-legacy with llvm from base too.

Testing…
Comment 17 Mikhail Teterin freebsd_committer freebsd_triage 2024-05-28 18:17:33 UTC
> Why "EXTRA_PATCHES+=	${FILESDIR}/patch-register"?

Because the PATCHDIR is virtualbox-ose-legacy/files, and I was concentrating on this port only ("additions").

> Also probably this can fix build emulators/virtualbox-ose-legacy with llvm from base too

That's very probable, yes. That's, what I meant, when I wrote (in comment #8):

> The second hunk adds the patch-register to the list of patches -- if the patch
> ought to live elsewhere, the line may need to be changed (or even removed altogether).

If you drop the new patch-register into the virtualbox-ose-legacy/files/, then this line will not be needed at all.
Comment 18 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-29 09:57:56 UTC
(In reply to Mikhail Teterin from comment #17)
I almost done with all virtualbox-ose-*legacy ports, but this commit https://cgit.freebsd.org/ports/commit/?id=f156eebebfda0cf0542f442da7dcb385832606d4 broke part of my work…
Main part with patches for build with modern LLVMs isn't lost!
I hope I can attach patch to this PR tonight.

> If you drop the new patch-register into the virtualbox-ose-legacy/files/, then this line will not be needed at all.
Yes.
Comment 19 Vladimir Druzenko freebsd_committer freebsd_triage 2024-05-30 01:47:56 UTC
Created attachment 251072 [details]
fix build with llvm15+ on 13.2, 13.3 amd64, i386

Patch fixed build both emulators/virtualbox-ose-legacy and virtualbox-ose-additions-legacy on 13.2, 13.3 amd64, i386 with llvm 15, 16, 17, 18.
13.3 have llvm17 in base - don't require llvm15 from ports anymore.
Tested build in poudriere all combinations of the FreeBSD versions, arches and llvm15+.
Also tested work on 13.3 amd64 - install in VM FreeBSD 14.1-BETA3.

Who can test it on 14.0, 14.1 amd64, i386?
I still don't have 14.
Comment 20 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-04 14:18:49 UTC
(In reply to Mikhail Teterin from comment #17)
Please test my patch especially on 14.

I will commit this after June 13, if no one objects.
Comment 21 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-09 14:17:10 UTC
> Who can test it on 14.0, 14.1 amd64, i386?
> I still don't have 14.
I updated several hosts to 14.1 and tested build - no errors during build, but all are amd64 "live systems" (without poudriere) and run doesn't tested.
Comment 22 Mikhail T. 2024-06-10 15:15:13 UTC
> I will commit this after June 13, if no one objects.

Given, that the port is currently broken anyway, I think, you're fretting too much over possible imperfections in fixing it.

That said, nobody know, how the current portmgr might react, so, maybe, you have a point...
Comment 23 Mikhail T. 2024-06-10 15:19:21 UTC
> BUILD_DEPENDS+=	clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}

Is installing llvm (of any version) really necessary? I'm pretty sure, the code will build with just the plain cc/c++ found in base.
Comment 24 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-10 19:22:04 UTC
(In reply to Mikhail T. from comment #22)
I think I can set:
Approved by:	portmgr (blanket, fix build)

(In reply to Mikhail T. from comment #23)
>> BUILD_DEPENDS+=	clang${VBOX_LLVM_VER}:devel/llvm${VBOX_LLVM_VER}
> Is installing llvm (of any version) really necessary? I'm pretty sure, the code will build with just the plain cc/c++ found in base.
With llvm 12, 13 and 14 build fails. So affected only 13.2 and some versions of 14 before 14.0 release - deprecated and almost unsupported versions:
> ${OSVERSION} < 1302505 || (${OSVERSION} >= 1400000 && ${OSVERSION} < 1400079)
Build fine on 13.3 i386 and amd64 with llvm17 from base, llvm 15, 16, 17 and 18 from ports, on 14.1 amd64 with llvm 18 from base.

Also tested work on 13.3 amd64 compiled with llvm 17 from base.
Comment 25 Mikhail T. 2024-06-10 19:24:50 UTC
(In reply to Vladimir Druzenko from comment #24)
> Also tested work on 13.3 amd64 compiled with llvm 17 from base.

So there is no need for clang${something} in BUILD_DEPENDS, is there?
Comment 26 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-10 19:33:14 UTC
(In reply to Mikhail T. from comment #25)
It's required for 13.2 and old versions of 14.
Comment 27 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-10 21:32:14 UTC
(In reply to Mikhail Teterin from comment #0)
> I also need to add -DPAE for compiling the kernel-modules, any advice on how to do that?
Is it still relevant?
Build emulators/virtualbox-ose-kmod-legacy without any errors on: 14.1 amd64, 13.3 amd64 i386, 13.2 amd64 i386.

Found this: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224616
Can you explain what fails one more time?
Comment 28 Mikhail T. 2024-06-11 01:50:30 UTC
(In reply to Vladimir Druzenko from comment #27)
> [Bug #224616] Can you explain what fails one more time?
When kernel is compiled with the PAE defined, all of the kernel modules must be compiled that way too.

Currently the port does not have any provisions for that. I have some local hackery inside /etc/make.conf to add -DPAE to COPTFLAGS, when building anything "virtualbox".

The Bug #224616 was an attempt to raise awareness of this omission -- and, perhaps, add PAE as an option or a flavor?
Comment 29 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-12 12:16:45 UTC
(In reply to Mikhail T. from comment #28)
> When kernel is compiled with the PAE defined, all of the kernel modules must be compiled that way too.
This means this is also true for the emulators/virtualbox-ose-kmod-legacy port, but not for the emulators/virtualbox-ose-legacy, isn't it?

Can you try set PAE via:
1) VBOX_GCC_PEDANTIC_CXX in LocalConfig.kmk
2) VBOX_FREEBSD in LocalConfig.kmk + patch to Config.kmk:
@@ -3068,6 +3069,9 @@ ifeq ($(KBUILD_TARGET_ARCH),x86)
   # (The '<=' operator is for prepending (kmk specific).)
   VBOX_GCC_OPT <= -march=i586
  endif
+ ifeq ($(KBUILD_TARGET),freebsd)
+  VBOX_GCC_OPT <= $(VBOX_FREEBSD)
+ endif
 endif
 
 
Also can you test build emulators/virtualbox-ose-kmod-legacy and "service vboxnet onestart" too on you i386 host with PAE without patches and with patch above?

Thanks!
Comment 30 Mikhail T. 2024-06-12 23:48:08 UTC
> This means this is also true for the emulators/virtualbox-ose-kmod-legacy port

Yes, it is true for _any_ port, that builds kernel modules.

> [...] too on you i386 host with PAE without patches and with patch above?

I will try, but this one i386 host I use is on my corporate desktop and, when I'm using it, I'm _at work_ -- and don't have much time for outside projects.
Comment 31 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-24 21:54:01 UTC
(In reply to Mikhail T. from comment #30)
Did you manage to find time for testing?
Comment 32 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-25 19:41:42 UTC
Created attachment 251696 [details]
fix build with llvm15+ on 13.2, 13.3 amd64, i386, add PAE option for i386

Can you please test this patch?

PAE option for ports:
emulators/virtualbox-ose-additions-legacy or emulators/virtualbox-ose-additions-nox11-legacy
and
emulators/virtualbox-ose-kmod-legacy.
Comment 33 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-26 13:34:01 UTC
I'll commit my last patch in next few days.
Only PAE didn't tested - no time for create i386 VM.
Comment 34 commit-hook freebsd_committer freebsd_triage 2024-06-28 19:26:33 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c9de267a3525a05df601239c02a960cb98445c76

commit c9de267a3525a05df601239c02a960cb98445c76
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2024-06-28 19:08:33 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-06-28 19:08:33 +0000

    emulators/virtualbox-ose{,-nox11,-kmod,-additions,-additions-nox11}-legacy: fix build with llvm15+, fix run with PAE on i386

    * Fix build with llvm15+ from ports and from base:
      - ISO C++17 does not allow 'register' storage class specifier;
      - require -fPIC on i386.
    * Fix load kernel modules on host and guest i386 if kernel compiled with
    PAE option: add non-default option PAE to ports.
    Based on patches from mi@.

    PR:             279257 224616
    Approved by:    vbox (maintainer, timeout 1 month and 6 years)

 emulators/virtualbox-ose-additions-legacy/Makefile |  16 +-
 .../virtualbox-ose-additions-nox11-legacy/Makefile |   2 +-
 emulators/virtualbox-ose-kmod-legacy/Makefile      |  15 +-
 emulators/virtualbox-ose-legacy/Makefile           |  28 +-
 .../virtualbox-ose-legacy/files/patch-C++17 (new)  | 301 +++++++++++++++++++++
 .../virtualbox-ose-legacy/files/patch-Config.kmk   |  10 +
 emulators/virtualbox-ose-nox11-legacy/Makefile     |   2 +-
 7 files changed, 354 insertions(+), 20 deletions(-)
Comment 35 Vladimir Druzenko freebsd_committer freebsd_triage 2024-06-28 19:27:33 UTC
Thanks!