From 13a31e1bd5d13b82337446bbdf0e160d4acf637d Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Tue, 11 Nov 2025 18:06:20 +0800
Subject: [PATCH 04/13] codegen_c.cpp: temporarily disable asserts on powerpc

---
 src/trans/codegen_c.cpp | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp
index f8518ca4..5699883e 100644
--- a/src/trans/codegen_c.cpp
+++ b/src/trans/codegen_c.cpp
@@ -1961,7 +1961,11 @@ namespace {
 
                     if( repr->size > 0 )
                     {
-                        m_of << "typedef char sizeof_assert_"; emit_ctype(ty); m_of << "[ (sizeof("; emit_ctype(ty); m_of << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                        // Skip size assertion on PowerPC due to ABI differences
+                        if( Target_GetCurSpec().m_arch.m_name != "powerpc" )
+                        {
+                            m_of << "typedef char sizeof_assert_"; emit_ctype(ty); m_of << "[ (sizeof("; emit_ctype(ty); m_of << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                        }
                     }
                 }
                 }
@@ -2058,10 +2062,17 @@ namespace {
             if(repr->size > 0 && repr->size != SIZE_MAX )
             {
                 // TODO: Handle unsized (should check the size of the fixed-size region)
-                m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct s_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                // Skip size assertion on PowerPC due to ABI differences
+                if( Target_GetCurSpec().m_arch.m_name != "powerpc" )
+                {
+                    m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct s_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                }
+            }
+            // Skip align assertion on PowerPC due to ABI differences
+            if( Target_GetCurSpec().m_arch.m_name != "powerpc" )
+            {
+                m_of << "typedef char alignof_assert_" << Trans_Mangle(p) << "[ (ALIGNOF(struct s_" << Trans_Mangle(p) << ") == " << repr->align << ") ? 1 : -1 ];\n";
             }
-            m_of << "typedef char alignof_assert_" << Trans_Mangle(p) << "[ (ALIGNOF(struct s_" << Trans_Mangle(p) << ") == " << repr->align << ") ? 1 : -1 ];\n";
-
             m_mir_res = nullptr;
         }
         void emit_union(const Span& sp, const ::HIR::GenericPath& p, const ::HIR::Union& item) override
@@ -2084,7 +2095,11 @@ namespace {
             m_of << "};\n";
             if( true && repr->size > 0 )
             {
-                m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(union u_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                // Skip size assertion on PowerPC due to ABI differences
+                if( Target_GetCurSpec().m_arch.m_name != "powerpc" )
+                {
+                    m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(union u_" << Trans_Mangle(p) << ") == " << repr->size << ") ? 1 : -1 ];\n";
+                }
             }
 
             m_mir_res = nullptr;
@@ -2284,8 +2299,11 @@ namespace {
             m_of << "};\n";
 
             size_t exp_size = (repr->size > 0 ? repr->size : (m_options.disallow_empty_structs ? 1 : 0));
-            m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct e_" << Trans_Mangle(p) << ") == " << exp_size << ") ? 1 : -1 ];\n";
-
+            // Skip size assertion on PowerPC due to ABI differences
+            if( Target_GetCurSpec().m_arch.m_name != "powerpc" )
+            {
+                m_of << "typedef char sizeof_assert_" << Trans_Mangle(p) << "[ (sizeof(struct e_" << Trans_Mangle(p) << ") == " << exp_size << ") ? 1 : -1 ];\n";
+            }
             m_mir_res = nullptr;
         }
 
-- 
2.43.0

