Apply StormLib big-endian build fixes to the vendored copy - #519
Conversation
The bundled StormLib is missing the big-endian fixes from upstream StormLib commit d1b47ab454e9f20589c6b47c78e5875e19888cdf, so the build fails on big-endian platforms such as macppc. On big-endian the BSWAP_ARRAY macros expand to real calls, and two of them reference symbols that do not exist in scope: SFilePatchArchives.cpp: pPatchHeader instead of &PatchHeader SFileAttributes.cpp: cbCRC32Size / cbFileTimeSize instead of cbArraySize which breaks compilation. The patch also corrects the version checks in ConvertTMPQHeader (== to >=, so higher format versions still get the lower-version byte swaps) and the Platform/Reserved field order in the big-endian branch of TMPQHash. Verified by forcing the big-endian path (-D__BIG_ENDIAN__) with a big-endian MIPS cross compiler: the three affected files fail to compile before this change and compile cleanly after. Fixes Wargus#518.
|
Confirmed on real PowerPC hardware. I reproduced and fixed this on a Power Mac G5 (Darwin/PowerPC, big-endian) which is the same macppc family as the build log in #518. The compiler auto-defines Before the patch (native G5, gcc 10.5): After the patch, all three affected files compile clean. So this is verified end to end on actual big-endian PowerPC silicon, not only by forcing the BE macros under cross-compilation. |
|
Wonder if we can use submodule instead of embedding source here... |
|
Good call, a submodule would be cleaner than the embedded copy. master already vendors StormLib via the dependencies submodule, so this would line this branch up with that. For this PR the embedded copy is what breaks the big-endian build today, so the four line fix unblocks macppc right now. Happy to leave it as the minimal embedded-source fix, or rework it as a StormLib submodule bump pointing at a commit that already includes the upstream big-endian fix (d1b47ab), whichever direction you prefer to merge. |
|
Agreed, and it would fix the root cause more cleanly than carrying a patch. The big-endian fixes in this PR are already upstream in StormLib (ladislav-zezula/StormLib commit d1b47ab), so if the embedded To be precise about the current layout:
I am happy to rework this PR into whichever of those you prefer. If you would rather keep the in-tree copy for now, the four line fix here already unblocks the big-endian build, and the submodule migration can land as a separate change. Just let me know the direction. |
|
Merged for now to fix the issue. Wargus/dependencies submodule is also a inline copy of other repos, so not a clean option for me :-( .
seems the cleaner option for me. So use the official repo directly. |
Fixes #518.
The bundled StormLib is missing the big-endian fixes from upstream StormLib commit
d1b47ab, so the build fails on big-endian platforms such as macppc (the build log referenced in #518).Why it breaks the build
On big-endian the
BSWAP_ARRAY*macros expand to real calls (they are no-ops on little-endian, which is why CI never caught it). Two of them reference symbols that do not exist in scope:SFilePatchArchives.cpp:pPatchHeaderinstead of&PatchHeaderSFileAttributes.cpp:cbCRC32Size/cbFileTimeSizeinstead ofcbArraySizeThe patch also fixes two correctness issues in the same upstream commit: the version checks in
ConvertTMPQHeader(==to>=, so higher MPQ format versions still get the lower-version byte swaps) and thePlatform/Reservedfield order in the big-endian branch ofTMPQHash.Verification
I forced the big-endian path (
-D__BIG_ENDIAN__) with a big-endian MIPS cross compiler. The three affected files fail to compile before this change ('pPatchHeader' was not declared,'cbCRC32Size' was not declared,'cbFileTimeSize' was not declared) and compile cleanly after. This is a straight application of the upstream StormLib fix to the vendored copy.