aboutsummaryrefslogtreecommitdiff
path: root/emulators
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2020-04-14 13:51:04 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-04-14 13:51:04 +0000
commit0aaca77f4d89d494c51216ba72ac887f0b71d590 (patch)
treef75971047a071c53d33efcd0ec3ed4b7008a3d27 /emulators
parent763027ab13149989a7b2d14727affe43f6db6df7 (diff)
downloadports-0aaca77f4d89d494c51216ba72ac887f0b71d590.tar.gz
ports-0aaca77f4d89d494c51216ba72ac887f0b71d590.zip
MFH: r531689
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) Approved by: ports-secteam (blanket: major runtime fix caused by bad build)
Notes
Notes: svn path=/branches/2020Q2/; revision=531690
Diffstat (limited to 'emulators')
-rw-r--r--emulators/virtualbox-ose/Makefile9
-rw-r--r--emulators/virtualbox-ose/files/patch-Config.kmk11
-rw-r--r--emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp38
3 files changed, 51 insertions, 7 deletions
diff --git a/emulators/virtualbox-ose/Makefile b/emulators/virtualbox-ose/Makefile
index c70cc14c5db1..16a413cdca27 100644
--- a/emulators/virtualbox-ose/Makefile
+++ b/emulators/virtualbox-ose/Makefile
@@ -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
diff --git a/emulators/virtualbox-ose/files/patch-Config.kmk b/emulators/virtualbox-ose/files/patch-Config.kmk
index c660803fc82e..e7f6573d7a28 100644
--- a/emulators/virtualbox-ose/files/patch-Config.kmk
+++ b/emulators/virtualbox-ose/files/patch-Config.kmk
@@ -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)
diff --git a/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp
new file mode 100644
index 000000000000..f1cc9961e1f5
--- /dev/null
+++ b/emulators/virtualbox-ose/files/patch-src_libs_xpcom18a4_xpcom_reflect_xptcall_src_md_unix_xptcinvoke__x86__64__linux.cpp
@@ -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;
+ }