Bug 201132 - emulators/virtualbox-ose-additions does not link on FreeBSD10.2 r284791M
Summary: emulators/virtualbox-ose-additions does not link on FreeBSD10.2 r284791M
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: Virtualbox Team (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-26 20:00 UTC by lenzi.sergio
Modified: 2018-01-31 18:21 UTC (History)
4 users (show)

See Also:


Attachments
[patch] link VBoxClient with -lc++ when using -lcxxrt (1.00 KB, patch)
2015-10-16 01:24 UTC, John Hein
jcfyecrayz: maintainer-approval? (vbox)
Details | Diff
this fix the build for virtualbox-ose-additions on 10.2 release (525 bytes, patch)
2015-10-16 02:36 UTC, lenzi.sergio
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lenzi.sergio 2015-06-26 20:00:12 UTC
VirtualBox ose additions does not link on FreeBSD10.2 r284791M

error is:
kBuild: Installing libXext => /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/lib/libXext.so
/usr/bin/ld: /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/VBoxClient: hidden symbol `_Unwind_Resume_or_Rethrow' in /usr/lib/libgcc_eh.a(unwind-dw2.o) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
cc: error: linker command failed with exit code 1 (use -v to see invocation)
kmk: *** [/usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/VBoxClient] Error 1


The port COMPILES and works under Freebsd10.1






The failing command:
@cc                  -m64   -o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/VBoxClient /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/main.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/src/VBox/GuestHost/SharedClipboard/clipboard-helper.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/src/VBox/GuestHost/SharedClipboard/x11-clipboard.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/clipboard.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/seamless.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/seamless-x11.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/display.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/hostversion.o /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/obj/VBoxClient/draganddrop.o   -L/usr/X11R6/lib32  -L/usr/X11R6/lib  -L/usr/local/lib   -liconv   -lX11   -lXrandr   -lXt   -lcxxrt   -lgcc_eh   -lXext   -lXmu   /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/lib/additions/RuntimeGuestR3.a   /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/lib/additions/VBoxGuestR3Lib.a   /usr/ports/emulators/virtualbox-ose-additions/work/VirtualBox-4.3.28/out/freebsd.amd64/release/lib/additions/RuntimeGuestR3.a   -lpthread   -liconv
Comment 1 John Hein 2015-10-14 22:23:32 UTC
If you use c++ instead of cc, it links.
Comment 2 lenzi.sergio 2015-10-15 05:22:14 UTC
(In reply to John Hein from comment #1)

Hello, how to "tell"  Kbuild to use c++ instead of cc???

the command is in a .dep

TIA
Comment 3 John Hein 2015-10-16 01:11:46 UTC
Well, I tested that assertion (in comment 1) by just manually calling the failed cc line that kmk spewed out with c++.

Since that's not really useful for building the port, I dipped my toe into the inscrutable pool of kBuild and found a couple ways to work around the issue.  Why someone decided the world needed yet another build system to decipher is beyond me (despite having read some of the rationale), not to mention why the virtualbox people chose it.  But I digress... on to the hacking...


(1) hack src/VBox/Additions/x11/VBoxClient/Makefile.kmk to force the linker command to be c++:

--- src/VBox/Additions/x11/VBoxClient/Makefile.kmk.orig 2015-07-10 14:27:59.000000000 +0000
+++ src/VBox/Additions/x11/VBoxClient/Makefile.kmk      2015-10-15 17:04:01.248043000 +0000
@@ -22,6 +22,7 @@
 # VBoxClient - clipboard and seamless.
 #
 PROGRAMS += VBoxClient
+TOOL_GCC3_LD=c++


This doesn't feel right.  It doesn't work if the kbuild machinery doesn't
pick tools/GCC3.kmk (why / how kBuild selects tools/GCC3.kmk is one of the inscrutable kBuild mysteries - I had to do a lot of guesswork - the kBuild/kmk docs are not very helpful).  It doesn't look like the virtualbox kBuild/kmk infrastructure supports this level of granular configurability very well.



(2) add -lc++ with the change that pulled in -lcxxrt.

--- src/VBox/Additions/x11/VBoxClient/Makefile.kmk.orig 2015-07-10 14:27:59.000000000 +0000
+++ src/VBox/Additions/x11/VBoxClient/Makefile.kmk      2015-10-15 17:07:28.320295000 +0000
@@ -50,7 +50,8 @@
 #      Xtst
 # These are static replacements for gcc-specific parts of libstdc++
 VBoxClient_LIBS += \
-       supc++ \
+       cxxrt \
+       c++ \
        gcc_eh


Just let the link use cc and and -lc++.  This is pretty much all that linking with c++ (vs. cc) does anyway.  This modification can be directly applied to emulators/virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk.


Between (1) & (2), both work for building this version of the port on 10.2.

If I were upstream, I'd figure out a way in the kmk infrastructure to support (1) (or replace kmk with something else).  Linking a c++ program with the c++ compiler (vs. cc) is just more "correct".

For FreeBSD ports, I'd pick (2) at this time.  It's an easy change to an existing patch, and it is required specifically _because_ of that patch (which is currently only pulled in if the selected compiler is clang).


Incidentally, I think this doesn't happen with 9.x, for instance, because it links with libsupc++ rather than libcxxrt.  This does not require pulling in libstdc++, so linking with c++ is not necessary.  I don't remember exactly when FreeBSD switched to clang++/libc++/libcxxrt from the gnu equivalents by default, but maybe that was between 10.1 and 10.2 and that's why it builds on 10.1 - I don't have a 10.1 to test that theory, but I thought 10.1 didn't have gcc by default, so that wouldn't explain why it builds on 10.1.  Maybe your 10.1 system was built with gcc for the base compiler turned on or make.conf had a setting to prefer gcc?  I'm completely guessing now, so I'll stop.
Comment 4 John Hein 2015-10-16 01:24:43 UTC
Created attachment 162106 [details]
[patch] link VBoxClient with -lc++ when using -lcxxrt

The attached patch implements the (2) option described in comment 3.  Works for me, although I haven't had the time to test in poudriere.

I couldn't find a build log showing success or failure on any official 10.2 freebsd build server.
Comment 5 lenzi.sergio 2015-10-16 02:36:43 UTC
Created attachment 162107 [details]
this fix the build for virtualbox-ose-additions on 10.2 release

Thanks for John Hein for the hard work.

Just put the attach file on the /usr/ports/emulators/virtualbox-ose/files directory and build virtualbox-ose-additions
Comment 6 John Hein 2015-10-18 01:22:10 UTC
(In reply to lenzi.sergio from comment #5)

This patch (attachment 162107 [details]) won't apply if virtualbox-ose/files/extrapatch-src-VBox-Additions-x11-VBoxClient-Makefile.kmk was not applied (nor is it necessary if that patch was not applied).  The patch from comment 4 (attachment 162106 [details]) that was already submitted here handles that.
Comment 7 Walter Schwarzenfeld freebsd_triage 2018-01-13 20:05:23 UTC
10.2 is EOL. VBox has version 5.2.4. I think this is overcome by events.