graalvm-mobile

rjsheperd 2026-01-26T19:26:32.470539Z

@smith.adriane trying to build grease and I'm getting this error. I've tried to update the jni-config to include the namespace, but that didn't really do anything:

Undefined symbols for architecture arm64:
  "_JNI_OnLoad_sunec", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_io_ObjectInputStream_bytesToDoubles", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_io_ObjectInputStream_bytesToFloats", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_bind0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_connect0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_dataAvailable", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_datagramSocketClose", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_disconnect0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_init", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_peek", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_peekData", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_receive0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_send0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_socketGetOption", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainDatagramSocketImpl_socketSetOption0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_initProto", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketAccept", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketAvailable", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketBind", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketClose0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketConnect", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketCreate", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketGetOption", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketListen", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketSendUrgentData", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketSetOption0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_PlainSocketImpl_socketShutdown", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_SocketCleanable_cleanupClose0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_SocketInputStream_init", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_SocketInputStream_socketRead0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_SocketOutputStream_init", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_net_SocketOutputStream_socketWrite0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_nio_MappedByteBuffer_force0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_nio_MappedByteBuffer_isLoaded0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_java_nio_MappedByteBuffer_load0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_net_dns_ResolverConfigurationImpl_localDomain0", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_nio_ch_DatagramChannelImpl_initIDs", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_security_ec_ECDHKeyAgreement_deriveKey", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_security_ec_ECDSASignature_signDigest", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_security_ec_ECDSASignature_verifySignedDigest", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair", referenced from:
      ___svm_cglobaldata_base in bb.o
  "_Java_sun_security_ec_ECKeyPairGenerator_isCurveSupported", referenced from:
      ___svm_cglobaldata_base in bb.o
ld: symbol(s) not found for architecture arm64

frankitox 2026-01-28T17:57:27.748929Z

Happy to read about your progress/experiments @rjsheperd 🙂

âž• 1
rjsheperd 2026-01-27T17:21:32.728269Z

I got JDK 21 for iOS to build using this: https://github.com/utopia-rise/ios-graal-jdk-21 with some patches from https://github.com/openjdk/jdk17u-dev/tree/master (had to update libpng and the libjsound native CPP files for MacOSX) However, I think I need to add some modules to the ios-graal-jdk-21 builder to enable https://github.com/oracle/graal/tree/master/substratevm/src/com.oracle.svm.native.libchelper. Unless there's another way to get that?

🎉 2
rjsheperd 2026-01-27T18:48:07.408999Z

I feel like I'm getting closer. I've managed to get liblibchelper.a built using the same Graal JVM that I used to build with the ios-graal-jdk-21 repo. Have to run to an appointment, but hoping I can get it all pulled together 🤞

phronmophobic 2026-01-27T18:50:14.179539Z

Awesome! If you get it to work, it would be great to update the grease documentation. I can also update the github action which is a nice way to make sure that the process is reproducible.

✅ 1
rjsheperd 2026-01-27T18:52:40.178709Z

Do you think it's worth having JDK 21 and JDK 17?

rjsheperd 2026-01-27T18:53:18.180909Z

I was also thinking this could be a way to build for JDK 25: https://github.com/openjdk/mobile

👀 1
phronmophobic 2026-01-27T18:54:55.960009Z

I don't think it's worth trying to support JDK 21 and 17.

phronmophobic 2026-01-27T18:55:52.322769Z

Does the openjdk/mobile project work?

rjsheperd 2026-01-27T18:58:41.745179Z

¯\(ツ)/¯

rjsheperd 2026-01-27T18:59:50.638739Z

Also, I targeted the minimum iOS version that I could since I don't have an earlier version of XCode (iOS 16), but I think you could potentially support earlier versions of iOS

phronmophobic 2026-01-27T19:10:40.860569Z

That's maybe something that possible using a github action.

rjsheperd 2026-01-26T19:32:01.766869Z

Sorry if this is the wrong place to debug this! I'm about to push up my fork here: http://github.com/rjsheperd/grease

phronmophobic 2026-01-26T19:33:42.698179Z

