1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-22 04:17:44 +00:00

emulators/virtualbox-ose: Switch build to USES= compiler:c++14-lang

The runtime breakage that started occurring after the LLVM 7 -> 8 transition
has been diagnosed with help from cem@, and the attached patch fixes it. The
problem ended up being that tail-call optimization was being applied to this
function (which should probably be written in assembly instead) and moving
the tail-call to later on after some stack manipulations. The problem with
this is that this particular function uses alloca() to carefully craft a
stack that it's expecting to be used for the function it's calling at the
end.

The new patch fixes this using a technique that was committed later on in
upstream changeset 75061 to address a similar failure with GCC sanitizers
enabled. The FreeBSD-specific component of this patch is using the different
stack setup if __clang__ is defined as well.

The extra hunk in the Config patch has been added because the VirtualBox
build system cannot cope with LLVM version numbers in the way it's
expecting. Hardcode it to GCC 4.2 for FreeBSD, which is what the clang
__GNU* macros describe, to fix build breakage that happens with newer LLVM
as the build system decides our LLVM is an even older and more broken
version of GCC with a broken regparm.

PR:		236616, 244847
Approved by:	koobs (mentor)
MFH:		2020Q2 (blanket: major runtime build fix)
This commit is contained in:
Kyle Evans 2020-04-14 13:47:51 +00:00
parent cbe65e3acf
commit a714a89d78
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=531689
3 changed files with 51 additions and 7 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= virtualbox-ose
PORTVERSION= 5.2.34
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= emulators
MASTER_SITES= https://download.oracle.com/virtualbox/${PORTVERSION}/
DISTFILES= VirtualBox-${PORTVERSION}${EXTRACT_SUFX} ${GUESTADDITIONS}
@ -30,13 +30,8 @@ CPE_PRODUCT= vm_virtualbox
WRKSRC= ${WRKDIR}/VirtualBox-${PORTVERSION}
ONLY_FOR_ARCHS= i386 amd64
USES= cpe gnome iconv pkgconfig ssl tar:bzip2
USES= compiler:c++14-lang cpe gnome iconv pkgconfig ssl tar:bzip2
USE_GNOME= libidl libxml2
# machine/atomic.h may use features that are only available in GCC9. This is
# a workaround, anyways- we should be expressing USES= compiler:c++14-lang, but
# contemporary clang miscompiles virtualbox in some fashion and yields runtime
# breakage.
USE_GCC= any
HAS_CONFIGURE= yes
CONFIGURE_ARGS= --disable-java --passive-mesa

View File

@ -74,6 +74,17 @@
# branding
VBOX_BRAND_LICENSE_HTML := $(PATH_ROOT)/doc/License-gpl-2.0.html
VBOX_BRAND_LICENSE_RTF := $(PATH_ROOT)/doc/License-gpl-2.0.rtf
@@ -2538,6 +2534,10 @@ ifeq ($(KBUILD_HOST),win) ## @todo can drop this now,
# This isn't important (yet) on windows, so cook the result until
# cygwin is feeling better.
VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 3), $(int-mul 100, 3), 3)
+else ifeq($(KBUILD_HOST,freebsd))
+ # At a minimum, we'll be building with GCC 4.2 on FreeBSD. LLVM will always
+ # pose as GCC 4.2 anyways, so this seems safe.
+ VBOX_GCC_VERSION := $(int-add $(int-mul 10000, 4), $(int-mul 100, 2), 0)
else
# This is kind of bad, the returned string needs to be re-evaluated before use.
# The reason for this hack is that the windows kmk_ash cannot deal with $((1+1)).
@@ -4158,6 +4154,7 @@ ifdef VBOX_WITH_RAW_MODE
TEMPLATE_VBoxRc_TOOL = $(VBOX_GCC32_TOOL)
TEMPLATE_VBoxRc_CXXFLAGS = -fno-pie -nostdinc -g $(VBOX_GCC_pipe) $(VBOX_GCC_WERR) $(VBOX_GCC_PEDANTIC_CXX) $(VBOX_GCC32_Wno-variadic-macros) -fno-exceptions $(VBOX_GCC_GC_OPT) $(VBOX_GCC_GC_FP) -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-strict-aliasing $(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_fvisibility-hidden) $(VBOX_GCC_fvisibility-inlines-hidden) -fno-rtti $(VBOX_GCC_IPRT_FMT_CHECK)

View File

@ -0,0 +1,38 @@
--- src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp.orig 2019-10-10 18:15:53 UTC
+++ src/libs/xpcom18a4/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_linux.cpp
@@ -143,11 +143,22 @@ XPTC_InvokeByIndex(nsISupports * that, PRUint32 method
if (nr_stack)
nr_stack = (nr_stack + 1) & ~1;
+#if !defined(VBOX_WITH_GCC_SANITIZER) && !defined(__clang__)
// Load parameters to stack, if necessary
PRUint64 *stack = (PRUint64 *) __builtin_alloca(nr_stack * 8);
+#else
+ typedef struct { PRUint64 stack[20]; } methodStack;
+ if (nr_stack > 20)
+ return NS_ERROR_CALL_FAILED;
+ methodStack stack;
+#endif
PRUint64 gpregs[GPR_COUNT];
double fpregs[FPR_COUNT];
+#if !defined(VBOX_WITH_GCC_SANITIZER) && !defined(__clang__)
invoke_copy_to_stack(stack, paramCount, params, gpregs, fpregs);
+#else
+ invoke_copy_to_stack(stack.stack, paramCount, params, gpregs, fpregs);
+#endif
// Load FPR registers from fpregs[]
register double d0 asm("xmm0");
@@ -205,7 +216,12 @@ XPTC_InvokeByIndex(nsISupports * that, PRUint32 method
methodAddress += 8 * methodIndex;
methodAddress = *((PRUint64 *)methodAddress);
+#if !defined(VBOX_WITH_GCC_SANITIZER) && !defined(__clang__)
typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, PRUint64);
PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5);
+#else
+ typedef PRUint32 (*Method)(PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, PRUint64, methodStack);
+ PRUint32 result = ((Method)methodAddress)(a0, a1, a2, a3, a4, a5, stack);
+#endif
return result;
}