This is an archive of the discontinued LLVM Phabricator instance.

[LLD][MachO] Do not run Mach-O tests on big-endian hosts
ClosedPublic

Authored by uweigand on Apr 26 2023, 10:10 AM.

Details

Summary

Currently, most Mach-O tests fail when executed on a big-endian host. This is because the Mach-O back-end does not perform the necessary byte swaps when accessing the (little-endian) binary file format.

To fix this properly would either require use of the various swapStruct routines from the BinaryFormat/MachO.h header, or else a re-write of those headers to use ulittle32 etc. data types.

For now, simply consider all Mach-O tests unsupported on big-endian hosts (specifically, SystemZ), to enable running the test suite at all on such hosts.

Diff Detail

Event Timeline

uweigand created this revision.Apr 26 2023, 10:10 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 26 2023, 10:10 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
uweigand requested review of this revision.Apr 26 2023, 10:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 10:10 AM
oontvoo added inline comments.
lld/test/MachO/lit.local.cfg
8–9

How about using the existing host-byteorder-little-endian/host-byteorder-big-endian?

either adding this:

REQUIRES: host-byteorder-little-endian

or just checking "host-byteorder-little-endian" in config.available_features ?

uweigand updated this revision to Diff 517882.Apr 28 2023, 5:50 AM

Use sys.byteorder to test for big-endian hosts.

uweigand marked an inline comment as done.Apr 28 2023, 5:51 AM
uweigand added inline comments.
lld/test/MachO/lit.local.cfg
8–9

Turns out those features are only available in the llvm test suite, not the lld test suite right now. I guess they could be added there, but for now I'm just directly checking sys.byteorder to identify big-endian hosts.

oontvoo accepted this revision.May 1 2023, 5:47 AM

LG - thanks!

This revision is now accepted and ready to land.May 1 2023, 5:47 AM
This revision was automatically updated to reflect the committed changes.
uweigand marked an inline comment as done.