D, Darwin: Restore bootstrap.

Message ID 20250114201042.64693-1-iain@sandoe.co.uk
State New
Headers
Series D, Darwin: Restore bootstrap. |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed

Commit Message

Iain Sandoe Jan. 14, 2025, 8:10 p.m. UTC
  Tested on x86_64, i686 darwin17 and aarch64 darwin21,
OK for trunk, or alternate solution?
thanks,
Iain

--- 8< ---

Recent merges from libphobos have broken bootstrap on many/most Darwin
version (those with 32bit multilibs, 32bit hosts, aarch64 and powerpc).

This is because the thread data are not imported into osthread.d.

Fixed thus:

libphobos/ChangeLog:

	* libdruntime/core/thread/osthread.d: Import thread data for
	i686, aarch64, powerpc and powerpc64.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 libphobos/libdruntime/core/thread/osthread.d | 35 ++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)
  

Comments

Iain Buclaw Jan. 14, 2025, 8:45 p.m. UTC | #1
Excerpts from Iain Sandoe's message of Januar 14, 2025 9:10 pm:
> Tested on x86_64, i686 darwin17 and aarch64 darwin21,
> OK for trunk, or alternate solution?
> thanks,
> Iain
> 

Thank Iain,

Could a pull request be made upstream here?

https://github.com/dlang/dmd/pulls

Location of this module is

https://github.com/dlang/dmd/blob/master/druntime/src/core/thread/osthread.d

> --- 8< ---
> --- a/libphobos/libdruntime/core/thread/osthread.d
> +++ b/libphobos/libdruntime/core/thread/osthread.d
> @@ -81,6 +81,13 @@ else version (PPC)
>          version = AsmExternal;
>      }
>  }
> +else version (PPC64)
> +{
> +    version (Posix)
> +    {
> +        version = AsmExternal;
> +    }
> +}
>  else version (MIPS_O32)
>  {
>      version (Posix)

On reviewing this section, I'm not sure why this entire block for 
defining the AsmExternal version is here in the first place - ucontext 
is not used anywhere throughout the module.

I'd elect to just remove it all.

Everything else looks OK to me.

```
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -59,67 +59,6 @@ else version (D_InlineAsm_X86_64)
         version = AsmX86_64_Posix;
     }
 }
-else version (X86)
-{
-    version (CET) {} else
-    {
-        version = AsmExternal;
-    }
-}
-else version (X86_64)
-{
-    version (CET)   {} else
-    version (D_X32) {} else
-    {
-        version = AsmExternal;
-    }
-}
-else version (PPC)
-{
-    version (Posix)
-    {
-        version = AsmExternal;
-    }
-}
-else version (MIPS_O32)
-{
-    version (Posix)
-    {
-        version = AsmExternal;
-    }
-}
-else version (AArch64)
-{
-    version (Posix)
-    {
-        version = AsmExternal;
-    }
-}
-else version (ARM)
-{
-    version (Posix)
-    {
-        version = AsmExternal;
-    }
-}
-
-version (Posix)
-{
-    version (AsmX86_Windows)    {} else
-    version (AsmX86_Posix)      {} else
-    version (AsmX86_64_Windows) {} else
-    version (AsmX86_64_Posix)   {} else
-    version (AsmExternal)       {} else
-    {
-        // NOTE: The ucontext implementation requires architecture specific
-        //       data definitions to operate so testing for it must be done
-        //       by checking for the existence of ucontext_t rather than by
-        //       a version identifier.  Please note that this is considered
-        //       an obsolescent feature according to the POSIX spec, so a
-        //       custom solution is still preferred.
-        static import core.sys.posix.ucontext;
-    }
-}
 
 version (Windows)
 {
```

Regards,
Iain.
  
Iain Sandoe Jan. 15, 2025, 5:38 p.m. UTC | #2
> On 14 Jan 2025, at 20:45, Iain Buclaw <ibuclaw@gdcproject.org> wrote:
> 
> Excerpts from Iain Sandoe's message of Januar 14, 2025 9:10 pm:
>> Tested on x86_64, i686 darwin17 and aarch64 darwin21,
>> OK for trunk, or alternate solution?
>> thanks,
>> Iain
>> 

> Could a pull request be made upstream here?
> 
> https://github.com/dlang/dmd/pulls

Done.
thanks
Iain
  

Patch

diff --git a/libphobos/libdruntime/core/thread/osthread.d b/libphobos/libdruntime/core/thread/osthread.d
index e5f0cadbbf2..a9470616277 100644
--- a/libphobos/libdruntime/core/thread/osthread.d
+++ b/libphobos/libdruntime/core/thread/osthread.d
@@ -81,6 +81,13 @@  else version (PPC)
         version = AsmExternal;
     }
 }
+else version (PPC64)
+{
+    version (Posix)
+    {
+        version = AsmExternal;
+    }
+}
 else version (MIPS_O32)
 {
     version (Posix)
@@ -157,9 +164,33 @@  else version (Posix)
     {
         import core.sys.darwin.mach.kern_return : KERN_SUCCESS;
         import core.sys.darwin.mach.port : mach_port_t;
-        import core.sys.darwin.mach.thread_act : mach_msg_type_number_t, thread_get_state, thread_resume,
-            thread_suspend, x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT, x86_thread_state64_t;
+        import core.sys.darwin.mach.thread_act : mach_msg_type_number_t,
+            thread_get_state, thread_resume, thread_suspend;
         import core.sys.darwin.pthread : pthread_mach_thread_np;
+        version (X86)
+        {
+            import core.sys.darwin.mach.thread_act :
+              x86_THREAD_STATE32, x86_THREAD_STATE32_COUNT, x86_thread_state32_t;
+        }
+        version (X86_64)
+        {
+            import core.sys.darwin.mach.thread_act :
+              x86_THREAD_STATE64, x86_THREAD_STATE64_COUNT, x86_thread_state64_t;
+        }
+        version (AArch64)
+        {
+            import core.sys.darwin.mach.thread_act : ARM_THREAD_STATE64, ARM_THREAD_STATE64_COUNT, arm_thread_state64_t;
+        }
+        version (PPC)
+        {
+            import core.sys.darwin.mach.thread_act :
+             PPC_THREAD_STATE32, PPC_THREAD_STATE32_COUNT, ppc_thread_state32_t;
+        }
+        version (PPC64)
+        {
+            import core.sys.darwin.mach.thread_act :
+             PPC_THREAD_STATE64, PPC_THREAD_STATE64_COUNT, ppc_thread_state64_t;
+        }
     }
 }