adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 125 forks source link

arsd:jni 10.9.9 unable to compile using LDC2 #380

Closed DannyArends closed 1 year ago

DannyArends commented 1 year ago

Hey Adam,

Cross-compiling using dub with LDC2 (on linux64) to android worked in the past, but with jni.d 10.9.9 I get the following error:

../../.dub/packages/arsd-official-10.9.9/arsd-official/jni.d(1684,19): Error: Function type does not match previously declared function with the same mangled name: `_D4arsd3jni17StackTraceElement6__ctorMFAyaQdQfiZCQBvQBtQBs`
../../.dub/packages/arsd-official-10.9.9/arsd-official/jni.d(1684,19): Previous IR type: %arsd.jni.StackTraceElement* (%arsd.jni.StackTraceElement*, { i64, i8* }, { i64, i8* }, { i64, i8* }, i32)
../../.dub/packages/arsd-official-10.9.9/arsd-official/jni.d(1684,19): New IR type: %arsd.jni.StackTraceElement* ({ i64, i8* }, { i64, i8* }, { i64, i8* }, i32, %arsd.jni.StackTraceElement*)

Seems the arsd.jni.StackTraceElement* pointer is last in the New IR type, and first in the Previous IR type. Is there any way to fix this,

If I swap the parameters at line 1684, from

private static T implementation(Parameters!method args, T this_) {

to

private static T implementation(T this_, Parameters!method args) {

It compiles, but I don't know if this is the correct fix

LDC version: LDC - the LLVM D compiler (1.32.0), let me know if you need to know anything else

Thanks for the great work on arsd !

adamdruppe commented 1 year ago

That change might be right, it just might also differ on 32 vs 64 bits....

DannyArends commented 1 year ago

Thanks for the quick response, I'll just edit the file and compile, see if it runs. I'll additionally test the 32 bit version as well then, see if the same thing happens.

adamdruppe commented 1 year ago

Lemme know how it goes, I've been pretty busy with other stuff lately so I don't expect to have a change to dig into it myself until some time next week.

DannyArends commented 1 year ago

Hey Adam,

Just tested it on 32bit as well, same result.

mw66 commented 1 year ago

@adamdruppe hit this bug today with arsd-official-10.9.10, and found the fix is already in, you want to push a new release?

mw66 commented 1 year ago

However, with the #382 fix, the example at the top of the file has a new problem:

javac Hello.java
ldmd2 -shared myjni.d arsd/jni.d # compile into a shared lib
myjni.d(30): Error: Function type does not match previously declared function with the same mangled name: `_D5myjni5Hello6memberMFNdiZv`
myjni.d(30):        Previous IR type: void (i32, %myjni.Hello*)
myjni.d(30):        New IR type:      void (%myjni.Hello*, i32)
mw66 commented 1 year ago

BTW, with dmd on Linux, the cmd should be:

dmd -oflibmyjni.so -shared myjni.d arsd/jni.d # compile into a shared lib

With the current command, no .so is generated.