Description
Given the file minimal.c
int main(int argc, char** argv)
{ return 42; }
Which compiles succesfully on the host (windows x86_64)
H:\zig_on_ppc>zig build-exe --c-source minimal.c --library c
H:\zig_on_ppc>
When attempting the same for a 32bit power pc target, we encounter immediately an error:
H:\zig_on_ppc>zig build-exe --c-source minimal.c --library c -target powerpc-linux-gnu
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:398:46: error: unexpected token in directive
.globl _ZN9libunwind13Registers_ppc6jumptoEv @ .hidden _ZN9libunwind13Registers_ppc6jumptoEv @ .type _ZN9libunwind13Registers_ppc6jumptoEv,@function @ _ZN9libunwind13Registers_ppc6jumptoEv:
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:400:17: error: unexpected token
; void libunwind::Registers_ppc::jumpto()
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:402:11: error: unexpected token
; On entry:
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:403:24: error: unexpected token
; thread_state pointer is in r3
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:406:22: error: unexpected token
; restore integral registerrs
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:407:13: error: unexpected token
; skip r0 for now
^
(... abbreviated ...)
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:558:13: error: invalid memory operand
lwz r3,20(r3) ; do r3 last
^
H:\\3rdparty\\zig-windows-x86_64-0.4.0\\lib\\zig\\libunwind\\src\\UnwindRegistersRestore.S:558:25: error: unexpected token
lwz r3,20(r3) ; do r3 last
^
The following command failed:
H:\3rdparty\zig-windows-x86_64-0.4.0\zig.exe cc -MD -MV -MF C:\Users\Nicolas\AppData\Local\zig\stage1\tmp\TPBbmNsmEzfx-UnwindRegistersRestore.o.d -nostdinc -fno-spell-checking -isystem H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\include -isystem H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libc\include\powerpc-linux-gnu -isystem H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libc\include\generic-glibc -isystem H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libc\include\powerpc-linux-any -isystem H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libc\include\any-linux-any -target powerpc-unknown-linux-gnu -g -fstack-protector-strong --param ssp-buffer-size=4 -fno-omit-frame-pointer -o C:\Users\Nicolas\AppData\Local\zig\stage1\tmp\TPBbmNsmEzfx-UnwindRegistersRestore.o -c H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libunwind\src\UnwindRegistersRestore.S -fPIC -I H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libunwind\include -fPIC -D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS -D_DEBUG
I looked afterwards at H:\3rdparty\zig-windows-x86_64-0.4.0\lib\zig\libunwind\src\UnwindRegistersRestore.S
and I think this file's __ppc__
block is using syntax that clang's CC does not expect.
When I change all ;
(comments) to //
and all register names from r0
to %r0
; f0
to %f0
etc.. then I get libunwind to compile. However this indicates something's already wrong upstream with libunwind.
After doing this, I encountered next a linking error in the case of powerpc-linux-gnu and in the case of powerpc-linux-musl a problem with the definition of the long doubles
: musl seems to expect them to have a mantissa of 53 bits where clang apparently uses way larger doubles on ppc.