-- v3: winebuild: spec32.c: A couple changes to get a build on Linux ARM64
From: Mike slavo5150@yahoo.com
--- tools/winebuild/spec32.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index fb2ce884e28..cf33e9a47e4 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -98,6 +98,7 @@ static int has_relays( struct exports *exports ) { int i;
+ if (target.cpu == CPU_ARM64) return 0; if (target.cpu == CPU_ARM64EC) return 0;
for (i = exports->base; i <= exports->limit; i++) @@ -762,10 +763,32 @@ void output_module( DLLSPEC *spec ) break; default: output( "\n\t.section ".init","ax"\n" ); - output( "\tjmp 1f\n" ); + switch (target.cpu) + { + case CPU_i386: + case CPU_x86_64: + output( "\tjmp 1f\n" ); + break; + case CPU_ARM: + case CPU_ARM64: + case CPU_ARM64EC: + output( "\tb .L1\n" ); + break; + } output( "__wine_spec_pe_header:\n" ); output( "\t.skip %u\n", 65536 + page_size ); - output( "1:\n" ); + switch (target.cpu) + { + case CPU_i386: + case CPU_x86_64: + output( "1:\n" ); + break; + case CPU_ARM: + case CPU_ARM64: + case CPU_ARM64EC: + output( ".L1:\n" ); + break; + } break; }
The code you changed is only used for ELF builds, but that's not going to work on ARM64, you need a PE build.
Did you hack configure to make it build, or did the PE detection fail for some reason?
On Fri Jun 13 20:05:16 2025 +0000, Alexandre Julliard wrote:
The code you changed is only used for ELF builds, but that's not going to work on ARM64, you need a PE build. Did you hack configure to make it build, or did the PE detection fail for some reason?
I did not make any changes to configure, so I guess PE detection failed.
On Fri Jun 13 20:05:16 2025 +0000, Mike wrote:
I did not make any changes to configure, so I guess PE detection failed.
Could you please send me your config.log?
On Fri Jun 13 20:31:08 2025 +0000, Alexandre Julliard wrote:
Could you please send me your config.log?
[config.log](/uploads/2daea8ef49a06adf69bbeb359178ee8f/config.log)
On Mon Jun 16 00:24:58 2025 +0000, Mike wrote:
[config.log](/uploads/2daea8ef49a06adf69bbeb359178ee8f/config.log)
Thanks. Everything looks good, so my guess is you are running into the make install bug (#58269).
On Mon Jun 16 07:49:24 2025 +0000, Alexandre Julliard wrote:
Thanks. Everything looks good, so my guess is you are running into the make install bug (#58269).
I'll try 10.10 soon. But are we talking about the same thing? Wine builds fine for me. The problem is I'm trying to use `winegcc` which calls `winebuild` in order to build a DLL on an ARM64 Linux device. In that scenario `winebuild` is generating Intel code, and that is what I attempted to fix with this MR.
On Mon Jun 16 09:00:10 2025 +0000, Mike wrote:
I'll try 10.10 soon. But are we talking about the same thing? Wine builds fine for me. The problem is I'm trying to use `winegcc` which calls `winebuild` in order to build a DLL on an ARM64 Linux device. In that scenario `winebuild` is generating Intel code, and that is what I attempted to fix with this MR.
Ah I see. Yes, you'd need to pass `-target aarch64-windows` or equivalent to `winegcc`, the same way it's done when building Wine itself. We should probably make winegcc refuse to build ELF libraries on ARM64.
On Mon Jun 16 09:07:07 2025 +0000, Alexandre Julliard wrote:
Ah I see. Yes, you'd need to pass `-target aarch64-windows` or equivalent to `winegcc`, the same way it's done when building Wine itself. We should probably make winegcc refuse to build ELF libraries on ARM64.
Ok, thanks for helping me understand.
I've actually already tried using `-target aarch64-windows`, but if I do that, then I can't get access to `dlfcn.h` and `libdl`.
I'm trying to create a DLL on the ARM64 Linux device that can be loaded by Wine/Windows, but, in its implementation, call functions on the host system using `dlopen`, `dlsym`, and friends. My research pointed me to using `winegcc` and friends. I accomplished this task on an x64 Linux device using `winegcc` and friends, but when I follow the same procedure on an ARM64 device it tries to generate Intel instructions.
With this MR applied, I can get the DLL to build using `winegcc` on the ARM64 Linux device, but the Windows application can't load it. Regardless, I thought I was on the right track with the MR.
So now, trying to comprehend what everyone has said in the comments of this MR, `winegcc` builds PE executables on x64, but builds ELF executables on ARM64? What changes need to be made to Wine so building a DLL using `winegcc` on ARM64 works the same way as it does x64?
So now, trying to comprehend what everyone has said in the comments of this MR, `winegcc` builds PE executables on x64, but builds ELF executables on ARM64? What changes need to be made to Wine so building a DLL using `winegcc` on ARM64 works the same way as it does x64?
You can't do that, you have to build a PE dll and a separate Unix library, and use the WINE_UNIX_CALL support to call into the Unix library. This is done in the Wine tree in several places, but we don't have the tooling in place yet to do this out of tree, so there will be some manual work involved.
ELF DLLs are not supported on ARM64 because the x18 register is not reserved on the Unix side, so it's not possible to call into a Unix library without going through the Wine Unix call interface.
This merge request was closed by Mike.