From 502f5b8a59709ca4090dabcc4b5016fd5ef55077 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Thu, 11 May 2023 16:33:36 +0200 Subject: [PATCH] vbox6: fix build errors with GCC 12 The fixes were manually backported from virtualbox-trunk. Issue genodelabs/genode#4827 Fixes genodelabs/genode#4846 --- repos/ports/ports/virtualbox6.hash | 2 +- .../src/virtualbox6/patches/gcc-12.patch | 129 ++++++++++++++++++ repos/ports/src/virtualbox6/patches/series | 1 + 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 repos/ports/src/virtualbox6/patches/gcc-12.patch diff --git a/repos/ports/ports/virtualbox6.hash b/repos/ports/ports/virtualbox6.hash index 5f92a93bf2..e4f71ffe2b 100644 --- a/repos/ports/ports/virtualbox6.hash +++ b/repos/ports/ports/virtualbox6.hash @@ -1 +1 @@ -7206beec5f83e36d8ed850537ae730d862e790d5 +eab4c504647fc26a2a6713ceffef070c4caeb9ef diff --git a/repos/ports/src/virtualbox6/patches/gcc-12.patch b/repos/ports/src/virtualbox6/patches/gcc-12.patch new file mode 100644 index 0000000000..d5d327d3c3 --- /dev/null +++ b/repos/ports/src/virtualbox6/patches/gcc-12.patch @@ -0,0 +1,129 @@ +Build fixes for GCC 12 + +diff -ur a/src/virtualbox6/include/iprt/string.h b/src/virtualbox6/include/iprt/string.h +--- a/src/virtualbox6/include/iprt/string.h 2023-05-11 15:11:18.126829715 +0200 ++++ b/src/virtualbox6/include/iprt/string.h 2023-05-11 16:20:57.408769851 +0200 +@@ -2639,17 +2639,15 @@ + #if defined(__cplusplus) && !defined(DOXYGEN_RUNNING) + DECLINLINE(char const *) RTStrEnd(char const *pszString, size_t cchMax) + { +- /* Avoid potential issues with memchr seen in glibc. +- * See sysdeps/x86_64/memchr.S in glibc versions older than 2.11 */ +- while (cchMax > RTSTR_MEMCHR_MAX) ++ while (cchMax-- > 0) + { +- char const *pszRet = (char const *)memchr(pszString, '\0', RTSTR_MEMCHR_MAX); +- if (RT_LIKELY(pszRet)) +- return pszRet; +- pszString += RTSTR_MEMCHR_MAX; +- cchMax -= RTSTR_MEMCHR_MAX; ++ if (*pszString) ++ { } ++ else ++ return pszString; ++ pszString++; + } +- return (char const *)memchr(pszString, '\0', cchMax); ++ return NULL; + } + + DECLINLINE(char *) RTStrEnd(char *pszString, size_t cchMax) +@@ -2657,17 +2655,15 @@ + DECLINLINE(char *) RTStrEnd(const char *pszString, size_t cchMax) + #endif + { +- /* Avoid potential issues with memchr seen in glibc. +- * See sysdeps/x86_64/memchr.S in glibc versions older than 2.11 */ +- while (cchMax > RTSTR_MEMCHR_MAX) ++ while (cchMax-- > 0) + { +- char *pszRet = (char *)memchr(pszString, '\0', RTSTR_MEMCHR_MAX); +- if (RT_LIKELY(pszRet)) +- return pszRet; +- pszString += RTSTR_MEMCHR_MAX; +- cchMax -= RTSTR_MEMCHR_MAX; ++ if (*pszString) ++ { } ++ else ++ return pszString; ++ pszString++; + } +- return (char *)memchr(pszString, '\0', cchMax); ++ return NULL; + } + + RT_C_DECLS_BEGIN +Only in b/src/virtualbox6/include/iprt: string.h~ +diff -ur a/src/virtualbox6/src/VBox/Devices/PC/DevFwCommon.cpp b/src/virtualbox6/src/VBox/Devices/PC/DevFwCommon.cpp +--- a/src/virtualbox6/src/VBox/Devices/PC/DevFwCommon.cpp 2023-05-11 15:11:18.066827479 +0200 ++++ b/src/virtualbox6/src/VBox/Devices/PC/DevFwCommon.cpp 2023-05-11 16:05:19.081789735 +0200 +@@ -485,7 +485,7 @@ + return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS, \ + N_("Configuration error: Querying \"" name "\" as a string failed")); \ + } \ +- else if (!strcmp(szBuf, "")) \ ++ if (!strcmp(szBuf, "")) \ + pszTmp = ""; \ + else \ + pszTmp = szBuf; \ +@@ -529,12 +529,10 @@ + pszStr = (char *)(tbl + 1); \ + iStrNr = 1; + +-#define DMI_TERM_STRUCT \ +- { \ +- *pszStr++ = '\0'; /* terminate set of text strings */ \ +- if (iStrNr == 1) \ +- *pszStr++ = '\0'; /* terminate a structure without strings */ \ +- } ++#define DMI_TERM_STRUCT do { \ ++ size_t const cbToZero = iStrNr == 1 ? 2 : 1; \ ++ pszStr = (char *)memset(pszStr, 0, cbToZero) + cbToZero; \ ++ } while (0) + + bool fForceDefault = false; + #ifdef VBOX_BIOS_DMI_FALLBACK +diff -ur a/src/virtualbox6/src/VBox/Main/src-server/MediumImpl.cpp b/src/virtualbox6/src/VBox/Main/src-server/MediumImpl.cpp +--- a/src/virtualbox6/src/VBox/Main/src-server/MediumImpl.cpp 2023-05-11 15:11:17.622810926 +0200 ++++ b/src/virtualbox6/src/VBox/Main/src-server/MediumImpl.cpp 2023-05-11 16:19:31.669573557 +0200 +@@ -64,6 +64,9 @@ + // + //////////////////////////////////////////////////////////////////////////////// + ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wdeprecated-declarations" ++ + struct SnapshotRef + { + /** Equality predicate for stdc++. */ +@@ -134,6 +137,9 @@ + + typedef std::list BackRefList; + ++#pragma GCC diagnostic pop ++ ++ + struct Medium::Data + { + Data() +diff -ur a/src/virtualbox6/src/VBox/Main/src-server/PerformanceImpl.cpp b/src/virtualbox6/src/VBox/Main/src-server/PerformanceImpl.cpp +--- a/src/virtualbox6/src/VBox/Main/src-server/PerformanceImpl.cpp 2023-05-11 15:11:17.622810926 +0200 ++++ b/src/virtualbox6/src/VBox/Main/src-server/PerformanceImpl.cpp 2023-05-11 16:12:30.989890953 +0200 +@@ -644,6 +644,8 @@ + NOREF(hTimerLR); + } + ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* + * Metrics collection is a three stage process: + * 1) Pre-collection (hinting) +@@ -723,6 +725,8 @@ + Log4Func(("{%p}: LEAVE\n", this)); + } + ++#pragma GCC diagnostic pop ++ + //////////////////////////////////////////////////////////////////////////////// + // PerformanceMetric class + //////////////////////////////////////////////////////////////////////////////// diff --git a/repos/ports/src/virtualbox6/patches/series b/repos/ports/src/virtualbox6/patches/series index 01f24ee894..9e10067760 100644 --- a/repos/ports/src/virtualbox6/patches/series +++ b/repos/ports/src/virtualbox6/patches/series @@ -10,3 +10,4 @@ devsvga.patch shaderlib.patch svga.patch audio.patch +gcc-12.patch