I was hoping support for this use case would improve over time, but it seems like there's been a lot of bitrot instead.

phronmophobic 2026-01-26T19:33:55.183319Z

If someone can get this working again, that would be great.

phronmophobic 2026-01-26T19:36:41.819879Z

I believe the link from the static dependencies from gluon are broken. Did you download them from somewhere else?

phronmophobic 2026-01-26T19:37:21.312549Z

What version of native image are you using?

phronmophobic 2026-01-26T19:38:59.134749Z

If you were following the steps from grease, you should have hit an error much sooner.

rjsheperd 2026-01-26T20:05:00.798379Z

I ended up getting to that point with some updates to the deps.edn file and by rebuilding libffi using version 3.5.2

rjsheperd 2026-01-26T20:21:06.646709Z

Here's my fork: https://github.com/rjsheperd/grease I downloaded the static deps from the same URL you specified in the README. I was thinking that might be the issue...

phronmophobic 2026-01-26T20:28:54.139619Z

the link in scripts/download-deps no longer works

phronmophobic 2026-01-26T20:32:03.311599Z

If I were trying to get this to work, I probably wouldn't start with grease. I would probably either start with https://clojurians.slack.com/archives/C0260KHN0Q0/p1767891724536509?thread_ts=1767887733.921589&cid=C0260KHN0Q0 repo or the https://github.com/gluonhq/gluon-samples/tree/master/HelloGluon from gluon.

phronmophobic 2026-01-26T20:33:10.556449Z

If you can get one of the basic java examples to work, then you can start to incorporate the features from grease/babashka.

phronmophobic 2026-01-26T20:34:02.970649Z

Maybe grease isn't that far away, but it's hard to tell without a working example.

rjsheperd 2026-01-26T20:35:48.062629Z

Do you think the issue with JNI_Load_sunec can be resolved with a newer version of Gluon's Graal VM? I see this was brought up in 2020: https://github.com/oracle/graal/issues/2713#event-3626730652

rjsheperd 2026-01-26T20:36:14.088659Z

I did see the ios-graal-jdk-21 repo. That did look promising.

phronmophobic 2026-01-26T20:39:36.321259Z

since the link to the static dependencies are broken, did you download them from somewhere else?

phronmophobic 2026-01-26T20:41:40.835329Z

my guess is the missing symbols are from the missing jdk static libs

rjsheperd 2026-01-26T21:06:04.458269Z

I updated to this build of Gluon and it did build!

rjsheperd 2026-01-26T21:07:00.355969Z

2026-01-26 13:06:43.524709-0800 MobileTest[776:148485] [PreviewsAgentExecutorLibrary] Calling provided entry point.
java.lang.ExceptionInInitializerError: null
    at com.phronemophobic.grease.interface.clj_eval(interface.java:-1)

🎉 1
phronmophobic 2026-01-26T21:14:28.280359Z

That's an older version than the version linked in the grease readme

rjsheperd 2026-01-26T22:17:58.098809Z

Interesting. It does look like the bb.o file has the correct symbols:

(base) ➜  grease git:(main) ✗ otool -tV library/build/out/bb.o | grep interface
....  ...
_interface_clj_add_f157a51f56ba7a1e87df23f748c220e539822232:
_interface_clj_callback_fn_0081e7c938cf1e9f8347a00b86cc6b0b03c126fb:
_interface_clj_eval_dbbcdd90018a68974d23e62348582a7a4338e7b7:
_interface_clj_print_88c30eb43c7827f9cbdfb2a41cbbdf715f945901:
_interface_clj_print_hi_9293c36f4e350aea0c86e13fab9def0cbedcf6f3:
_interface_clj_prn_71eeefba7ccfac85df24a5638356c36f84d4b0d0:
_interface_clj_start_server_0ad7568083062a97012333d511479eb3cbbbe827:
_interface_clj_sub_cb4c4136dd76a61c4bf943affcc5159bff233d19:

rjsheperd 2026-01-27T00:07:50.615629Z

Ah, I had to add the com.phronemophobic.grease.interface class to the --initialize-run-time flag

👀 1