dolphin/Source/Core
Dentomologist 58ab94c30c GCC: Suppress PPCSTATE_OFF invalid-offsetof warnings
Modify PPCSTATE_OFF and PPCSTATE_OFF_ARRAY macros when using GCC to
avoid useless log spam. Specifically, use a consteval lambda with gcc
_Pragma statements to disable the -Winvalid-offsetof warning inside the
macros.

Each successful build (and many failing ones) on the Android buildbot
generates almost 300 cases of -Winvalid-offsetof, resulting in thousands
of lines of log spam per build. In addition to bloating the log filesize
these spurious warnings make it harder to find actual warnings.

These warnings are generated by calls to the macros PPCSTATE_OFF and
PPCSTATE_OFF_ARRAY, which in turn are used by many other macros used by
the JIT. The ultimate cause is that offsetof is only conditionally
supported on non-standard-layout types, which includes the PowerPCState
struct.

To address potential questions of whether there's a better way to handle
this:

The obvious solution would be to modify PowerPCState so that it does
have a standard layout. This is unfortunately impractical.

To have a standard layout a type can only contain other types with
standard layouts. None of the stl containers are guaranteed to have
standard layouts, and PowerPCState contains a std::tuple and std::array.
PowerPCState also contains a PowerPC::Cache and InstructionCache which
themselves contain std:arrays and std::vectors.

Furthermore InstructionCache derives from Cache, and a derived class can
only have standard layout if at most one class in its hierarchy has a
non-static data member, but both classes have such members. Making
InstructionCache have a standard layout would require duplicating all
the functionality of Cache so it no longer derived from it, as well as
replacing the stl containers. This might require having a raw pointer to
said containers, with the manual memory management that implies.

All of that would be much more disruptive than would be justified to get
rid of some warnings (however annoying they might be). This is
compounded by the fact that PowerPCState hasn't had a standard layout
for a long time, if ever, and if the PPCSTATE_OFF macros weren't working
reliably it would have become obvious a long time ago.

As to why I picked the lambda solution over other potential changes:

- Keeping the define as-is and wrapping some gcc #pragmas around it
  doesn't work because the pragmas don't get included when the define is
  substituted to the call site.

- Keeping the define as a non-lambda expression and using inline
  _Pragma() statements would ideally be better and works fine for msvc,
  but fails for GCC with "'#pragma' is not allowed here".

- Turning off -Winvalid-offsetof globally for gcc would work, but there
  might be other contexts where offsetof is problematic and GCC seems to
  be the only compiler warning about it.
2023-08-21 14:01:11 -07:00
..
AudioCommon cubeb: Change name to "Dolphin Emulator" 2023-07-22 23:12:34 +02:00
Common NandPaths: Use initializer_list instead of unordered_set 2023-08-12 14:00:41 -07:00
Core GCC: Suppress PPCSTATE_OFF invalid-offsetof warnings 2023-08-21 14:01:11 -07:00
DiscIO Merge pull request #11955 from TellowKrinkle/CMakeDependencies 2023-06-30 19:06:04 +02:00
DolphinNoGUI Merge pull request #11873 from AdmiralCurtiss/pause-and-lock-host 2023-06-06 13:50:20 +02:00
DolphinQt DolphinQt/TASInputWindow: Make 'Enable Controller Input' translatable. 2023-08-18 21:02:30 +02:00
DolphinTool Merge pull request #11960 from Minty-Meeo/dolphin-tool-code-review-4 2023-06-17 14:18:21 +02:00
InputCommon Merge pull request #12083 from JosJuice/android-controlled-by-gamepad 2023-08-18 21:27:26 +02:00
MacUpdater CMake: Fix storyboard copying 2023-04-29 16:10:38 -05:00
UICommon Merge pull request #11955 from TellowKrinkle/CMakeDependencies 2023-06-30 19:06:04 +02:00
UpdaterCommon CMake: Use targets for all optionally-external dependencies 2023-06-15 01:41:41 -05:00
VideoBackends VideoBackends: update SRVDescriptorTable size in DX12 to use pixel sampler constant 2023-08-13 17:23:26 -05:00
VideoCommon Video: fix post process shaders with parameters failing to build on OpenGL 2023-08-18 02:00:56 +03:00
WinUpdater StringUtil: Move CommandLineToUtf8Argv() into Common namespace 2023-05-16 14:23:21 -04:00
CMakeLists.txt
DolphinLib.ARM64.props
DolphinLib.props VideoCommon: add material asset. A material is similar to other graphics engines where it provides data to be used in conjunction with a shader asset to generate a runtime AbstractShader 2023-07-09 12:21:34 -05:00
DolphinLib.vcxproj Added rcheevos to Externals 2023-04-02 08:28:23 -04:00
DolphinLib.vcxproj.user
DolphinLib.x64.props