jnr / jffi

Java Foreign Function Interface
Apache License 2.0
168 stars 77 forks source link

Support for LoongArch64 #125

Closed Panxuefeng-loongson closed 2 years ago

Panxuefeng-loongson commented 2 years ago

LoongArch is a risc architecture. In this pr, I want to add support for LoongArch.

Panxuefeng-loongson commented 2 years ago

Hi all: libffi already supports LoongArch, see:https://github.com/libffi/libffi/pull/678. We have Loongarch machines in the GCC compile farm, see: https://cfarm.tetaneutral.net/machines/list/. I think you can build the Loongarch port code with it. Thanks

Panxuefeng-loongson commented 2 years ago

@theaoqi

headius commented 2 years ago

Does this patch make a jffi library that works for you? The changes are quite simple, so if this is all that is needed that would be great!

Panxuefeng-loongson commented 2 years ago

Does this patch make a jffi library that works for you? The changes are quite simple, so if this is all that is needed that would be great!

Sorry for not replying in time. The patch worked for the LoongArch platform. After that I will try my best to adapt jruby.

Thanks

headius commented 2 years ago

There are two other places we will want to add LoongArch support other than JRuby:

jnr-ffi contains type mappings for supported platforms, so we know how wide these values are. LoongArch may be mostly a copy of MIPS for these types, but we should review it and make sure jnr-ffi knows about LoongArch.

https://github.com/jnr/jnr-constants

jnr-constants contains POSIX C constants like socket flags. These don't usually differ by hardware platform, but we should review them to make sure the Linux constants are not different on a LoongArch Linux instance.

Thank you for your help!

headius commented 2 years ago

I have requested access to the GCC compile farm so we can build a binary for LoongArch.

Panxuefeng-loongson commented 2 years ago

Thank you for reminding. I have a pr in jnr-ffi: https://github.com/jnr/jnr-ffi/pull/308. Please check the code for me when you have time. I'll do the rest as you suggest, for example: jnr-constants.

Thank you for your help!

Panxuefeng-loongson commented 2 years ago

There are two other places we will want to add LoongArch support other than JRuby:

jnr-ffi contains type mappings for supported platforms, so we know how wide these values are. LoongArch may be mostly a copy of MIPS for these types, but we should review it and make sure jnr-ffi knows about LoongArch.

https://github.com/jnr/jnr-constants

jnr-constants contains POSIX C constants like socket flags. These don't usually differ by hardware platform, but we should review them to make sure the Linux constants are not different on a LoongArch Linux instance.

Thank you for your help!

Hi:

jnr-constant already supports LoongArch: https://github.com/jnr/jnr-constants/pull/98. So now I just need to adapt jnr-ffi.

Thanks