zig icon indicating copy to clipboard operation
zig copied to clipboard

m68k backend is crashing with segfault

Open ikskuh opened this issue 3 years ago • 7 comments

Zig Version

0.10.0-dev.1261+6f986298c

Steps to Reproduce

[felix@denkplatte-v2 e45fca2d]$ touch empty.zig
[felix@denkplatte-v2 e45fca2d]$ zig build-obj -fno-emit-bin -target m68k-freestanding empty.zig
Segmentation fault
exit code: 139
[felix@denkplatte-v2 e45fca2d]$

Expected Behavior

The code should've build an object file

Actual Behavior

A segmentation fault happens

ikskuh avatar Mar 12 '22 09:03 ikskuh

LLVM codebase only support m68k st the compilation stage at the moment, LLD does not support m68k in their ELF module, you should check again at next LLVM update

mlarouche avatar Mar 12 '22 12:03 mlarouche

New to this stuff, but is it possible to compile for m68k at all?

ziggekatten avatar Jan 19 '23 19:01 ziggekatten

llvm has experimental support for m68k, zig doesn't support it out of the box yet but there's a flag if you build zig yourself

nektro avatar Jan 19 '23 19:01 nektro

I want to tackle that at one point. It should be a managable amount of work on the selfhosted compiler

ikskuh avatar Jan 19 '23 19:01 ikskuh

Spent the afternoon trying to find the flag for building zig. My LLVM (15) is now built with m68k support, and can compile C-code that creates correct m68k elf binary that runs in qemu. I'm no LLVM/cmake/make/gcc wizard, and trying to find the various option is a pain really. For zig to build, do i need to modify a cmake/makefile, or are there some cmake parameter here that I'm missing?

ziggekatten avatar Jan 22 '23 16:01 ziggekatten

./build/stage3/bin/zig build -Dllvm-has-m68k -Dno-lib, there's no cmake option currently

nektro avatar Jan 22 '23 20:01 nektro

The original crash here no longer reproduces.

alexrp avatar Aug 02 '24 09:08 alexrp