Thanks again @nia! I can confirm that compiling with the default gcc version on NetBSD 9.1 works just fine now.
rvp Is JIT even enabled in NetBSD+ARM?
I believe so, there also seems to be some strange behavior with the performance on x86.
I have been testing melonDS with different emulator settings, nda roms and different compilers to try to figure out more about the bad performance (low frame rate, stuttering and audio distortion etc):
ARM64
gcc 7.5 - minor graphical glitches
clang 10.0.1 - a lot of graphical glitches with lines across screen.
gcc10 - almost 0 graphical glitches (not noticeable unless you really try to find them)
Difference in compiler did not affect frame rate, I was able to squeeze a few extra fps by tweaking JIT block size and changing value of hw.audio0.blk_ms
with sysctl as suggested by nia.
These are very small performance tweaks, the play experience is not enjoyable but it's now at least at a playable frame rate in comparison to the older melonDS version in pkgsrc.
x86
Same glitches depending on which compiler is used as mentioned above on ARM64.
However, the strange thing is that performance with JIT enabled is about the same (overall smooth frame rate with occasional stuttering) as the older melonDS version already available in pkgsrc that doesn't have JIT supported. Turning off JIT I would expect the same performance as the older melonDS but it performs slightly worse with more audio stuttering and occasional frame drops.
EDIT:
My tests seemed to be case specific on heavy 3D rendered scenes, the overall performance across different games is better (just by a little bit) with or without JIT enabled on the newly compiled melonDS on x86.