Crystal: Rewrite sigfault.c in Crystal

Created on 4 Jan 2017  路  3Comments  路  Source: crystal-lang/crystal

Right now we have a sigfault handler to print a nice error message on segmentation faults. It's located at sigfault.c

This was written in C because if I remember correctly the internal structure of either siginfo_t, stack_t or sigaction were a bit complex, and even some properties are actually C macros.

The problem with this being written in C is that to compile the compiler we currently need to compile this file, so it's an extra step to remember. This is also kind of annoying when cross-compiling the compiler, because sigfault.c is compiled at the host machine, not the target machine. I think having this code re-written in Crystal will make things much simpler.

@ysbaddaden Do you think this can be done with https://github.com/ysbaddaden/posix ?

feature compiler

Most helpful comment

@ysbaddaden Oh, I totally forgot about that.

In any case, sigfault.c is used by any crystal program, but the LLVM wrapper is only used by the compiler, so rewriting sigfault.c to crystal still makes sense.

All 3 comments

Maybe it's already capable to deal with the structs and typedefs since I defined in POSIX. The macros, though, would have to be ported by hand.

Note that we still need a C++ wrapper for LLVM's DIBuilder.

@ysbaddaden Oh, I totally forgot about that.

In any case, sigfault.c is used by any crystal program, but the LLVM wrapper is only used by the compiler, so rewriting sigfault.c to crystal still makes sense.

What is the usage of https://github.com/ysbaddaden/posix ?
Maybe I can write the .cr version with this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asterite picture asterite  路  3Comments

paulcsmith picture paulcsmith  路  3Comments

nabeelomer picture nabeelomer  路  3Comments

jhass picture jhass  路  3Comments

lbguilherme picture lbguilherme  路  3Comments