1
0
forked from pool/virtualbox
virtualbox/cxx17.patch

109 lines
5.0 KiB
Diff
Raw Normal View History

2024-09-21 01:53:54 +02:00
From: Jan Engelhardt <ej@inai.de>
Date: 2024-09-20 22:48:58.758026690 +0200
The code uses <filesystem>, so ensure we always use -std=c++17 at the
very least.
2024-09-21 01:53:54 +02:00
Prior to C++17, noexcept cannot be part of a type alias, and so is
not part of the function signature, and so is not part of the ABI.
2024-09-21 01:53:54 +02:00
In C++17, noexcept is significant. There is a compile error because
the FNCONSUMER alias as defined in a .h file does not match the
function body in a .cpp file.
The def file is also wrong, but no one at virtualbox.org noticed for
some reason, even though the def mismatch also caused a link/build
failure in its own right.
To resolve the mismatch between .cpp/.h, the function signature is
augmented by RT_NOEXCEPT, based upon the function head being the
authoritative source as to whether something was meant to be noexcept
or not.
In turn, adding RT_NOEXCEPT causes a change in the ABI of VBoxRT.so.
The closed-source VirtualBox extension pack does not expect that and
is unable to load [LD_BIND_NOW=1]. To resolve _that_, we add extra
symbol aliases.
2024-09-21 01:53:54 +02:00
---
Config.kmk | 3 +++
include/iprt/cpp/restclient.h | 12 ++++++++++--
src/VBox/Runtime/VBox/VBoxRTImp-gcc.def | 2 +-
src/VBox/Runtime/common/rest/rest-binary.cpp | 9 +++++++++
4 files changed, 23 insertions(+), 3 deletions(-)
2024-09-21 01:53:54 +02:00
Index: VirtualBox-7.1.0/Config.kmk
===================================================================
--- VirtualBox-7.1.0.orig/Config.kmk
+++ VirtualBox-7.1.0/Config.kmk
@@ -3093,6 +3093,9 @@ ifeq ($(KBUILD_TARGET),darwin)
endif
endif
endif
+ifndef VBOX_GCC_std
+ VBOX_GCC_std := -std=c++17
+endif
#
# Check for incompatible rpath combinations.
Index: VirtualBox-7.1.0/include/iprt/cpp/restclient.h
===================================================================
--- VirtualBox-7.1.0.orig/include/iprt/cpp/restclient.h
+++ VirtualBox-7.1.0/include/iprt/cpp/restclient.h
@@ -130,7 +130,11 @@ public:
* is the sum of the previously returned @a *pcbActual values.
*/
typedef DECLCALLBACKTYPE(int, FNPRODUCER,(RTCRestBinaryParameter *a_pThis, void *a_pvDst, size_t a_cbDst,
- uint64_t a_offContent, size_t *a_pcbActual)) /*RT_NOEXCEPT*/;
+ uint64_t a_offContent, size_t *a_pcbActual))
+#if defined(__cplusplus) && __cplusplus >= 201700L
+RT_NOEXCEPT
+#endif
+;
/** Pointer to a byte producer callback. */
typedef FNPRODUCER *PFNPRODUCER;
@@ -268,7 +272,11 @@ public:
* is the sum of the previous @a a_cbSrc values.
*/
typedef DECLCALLBACKTYPE(int, FNCONSUMER,(RTCRestBinaryResponse *a_pThis, const void *a_pvSrc, size_t a_cbSrc,
- uint32_t a_uHttpStatus, uint64_t a_offContent, uint64_t a_cbContent)) /*RT_NOEXCEPT*/;
+ uint32_t a_uHttpStatus, uint64_t a_offContent, uint64_t a_cbContent))
+#if defined(__cplusplus) && __cplusplus >= 201700L
+RT_NOEXCEPT
+#endif
+;
/** Pointer to a byte consumer callback. */
typedef FNCONSUMER *PFNCONSUMER;
Index: VirtualBox-7.1.0/src/VBox/Runtime/VBox/VBoxRTImp-gcc.def
===================================================================
--- VirtualBox-7.1.0.orig/src/VBox/Runtime/VBox/VBoxRTImp-gcc.def
+++ VirtualBox-7.1.0/src/VBox/Runtime/VBox/VBoxRTImp-gcc.def
@@ -379,7 +379,7 @@ EXPORTS
_ZN22RTCRestBinaryParameter16xmitHttpCallbackEP14RTHTTPINTERNALPvmyPmS2_ ; int64=llong
_ZN22RTCRestBinaryParameter19setProducerCallbackEPFiPS_PvmmPmES1_m ; before-noexcept int64=long
_ZN22RTCRestBinaryParameter19setProducerCallbackEPFiPS_PvmyPmES1_y ; before-noexcept int64=llong
- _ZN22RTCRestBinaryParameter19setProducerCallbackEPDoFiPS_PvmyPmES1_m ; after-noexcept int64=long
+ _ZN22RTCRestBinaryParameter19setProducerCallbackEPDoFiPS_PvmmPmES1_m ; after-noexcept int64=long
_ZN22RTCRestBinaryParameter19setProducerCallbackEPDoFiPS_PvmyPmES1_y ; after-noexcept int64=llong
_ZN22RTCRestBinaryParameterC1Ev
_ZN22RTCRestBinaryParameterC2Ev
Index: VirtualBox-7.1.0/src/VBox/Runtime/common/rest/rest-binary.cpp
===================================================================
--- VirtualBox-7.1.0.orig/src/VBox/Runtime/common/rest/rest-binary.cpp
+++ VirtualBox-7.1.0/src/VBox/Runtime/common/rest/rest-binary.cpp
@@ -706,3 +706,12 @@ void RTCRestBinaryResponse::receiveCompl
AssertRC(rc);
}
+// extpack was built with wrong -std=, add a redirect
+extern "C" void DECLEXPORT_CLASS __attribute__((weak,
+alias("_ZN21RTCRestBinaryResponse19setConsumerCallbackEPDoFiPS_PKvmjmmEPv"))) // T symbol that exists
+ _ZN21RTCRestBinaryResponse19setConsumerCallbackEPFiPS_PKvmjmmEPv( // W symbol to make
+ RTCRestBinaryResponse::PFNCONSUMER, void *);
+extern "C" void DECLEXPORT_CLASS __attribute__((weak,
+alias("_ZN22RTCRestBinaryParameter19setProducerCallbackEPDoFiPS_PvmmPmES1_m"))) // T
+ _ZN22RTCRestBinaryParameter19setProducerCallbackEPFiPS_PvmmPmES1_m( // W
+ RTCRestBinaryParameter::PFNPRODUCER, void *, uint64_t);