X Tutup
Skip to content

SCUMM: Fix build with UBSan and SCUMM engine disabled#6372

Merged
bluegr merged 2 commits intoscummvm:masterfrom
lephilousophe:fix-scumm-ubsan
Dec 28, 2024
Merged

SCUMM: Fix build with UBSan and SCUMM engine disabled#6372
bluegr merged 2 commits intoscummvm:masterfrom
lephilousophe:fix-scumm-ubsan

Conversation

@lephilousophe
Copy link
Member

When building with the Undefined Behaviour Sanitizer (UBSan) and the SCUMM engine disabled, the linker fails to find the ScummEngine typeinfo needed by the UBSan instrumentation code in file.cpp.

That's because several classes in file.cpp need a pointer to a ScummEngine object and UBSan tries to check their type at runtime.
This code is not used in the detection code and could be cleaned up by the linker before resolving the references but that's not done in this order.

So, to avoid problems, I split the classes in another file which is only built with the engine and not the detection code.

In addition, I move the debug flags in detection.h to avoid including scumm.h in the detection code.
That was that or adding a declaration for the ScummFile class in scumm.h.

It's used by detection code and avoids including scumm.h in the
detection code.
This creates a specific translation unit for the code making use of
ScummEngine while keeping file.cpp for the classes needed for the
detection code.

This allows to build with UBSan while the Scumm engine is disabled.
@bluegr
Copy link
Member

bluegr commented Dec 28, 2024

Nice work! This cleanly separates the file related code used for detection

@bluegr bluegr merged commit 9db7dc7 into scummvm:master Dec 28, 2024
@lephilousophe lephilousophe deleted the fix-scumm-ubsan branch January 4, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup