[llvm] [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC (PR #100086)
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 01:49:20 PDT 2024
https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/100086
>From 76aac12c26e68a19ab95e99c9f9d2d214bcad744 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Tue, 23 Jul 2024 11:10:12 +0200
Subject: [PATCH 1/3] [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC
As discussed in Issue #86793, the `MachOTest.UnalignedLC` test dies with
SIGBUS on SPARC, a strict-alignment target. It simply cannot work there,
so this patch disables it.
Given that there's doubt about the test's correctnes, one might consider
disabling it wholesale.
Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.
---
llvm/unittests/BinaryFormat/MachOTest.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index 391298ff38d76..b64efce52d321 100644
--- a/llvm/unittests/BinaryFormat/MachOTest.cpp
+++ b/llvm/unittests/BinaryFormat/MachOTest.cpp
@@ -13,7 +13,15 @@
using namespace llvm;
using namespace llvm::MachO;
-TEST(MachOTest, UnalignedLC) {
+#if defined(__sparc__)
+// As discussed in Issue #86793, this test cannot work on a strict-alignment
+// targets like SPARC. The test may even be invalid.
+#define MAYBE_UnalignedLC DISABLED_UnalignedLC
+#else
+#define MAYBE_UnalignedLC UnalignedLC
+#endif
+
+TEST(MachOTest, MAYBE_UnalignedLC) {
unsigned char Valid32BitMachO[] = {
0xCE, 0xFA, 0xED, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
>From 5d0039e124a583ad4c43d27c55cf7fe5c27f5ac2 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Tue, 30 Jul 2024 11:37:07 +0200
Subject: [PATCH 2/3] Disable on all big-endian targets.
---
llvm/unittests/BinaryFormat/MachOTest.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index b64efce52d321..ad20f891fd97a 100644
--- a/llvm/unittests/BinaryFormat/MachOTest.cpp
+++ b/llvm/unittests/BinaryFormat/MachOTest.cpp
@@ -13,9 +13,9 @@
using namespace llvm;
using namespace llvm::MachO;
-#if defined(__sparc__)
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// As discussed in Issue #86793, this test cannot work on a strict-alignment
-// targets like SPARC. The test may even be invalid.
+// targets like SPARC. Besides, it's undefined behaviour on big-endian hosts.
#define MAYBE_UnalignedLC DISABLED_UnalignedLC
#else
#define MAYBE_UnalignedLC UnalignedLC
>From d238831d828149fb396d703f601c9783bcc37ba6 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Fri, 2 Aug 2024 10:48:46 +0200
Subject: [PATCH 3/3] Switch to BYTE_ORDER, BIG_ENDIAN.
---
llvm/unittests/BinaryFormat/MachOTest.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index ad20f891fd97a..78b20c28a9549 100644
--- a/llvm/unittests/BinaryFormat/MachOTest.cpp
+++ b/llvm/unittests/BinaryFormat/MachOTest.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/bit.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/TargetParser/Triple.h"
#include "gtest/gtest.h"
@@ -13,7 +14,7 @@
using namespace llvm;
using namespace llvm::MachO;
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#if BYTE_ORDER == BIG_ENDIAN
// As discussed in Issue #86793, this test cannot work on a strict-alignment
// targets like SPARC. Besides, it's undefined behaviour on big-endian hosts.
#define MAYBE_UnalignedLC DISABLED_UnalignedLC
More information about the llvm-commits
mailing list