Skip to content

Fix stmt-seq-macho.test for little endian platforms #137017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025

Conversation

alx32
Copy link
Contributor

@alx32 alx32 commented Apr 23, 2025

The test YAML was created on a little-endian system, so its data is stored in little-endian order. When the test runs on a big-endian host, yaml2obj defaults to the host’s byte order, misreading the file as big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing that yaml2obj always uses the correct byte order, no matter which machine runs the test.

The reason that during creation, obj2yaml doesn't specify the endiadness is because the endiadness is set as an optional parameter and therefore it won't be specified if it matches the platform default. Ref:

IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,

The test YAML was created on a little-endian system, so its data is stored in little-endian order. When the test runs on a big-endian host, yaml2obj defaults to the host’s byte order, misreading the file as big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing that yaml2obj always uses the correct byte order, no matter which machine runs the test.
@alx32 alx32 marked this pull request as ready for review April 23, 2025 16:43
@alx32 alx32 requested a review from JDevlieghere as a code owner April 23, 2025 16:43
@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/pr-subscribers-debuginfo

Author: None (alx32)

Changes

The test YAML was created on a little-endian system, so its data is stored in little-endian order. When the test runs on a big-endian host, yaml2obj defaults to the host’s byte order, misreading the file as big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing that yaml2obj always uses the correct byte order, no matter which machine runs the test.

The reason that during creation, obj2yaml doesn't specify the endiadness is because the endiadness is set as an optional parameter and therefore it won't be specified if it matches the platform default. Ref:

IO.mapOptional("IsLittleEndian", Object.IsLittleEndian,


Full diff: https://github.com/llvm/llvm-project/pull/137017.diff

1 Files Affected:

  • (modified) llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test (+4-2)
diff --git a/llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test b/llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test
index 1e08bc07e14cb..07659d95270cd 100644
--- a/llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test
+++ b/llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test
@@ -83,14 +83,15 @@ ld64.lld \
 
 # Convert executable to YAML for the test
 echo "#--- stmt_seq_macho.o.yaml"
-obj2yaml stmt_seq_macho.o
+obj2yaml stmt_seq_macho.o | sed '1a IsLittleEndian: true'
 echo ""
 echo "#--- stmt_seq_macho.exe.yaml"
-obj2yaml stmt_seq_macho.exe
+obj2yaml stmt_seq_macho.exe | sed '1a IsLittleEndian: true'
 
 #--- stmt-seq-macho.yaml
 #--- stmt_seq_macho.o.yaml
 --- !mach-o
+IsLittleEndian: true
 FileHeader:
   magic:           0xFEEDFACF
   cputype:         0x100000C
@@ -1564,6 +1565,7 @@ DWARF:
 
 #--- stmt_seq_macho.exe.yaml
 --- !mach-o
+IsLittleEndian: true
 FileHeader:
   magic:           0xFEEDFACF
   cputype:         0x100000C

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix the problem on big-endian platforms. LGTM, thanks!

Copy link
Collaborator

@hubert-reinterpretcast hubert-reinterpretcast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; thanks!

@alx32 alx32 merged commit 98eb476 into llvm:main Apr 23, 2025
6 of 10 checks passed
@alx32 alx32 linked an issue Apr 24, 2025 that may be closed by this pull request
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
The test YAML was created on a little-endian system, so its data is
stored in little-endian order. When the test runs on a big-endian host,
yaml2obj defaults to the host’s byte order, misreading the file as
big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing
that yaml2obj always uses the correct byte order, no matter which
machine runs the test.

The reason that during creation, obj2yaml doesn't specify the endianness
is because the endianness is set as an optional parameter and therefore
it won't be specified if it matches the platform default. Ref:
https://github.com/llvm/llvm-project/blob/d7215c0ee2e4bca1ce87b956335ef6a2cddaf16f/llvm/lib/ObjectYAML/MachOYAML.cpp#L105
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
The test YAML was created on a little-endian system, so its data is
stored in little-endian order. When the test runs on a big-endian host,
yaml2obj defaults to the host’s byte order, misreading the file as
big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing
that yaml2obj always uses the correct byte order, no matter which
machine runs the test.

The reason that during creation, obj2yaml doesn't specify the endianness
is because the endianness is set as an optional parameter and therefore
it won't be specified if it matches the platform default. Ref:
https://github.com/llvm/llvm-project/blob/d7215c0ee2e4bca1ce87b956335ef6a2cddaf16f/llvm/lib/ObjectYAML/MachOYAML.cpp#L105
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
The test YAML was created on a little-endian system, so its data is
stored in little-endian order. When the test runs on a big-endian host,
yaml2obj defaults to the host’s byte order, misreading the file as
big-endian and causing a failure.

This change explicitly marks the YAML as little-endian, guaranteeing
that yaml2obj always uses the correct byte order, no matter which
machine runs the test.

The reason that during creation, obj2yaml doesn't specify the endianness
is because the endianness is set as an optional parameter and therefore
it won't be specified if it matches the platform default. Ref:
https://github.com/llvm/llvm-project/blob/d7215c0ee2e4bca1ce87b956335ef6a2cddaf16f/llvm/lib/ObjectYAML/MachOYAML.cpp#L105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LLVM :: tools/dsymutil/ARM/stmt-seq-macho.test FAILs
5 participants