From 03fff3572ff60bc1119ac3dfbb0883247e3a83cf Mon Sep 17 00:00:00 2001 From: Itms Date: Mon, 4 Aug 2025 14:39:56 +0200 Subject: [PATCH] Use conforming preprocessor with modern MSVC https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview --- build/premake/premake5.lua | 5 +++ libraries/get-windows-libs.bat | 2 +- libraries/source/spidermonkey/build.sh | 6 --- .../patches/FixHeadersForMSVC.diff | 38 ------------------- source/lib/sysdep/os/win/wdbg_sym.cpp | 2 +- 5 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 libraries/source/spidermonkey/patches/FixHeadersForMSVC.diff diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua index b64164ceed..68a775fb08 100644 --- a/build/premake/premake5.lua +++ b/build/premake/premake5.lua @@ -296,6 +296,11 @@ function project_set_build_flags() -- Finally since VS2012 it's enabled implicitely when not set. vectorextensions "SSE2" + -- SpiderMonkey only supports building with MSVC on a best-effort basis, + -- and the traditional MSVC preprocessor is incompatible with some headers. + -- Use the modern, standard-compliant MSVC preprocessor instead. + usestandardpreprocessor "On" + -- use native wchar_t type (not typedef to unsigned short) nativewchar "on" diff --git a/libraries/get-windows-libs.bat b/libraries/get-windows-libs.bat index 0be2d94359..91c1b6b930 100644 --- a/libraries/get-windows-libs.bat +++ b/libraries/get-windows-libs.bat @@ -4,7 +4,7 @@ cd /D "%~dp0" rem **SVN revision to checkout for windows-libs or windows-libs-amd64** rem **Update this line when you commit an update to windows-libs or windows-libs-amd64** -set "svnrev=28267" +set "svnrev=28268" if "%1" == "--amd64" ( set "LIBS_PATH=win64" diff --git a/libraries/source/spidermonkey/build.sh b/libraries/source/spidermonkey/build.sh index 8b322a7778..6e5dfaf9eb 100755 --- a/libraries/source/spidermonkey/build.sh +++ b/libraries/source/spidermonkey/build.sh @@ -205,12 +205,6 @@ if [ "${OS}" = "Windows_NT" ]; then cd "${FOLDER}"/build-release/dist/include rm -f mozzconf.h zconf.h zlib.h ) - - # SpiderMonkey can be linked/included in projects built with MSVC, however, since clang is now the only - # supported compiler on Windows, the codebase has accumulated some divergences with MSVC. - # Upstream tries on a best-effort basis to keep the SM headers MSVC-compatible. - patch -d "${FOLDER}"/build-debug/dist/include -p1 - class ResultImplementation { -+// These assertions fail with MSVC 14.1. Similar bugs: -+// https://bugzilla.mozilla.org/show_bug.cgi?id=1778246 -+// https://bugzilla.mozilla.org/show_bug.cgi?id=1778247 -+// TODO: test with recent MSVC before reporting a bug -+#ifndef _MSC_VER - static_assert(std::is_trivially_copyable_v && - std::is_trivially_destructible_v); - static_assert(std::is_trivially_copyable_v && - std::is_trivially_destructible_v); -+#endif - - static constexpr size_t kRequiredSize = std::max(sizeof(V), sizeof(E)); - diff --git a/source/lib/sysdep/os/win/wdbg_sym.cpp b/source/lib/sysdep/os/win/wdbg_sym.cpp index a80a2e66d4..17c19d69c0 100644 --- a/source/lib/sysdep/os/win/wdbg_sym.cpp +++ b/source/lib/sysdep/os/win/wdbg_sym.cpp @@ -1337,7 +1337,7 @@ static bool udt_should_suppress(const wchar_t* type_name) // removed obsolete defs: HEVENT, HFILE, HUMPD if(type_name[0] != 'H') goto not_handle; -#define SUPPRESS_HANDLE(name) if(!wcscmp(type_name, L#name L"__")) return true; +#define SUPPRESS_HANDLE(name) if(!wcscmp(type_name, L""#name L"__")) return true; SUPPRESS_HANDLE(HACCEL); SUPPRESS_HANDLE(HBITMAP); SUPPRESS_HANDLE(HBRUSH);