russellallen / self

Making the world safe for objects
http://selflanguage.org
707 stars 76 forks source link

Feature/netbsd sparc #140

Closed nbuwe closed 1 year ago

nbuwe commented 1 year ago

This PR makes the sparc port catch up and makes it buildable on NetBSD/sparc. Debug build compiles and almost works except for two problems:

1) NetBSD v8 .mul stub doesn't follow the expected ABI completely.

This is a NetBSD bug that needs to be fixed but is also easy to work around, but I don't want to mix this hack into this PR.

2) Self JIT compiler uses %g7 register, but modern sparc ABI reserves this register for the system use for TLS (thread local storage) pointer. As it happens the NetBSD's default malloc (jemalloc) uses TLS, so on sparc it relies on %g7 not being clobbered.

This is Self's bug. I cheated and used custom libc.so with phk malloc that dodges this problem during my work. I haven't yet looked how hard would it be to stop using %g7 in the compiler.