Fork me on GitHub
#graalvm-mobile2021-06-17
>
phronmophobic00:06:43

I'm curious what you would be interesting in build as well what kind of GUI interface you would be looking for.

raspasov00:06:44

Responding in order: It would be great to double check that the basic mobile setup 1) works , 2) is easy to follow. I’ll try the project tonight.

🎉 2
raspasov00:06:30

It would great to get your take on what kind of GUI API you think would make sense (clj bindings for SwiftUI?, UIKit, something else?). I think SwiftUI is the future for MacOS/iOS/iPad/iOS. I haven’t used it much (just a bit) but the model looks solid. Very close to React, but also made to do “data sync” with classes/mutable objects.

raspasov00:06:16

UIKit is very low level in comparison, and a very mutable API, 90s style. Do this, do that. Mutable everything.

raspasov00:06:56

SwiftUI in comparison is very declarative. With caveats, from the surface, it feels like it can be a great fit for Clojure. But I don’t have enough experience with it and the interop between Swift/Clojure to say what the technical hurdles are going to be.

raspasov00:06:01

I'd also like to know what you think of React Native generally. One interesting strategy would be to create bindings to the native side of React Native. I like React Native. It’s very close to React, basically the same model. It can have limitations but they are mostly in performance for specific cases like animation performance, and can be worked around. There are libraries like Reanimated V2 which solve that quite well. Otherwise, RN is probably the best and most easily iterable way to build general UIs on iOS today.

phronmophobic00:06:40

SwiftUI does seem pretty functional. I haven't tried it in any real capacity though

raspasov00:06:01

React Native is built on top of UIKit, btw. It basically uses a “view” like a “div”.

raspasov00:06:24

Yes! It is. I have tried a few toy examples. It’s neat.

raspasov01:06:30

I wouldn’t say I like it more than React, but for what Swift/Obj-C is, it’s definitely towards best they can have.

phronmophobic01:06:07

My sense is that's there's way more stuff built on top of UIKit. The other benefit is that objective-c seems more dynamically malleable compared to swift. It seems like it would be possible to implement interop on of obc_msgsend similar to how java interop works

phronmophobic01:06:34

However, I don't think that's the main consideration

raspasov01:06:18

Yes, there definitely is. But I think things should be moving towards the SwiftUI direction.

raspasov01:06:53

Obj-C definitely very dynamic. What’s your sense about interop between Clojure and Swift? Would it be possible?

phronmophobic01:06:34

I'm sure it's possible

phronmophobic01:06:39

worst case scenario is that you use the reference api to generate the interface on both the clojure and swift sides

raspasov01:06:54

Cool. I’ve been doing a bit of Swift over the last 2 weeks. Definitely not an expert, but learning things. (I needed a custom camera solution and access to the raw frames of the camera, and re-made a component that interfaces with RN to do that)

raspasov01:06:50

If you get the compiler to be happy, Swift ain’t that bad. But that’s a big if 😜.

raspasov01:06:13

I am still wrapping my head around the rules about initializations in Swift structs. As long as I stick to (mostly) static classes and static vars, things are much “easier” and “familiar”, sort of Java-static style.

raspasov01:06:45

I’ll try the project and report here.

raspasov07:06:25

Going through the GraalVM setup. Should I be using Java 11 or Java 16, any difference?

raspasov07:06:30

I’ll try with Java 11 to start.

phronmophobic07:06:16

my setup was java 11

phronmophobic07:06:14

ideally, it shouldn't matter, but I haven't tried Java 16

raspasov07:06:37

Alright, not gonna go crazy to start, Java 11 it is 🙂

🙂 2
raspasov08:06:26

Ok, got GraalVM installed, I believe. Perhaps adding a link to this issue can be helpful to somebody https://stackoverflow.com/questions/65786439/problem-with-installing-running-grallvm-on-mac

raspasov08:06:44

Or just a note about MacOS:

xattr -d com.apple.quarantine <PATH TO GRAALVM INSTALLATION>

phronmophobic08:06:20

good call. it's been so long that I forgot

raspasov08:06:42

For sure, it’s a one-time pain.

phronmophobic08:06:24

trying to figure out the best place to put the link

phronmophobic08:06:35

but after all the links

raspasov08:06:16

I guess I didn’t scroll that far. I was going through this page at the moment: https://github.com/BrunoBonacci/graalvm-clojure/blob/master/doc/clojure-graalvm-native-binary.md

raspasov08:06:38

Omg, it’s there also 🙂

raspasov08:06:11

I am just impatient and don’t read things till the end 😂

2
phronmophobic08:06:20

to be fair, Mac OSX has been getting less developer friendly over the years

raspasov08:06:48

Yeah. Because security.

raspasov08:06:49

Ok, I’m running ./scripts/compile-shared I get this: ./scripts/compile-shared: line 20: /bin/native-image: No such file or directory

phronmophobic08:06:37

do you have your graalvm home set?

phronmophobic08:06:17

rather GRAALVM_HOME

raspasov08:06:14

I was trying to make it work via jenv but I guess I need the GRAALVM_HOME

phronmophobic08:06:16

the compile script references GRAALVM_HOME

raspasov08:06:26

Right, I see it. No problem.

phronmophobic08:06:29

not sure what might be a better alternative

phronmophobic08:06:22

it's looking for graalvm's native-image

raspasov08:06:59

Compiling now.

🤞 2
raspasov08:06:39

Taking its time, assume that’s expected.

phronmophobic08:06:52

yup, it takes some time

👌 2
raspasov08:06:19

Oh wow, went to make some food, this is still going 😄

raspasov08:06:35

Maybe something’s wrong?

raspasov08:06:54

Output so far:

raspasov08:06:56

[email protected] mobiletest % ./scripts/compile-shared    
+ set -e
+++ dirname ./scripts/compile-shared
++ cd ./scripts
++ pwd
+ DIR=/Users/raspasov/projects/github/mobiletest/scripts
+ cd /Users/raspasov/projects/github/mobiletest/scripts
+ PROJECT_DIR=/Users/raspasov/projects/github/mobiletest/scripts/..
+ cd ..
+ rm -rf ./classes
+ mkdir classes
+ clojure -X com.phronmophobic.mobiletest/compile-interface-class
+ clojure -X:depstar
[main] INFO hf.depstar.uberjar - Synchronizing pom.xml
Skipping paths: classes generated_classes native_test
[main] INFO hf.depstar.uberjar - Compiling com.phronmophobic.mobiletest ...
[main] INFO hf.depstar.uberjar - Compiling com.phronmophobic.mobiletest ...
[main] INFO hf.depstar.uberjar - Building uber jar: target/mobiletest-uber.jar
{:warning "could not find classpath entry", :path "generated_classes"}
{:warning "could not find classpath entry", :path "native_test"}
[main] INFO hf.depstar.uberjar - Processing pom.xml for {com.phronmophobic/mobiletest {:mvn/version "1.00-beta-1"}}
+ pushd library
~/projects/github/mobiletest/library ~/projects/github/mobiletest
+ /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/bin/native-image --report-unsupported-elements-at-runtime --initialize-at-build-time --no-fallback --no-server -H:CompilerBackend=llvm -H:+ExitAfterRelocatableImageWrite -H:+SharedLibrary -H:+AddAllCharsets -H:+ReportExceptionStackTraces -H:-DeadlockWatchdogExitOnTimeout -H:DeadlockWatchdogInterval=0 -H:+RemoveSaturatedTypeFlows -H:-SpawnIsolates -H:PageSize=16384 -Djdk.internal.lambda.eagerlyInitialize=false -H:+ReportExceptionStackTraces -H:TempDirectory=/Users/raspasov/projects/github/mobiletest/scripts/../library/tmp -H:ReflectionConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/reflectionconfig-arm64-ios.json -H:JNIConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/jniconfig-arm64-ios.json -H:ResourceConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/resourceconfig-arm64-ios.json -J-Dclojure.spec.skip-macros=true -J-Xmx20G -J-XX:MaxDirectMemorySize=8G -J-Dclojure.compiler.direct-linking=true -J-Dtech.v3.datatype.graal-native=true -Dsvm.targetName=iOS -Dsvm.targetArch=arm64 -H:+UseCAPCache -H:CAPCacheDir=/Users/raspasov/projects/github/mobiletest/scripts/../conf/capcache '-Dsvm.platform=org.graalvm.nativeimage.Platform$IOS_AARCH64' -jar ../target/mobiletest-uber.jar -cp classes
[mobiletest-uber:8653]  classlist:  2,728.25 ms, 0.94 GB
[mobiletest-uber:8653]    (cap):   171.45 ms, 0.94 GB
[mobiletest-uber:8653]    setup:  1,727.14 ms, 0.94 GB

raspasov08:06:36

Keep waiting?

phronmophobic08:06:16

I'm a little surprised it's taking this long, but it's not completely crazy

phronmophobic08:06:00

especially if compiling the uberjar for the first time needed to download dependencies

raspasov08:06:41

Yeah it is weird… I am on a relatively recent MBP 2018, 2.9 GHz 6-Core Intel Core i9 (not sure if this makes a big difference in compilation)

raspasov08:06:47

Still waiting.

phronmophobic08:06:36

I have seen it get stuck on setup before and killing and restarting can help

raspasov08:06:46

Ok, I’ll try that then?

raspasov08:06:35

There a couple of warnings, {:warning “could not find classpath entry”, :path “generated_classes”} {:warning “could not find classpath entry”, :path “native_test”} Do they matter?

phronmophobic08:06:26

It shouldn't. I'm just realizing those entries are from the avclj project that I based the initial project on

👌 2
raspasov08:06:52

Ok, still waiting at the same spot now.

raspasov08:06:32

Random feedback for the README, perhaps add right before ./scripts/compile-shared

export GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-VERSION/Contents/Home
export PATH=$GRAALVM_HOME/bin:$PATH
(assuming MacOS)

👍 2
raspasov09:06:25

Hmm something looks very stuck, not sure why…

raspasov09:06:50

(based on Activity Monitor, it doesn’t seem it’s doing much CPU or network)

phronmophobic09:06:51

that does seem suspicous

phronmophobic09:06:04

i'm running it on my computer and all the activity seems to be showing up under java rather than "native-image"

raspasov09:06:39

Ok, let me see…

phronmophobic09:06:36

weird. I'm running it now on my computer and it's taking forever

raspasov09:06:53

You said it needs to download something?

phronmophobic09:06:57

I don't remember it taking this long before

raspasov09:06:09

Maybe there’s a way to manually download it? Perhaps some server is down?

phronmophobic09:06:14

native image shouldn't be downloading anything

phronmophobic09:06:31

only to make the uberjar, which it looks like you've completed

raspasov09:06:49

Yes, the jar is there under /target

raspasov09:06:00

34.6MB mobiletest-uber.jar

phronmophobic09:06:38

now it's not working on my computer 😞. I swear this was all working earlier

raspasov09:06:44

I believe you. Hmm.

raspasov09:06:05

Gets stuck at the same spot?

phronmophobic09:06:46

I think I know the issue on my computer

phronmophobic09:06:02

I forgot to switch my JAVA_HOME to point to graalvm

phronmophobic09:06:17

if you do which java, does it print the java in graalvm?

raspasov09:06:01

I think I didn’t put the $JAVA_HOME :

raspasov09:06:02

[email protected] mobiletest % echo $JAVA_HOME [email protected] mobiletest % which java  /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/bin/java

raspasov09:06:14

JAVA_HOME is empty but the java is correct

raspasov09:06:24

I’ll try to set JAVA_HOME

raspasov09:06:33

export JAVA_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home
Running again…

raspasov09:06:53

Seems to be stuck same spot…

phronmophobic09:06:57

ok, looking back at my setup. My JAVA_HOME wasn't set, but I was using a different the first time around

phronmophobic09:06:16

I would try deleting the library/classes directory

phronmophobic09:06:23

and trying again

raspasov09:06:33

Ok! Trying.

phronmophobic09:06:40

it did compile for me this time in 213,763.55 ms

phronmophobic09:06:10

aka ~3.5 minutes

raspasov09:06:36

Progress: Warning: RecomputeFieldValue.FieldOffset automatic substitution failed. The automatic substitution registration was attempted because a call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) was detected in the static initializer of tech.v3.datatype.UnsafeUtil. Detailed failure reason(s): Could not determine the field where the value produced by the call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) for the field offset computation is stored. The call is not directly followed by a field store or by a sign extend node followed directly by a field store.

phronmophobic09:06:49

that's actually a good sign

phronmophobic09:06:16

I've noticed that when it prints that, it's past the part where it gets stuck sometimes

raspasov09:06:21

Ok, error, but a bunch of output:

raspasov09:06:13

[email protected] mobiletest % ./scripts/compile-shared
+ set -e
+++ dirname ./scripts/compile-shared
++ cd ./scripts
++ pwd
+ DIR=/Users/raspasov/projects/github/mobiletest/scripts
+ cd /Users/raspasov/projects/github/mobiletest/scripts
+ PROJECT_DIR=/Users/raspasov/projects/github/mobiletest/scripts/..
+ cd ..
+ rm -rf ./classes
+ mkdir classes
+ clojure -X com.phronmophobic.mobiletest/compile-interface-class
+ clojure -X:depstar
[main] INFO hf.depstar.uberjar - Synchronizing pom.xml
Skipping paths: classes generated_classes native_test
[main] INFO hf.depstar.uberjar - Compiling com.phronmophobic.mobiletest ...
[main] INFO hf.depstar.uberjar - Compiling com.phronmophobic.mobiletest ...
[main] INFO hf.depstar.uberjar - Building uber jar: target/mobiletest-uber.jar
{:warning "could not find classpath entry", :path "generated_classes"}
{:warning "could not find classpath entry", :path "native_test"}
[main] INFO hf.depstar.uberjar - Processing pom.xml for {com.phronmophobic/mobiletest {:mvn/version "1.00-beta-1"}}
+ pushd library
~/projects/github/mobiletest/library ~/projects/github/mobiletest
+ /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/bin/native-image --report-unsupported-elements-at-runtime --initialize-at-build-time --no-fallback --no-server -H:CompilerBackend=llvm -H:+ExitAfterRelocatableImageWrite -H:+SharedLibrary -H:+AddAllCharsets -H:+ReportExceptionStackTraces -H:-DeadlockWatchdogExitOnTimeout -H:DeadlockWatchdogInterval=0 -H:+RemoveSaturatedTypeFlows -H:-SpawnIsolates -H:PageSize=16384 -Djdk.internal.lambda.eagerlyInitialize=false -H:+ReportExceptionStackTraces -H:TempDirectory=/Users/raspasov/projects/github/mobiletest/scripts/../library/tmp -H:ReflectionConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/reflectionconfig-arm64-ios.json -H:JNIConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/jniconfig-arm64-ios.json -H:ResourceConfigurationFiles=/Users/raspasov/projects/github/mobiletest/scripts/../conf/resourceconfig-arm64-ios.json -J-Dclojure.spec.skip-macros=true -J-Xmx20G -J-XX:MaxDirectMemorySize=8G -J-Dclojure.compiler.direct-linking=true -J-Dtech.v3.datatype.graal-native=true -Dsvm.targetName=iOS -Dsvm.targetArch=arm64 -H:+UseCAPCache -H:CAPCacheDir=/Users/raspasov/projects/github/mobiletest/scripts/../conf/capcache '-Dsvm.platform=org.graalvm.nativeimage.Platform$IOS_AARCH64' -jar ../target/mobiletest-uber.jar -cp classes
[mobiletest-uber:10698]  classlist:  2,932.32 ms, 0.95 GB
[mobiletest-uber:10698]    (cap):   191.21 ms, 0.95 GB
[mobiletest-uber:10698]    setup:  1,622.68 ms, 0.95 GB
Warning: RecomputeFieldValue.FieldOffset automatic substitution failed. The automatic substitution registration was attempted because a call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) was detected in the static initializer of tech.v3.datatype.UnsafeUtil. Detailed failure reason(s): Could not determine the field where the value produced by the call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) for the field offset computation is stored. The call is not directly followed by a field store or by a sign extend node followed directly by a field store. 
[mobiletest-uber:10698]   (clinit):   362.14 ms, 2.69 GB
[mobiletest-uber:10698]  (typeflow):  9,919.26 ms, 2.69 GB
[mobiletest-uber:10698]  (objects): 10,759.01 ms, 2.69 GB
[mobiletest-uber:10698]  (features):  1,717.75 ms, 2.69 GB
[mobiletest-uber:10698]   analysis: 23,893.47 ms, 2.69 GB
[mobiletest-uber:10698]   universe:   994.07 ms, 3.86 GB
[mobiletest-uber:10698]   (parse):  1,572.44 ms, 3.86 GB
[mobiletest-uber:10698]   (inline):  5,622.28 ms, 4.49 GB
[mobiletest-uber:10698]  (compile):  1,329.01 ms, 4.49 GB
[mobiletest-uber:10698]   compile:  8,696.35 ms, 4.49 GB
7 fatal errors detected:

raspasov09:06:31

Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 6|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: void com.oracle.svm.core.graal.snippets.StackOverflowCheckSnippets.throwCachedStackOverflowError() [Direct call from void FunctionPointerLogHandler.fatalError()]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more
Fatal error:org.graalvm.compiler.graph.GraalGraphError: com.oracle.svm.core.util.UserError$UserException: Using the LLVM backend requires LLVM to be installed on your machine.
	at node: 61|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: void com.oracle.svm.core.thread.VMThreads.detachThread(IsolateThread) [Direct call from int CEntryPointSnippets.detachThreadMT(IsolateThread)]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: com.oracle.svm.core.util.UserError$UserException: Using the LLVM backend requires LLVM to be installed on your machine.
	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker.getLLVMVersion(LLVMFeature.java:149)
	at com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker.<clinit>(LLVMFeature.java:135)
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more

raspasov09:06:39

Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 119|Conditional { stamp=i32 [-1 - 2] ⇊0000000000000002, }
	at method: int com.oracle.svm.core.graal.snippets.CEntryPointSnippets.initializeIsolate(CEntryPointCreateIsolateParameters) [Direct call from int CEntryPointNativeFunctions.createIsolate(CEntryPointCreateIsolateParameters, CEntryPointNativeFunctions$IsolatePointer, CEntryPointNativeFunctions$IsolateThreadPointer)]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more
Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 5|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: void com.oracle.svm.core.graal.snippets.StackOverflowCheckSnippets.throwNewStackOverflowError() [Direct call from void CEntryPointSnippets.ensureJavaThread()]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more
Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 167|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: JNIObjectHandle com.oracle.svm.jni.functions.JNIFunctions.AllocObject(JNIEnvironment, JNIObjectHandle) [Direct call from JNIObjectHandle IsolateEnterStub.JNIFunctions_AllocObject_fd679b648ff7a5bbe75e2b56d7c12125e4e73817(JNIEnvironment, JNIObjectHandle)]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more
Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 34|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: void com.oracle.svm.core.thread.Safepoint.enterSlowPathSafepointCheck() [Direct call from void CEntryPointSnippets.ensureJavaThread()]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more

raspasov09:06:40

Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at node: 42|Conditional { stamp=i32 [0 - 1] ⇈0000000000000001, }
	at method: void com.oracle.svm.core.thread.Safepoint.enterSlowPathTransitionFromNativeToNewStatus(int) [Direct call from IsolateThread IsolateEnterStub.CEntryPointBuiltins_createIsolate_315bd7239ea2b5ed6515910416de2648c30349ea()]
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:291)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.generate(SubstrateLLVMBackend.java:147)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitLLVM(SubstrateLLVMBackend.java:123)
	at com.oracle.svm.core.graal.llvm.SubstrateLLVMBackend.emitBackEnd(SubstrateLLVMBackend.java:103)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compile(GraalCompiler.java:146)
	at jdk.internal.vm.compiler/org.graalvm.compiler.core.GraalCompiler.compileGraph(GraalCompiler.java:130)
	at com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:998)
	at com.oracle.svm.hosted.code.CompileQueue.doCompile(CompileQueue.java:960)
	at com.oracle.svm.hosted.code.CompileQueue$CompileTask.run(CompileQueue.java:265)
	at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
	at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.oracle.svm.core.graal.llvm.LLVMFeature$LLVMVersionChecker
	at com.oracle.svm.core.graal.llvm.LLVMGenerator.emitConditionalMove(LLVMGenerator.java:646)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitConditional(NodeLLVMBuilder.java:395)
	at jdk.internal.vm.compiler/org.graalvm.compiler.nodes.calc.ConditionalNode.generate(ConditionalNode.java:297)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.emitNode(NodeLLVMBuilder.java:327)
	at com.oracle.svm.core.graal.llvm.NodeLLVMBuilder.doBlock(NodeLLVMBuilder.java:287)
	... 15 more
Error: Image build request failed with exit status 1

raspasov09:06:09

Does not like something about LLVM.

phronmophobic09:06:19

that's a new error to me

phronmophobic09:06:59

I think I might know what it is. one sec

👌 2
phronmophobic09:06:38

that should definitely be in the Readme somewhere

raspasov09:06:41

Trying that command.

raspasov09:06:10

Is it a good idea to be nuking the /library folder every time?

phronmophobic09:06:12

that's probably worth putting in the script

raspasov09:06:28

Yes, can’t hurt.

raspasov09:06:17

Hmm it seems to be getting stuck again at that previous spot. Unpredictable.

phronmophobic09:06:30

I guess if it gets stuck before the Warning: RecomputeFieldValue.FieldOffset, then it's worth restarting

raspasov09:06:10

So weird why it would do that. Have you seen that before?

phronmophobic09:06:33

yea. I have noticed it getting stuck there before

raspasov09:06:14

Ok, restarting once without nuking /library made it go forward.

raspasov09:06:23

(that’s a guess as to the cause)

raspasov09:06:58

Perhaps you need to run it once, and then one more time.

phronmophobic09:06:16

I thought I noticed happening less often, but I could never tell if it was just random or not

raspasov09:06:43

Seems to be going through the steps.

raspasov09:06:52

[mobiletest-uber:11153]  classlist:  2,731.31 ms, 1.20 GB
[mobiletest-uber:11153]    (cap):   232.85 ms, 1.20 GB
[mobiletest-uber:11153]    setup:  1,997.64 ms, 1.20 GB
Warning: RecomputeFieldValue.FieldOffset automatic substitution failed. The automatic substitution registration was attempted because a call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) was detected in the static initializer of tech.v3.datatype.UnsafeUtil. Detailed failure reason(s): Could not determine the field where the value produced by the call to jdk.internal.misc.Unsafe.objectFieldOffset(Field) for the field offset computation is stored. The call is not directly followed by a field store or by a sign extend node followed directly by a field store. 
[mobiletest-uber:11153]   (clinit):   394.12 ms, 4.66 GB
[mobiletest-uber:11153]  (typeflow):  9,692.06 ms, 4.66 GB
[mobiletest-uber:11153]  (objects): 11,286.21 ms, 4.66 GB
[mobiletest-uber:11153]  (features):  1,601.63 ms, 4.66 GB
[mobiletest-uber:11153]   analysis: 24,224.42 ms, 4.66 GB
[mobiletest-uber:11153]   universe:  1,081.17 ms, 4.66 GB
[mobiletest-uber:11153]   (parse):  2,090.61 ms, 4.66 GB
[mobiletest-uber:11153]   (inline):  3,401.28 ms, 4.66 GB
[mobiletest-uber:11153]  (compile): 21,491.40 ms, 7.37 GB
[mobiletest-uber:11153]  (bitcode):  1,810.94 ms, 7.37 GB
[mobiletest-uber:11153]  (prelink):  4,937.09 ms, 7.37 GB

clojure-spin 2
raspasov09:06:34

I think it completed well:

raspasov09:06:37

# Printing build artifacts to: mobiletest-uber.build_artifacts.txt
[mobiletest-uber:11153]   [total]: 136,380.22 ms, 7.61 GB
+ rm -rf ./build/out
+ mkdir -p build/out
++ find . -name llvm.o -print0
++ xargs -r -0 ls -1 -t
++ head -1
+ LLVM_PATH=./tmp/SVM-1623922437105/llvm/llvm.o
+ cp ./tmp/SVM-1623922437105/llvm/llvm.o build/out
++ find . -name mobiletest-uber.o -print0
++ xargs -r -0 ls -1 -t
++ head -1
+ MOBILETEST_PATH=./tmp/SVM-1623922437105/mobiletest-uber.o
+ cp ./tmp/SVM-1623922437105/mobiletest-uber.o build/out
+ popd
~/projects/github/mobiletest

raspasov09:06:03

Ok, XCode next?

👍 2
raspasov09:06:12

XCode error:

ld: warning: directory not found for option '-L/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/clibraries/ios-arm64'
ld: library not found for -ljvm

raspasov09:06:28

Something about the paths

phronmophobic09:06:31

MacBook-Air:mobiletest adrian$ ls '/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/clibraries/ios-arm64'
clibraries-ios-arm64.md5	libffi.a			liblibchelper.a
libdarwin.a			libjvm.a			libstrictmath.a

raspasov09:06:34

I am missing the “ios-arm64” directory

raspasov09:06:04

[email protected] ~ % ls '/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/clibraries/ios-arm64'
ls: /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/clibraries/ios-arm64: No such file or directory
[email protected] ~ %

raspasov09:06:17

Perhaps need to install something?

phronmophobic09:06:19

is that the right graalvm path?

raspasov09:06:40

[email protected] ~ % ls /Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/clibraries/
darwin-amd64

raspasov09:06:54

^^ path exists up to “clibraries”

phronmophobic09:06:35

let's see if I can figure out how I got those clibraries

phronmophobic09:06:31

MacBook-Air:mobiletest adrian$ cd '/Library/Java/JavaVirtualMachines/graalvm-ce-java11-21.1.0/Contents/Home/lib/svm/'
MacBook-Air:svm adrian$ ls
LICENSE_NATIVEIMAGE.txt	builder			clibraries.zip		macros
bin			clibraries		library-support.jar
MacBook-Air:svm adrian$ ls -lt
total 320
drwxr-xr-x   4 adrian  staff    128 Jun  5 23:18 clibraries
-rw-r--r--   1 adrian  staff  75393 Jun  5 23:18 clibraries.zip
drwxr-xr-x  16 adrian  staff    512 May  9 23:30 macros
drwxr-xr-x   4 adrian  staff    128 May  9 23:30 bin
-rw-r--r--   1 adrian  staff  21035 May  9 23:30 LICENSE_NATIVEIMAGE.txt
drwxr-xr-x  11 adrian  staff    352 May  9 23:23 builder
-rw-r--r--   1 adrian  staff  59506 Apr 16 04:41 library-support.jar

raspasov09:06:51

Btw, are you on Intel or Arm mac?

raspasov09:06:05

(not sure if that makes a difference)

phronmophobic09:06:13

it looks like I got that clibraries on June 5th

phronmophobic09:06:43

before trying with clojure

phronmophobic09:06:48

I tried Gluon Mobile

phronmophobic09:06:10

and it looks like their maven plugin modified my setup

raspasov09:06:55

I’ve seen the Gluon Mobile, what is it exactly?

raspasov09:06:10

And how does it relate to GraalVM?

phronmophobic09:06:49

They don't make it easy to decipher, but I think it's an implementation of JavaFX and some other stuff that runs iOS/android

raspasov09:06:03

Does it use GraalVM under the hood?

phronmophobic09:06:19

I've tried to exclude any proprietary stuff

raspasov09:06:24

Got it, so a wrapper on top of GraalVM to help run some Java stuff.

phronmophobic09:06:41

specifically the javaFX libraries I think

raspasov09:06:55

… to help run JavaFX on mobile.

phronmophobic09:06:08

they have included some updates to the JVM implementation for mobile as well

raspasov09:06:11

(never used javaFX myself)

phronmophobic09:06:17

but most of those changes are released under GPL

phronmophobic09:06:51

they're integrating those back in to the regular JVM repo afaik

raspasov09:06:38

Got it; alright I’ll google around as well about the missing “ios-arm64” directory.

raspasov09:06:04

You think you got it through Gluon Mobile or unsure?

phronmophobic09:06:51

I referenced their maven plugin to figure out how to compile for iOS

raspasov09:06:16

Aaaand we’re live… “Hello, world!”

phronmophobic09:06:28

did it print anything to console?

raspasov09:06:34

“hello42” 2021-06-17 02:55:22.904126-0700 MobileTest[12654:4364688] the result is: 42 2021-06-17 02:55:22.904233-0700 MobileTest[12654:4364688] the result is: 42

phronmophobic09:06:03

so you have clojure running on your device now

raspasov09:06:19

Very nice! Thank you! 🙂

phronmophobic09:06:32

now I just need to go back through the chat and improve the docs

raspasov09:06:51

Looking at the project, which Clojure code is being executed?

phronmophobic09:06:51

oh, I haven't pushed my changes that starts the nrepl socket server

raspasov09:06:02

NSLog("the result is: %d",result2);

raspasov09:06:21

(because I see this is printed from Swift)

raspasov09:06:53

Eval? String?

raspasov09:06:59

For real? 🙂 That works??

raspasov10:06:18

Is it expected to work like that?

phronmophobic10:06:56

yea, I was surprised too. Thanks to the magic of sci

raspasov10:06:13

So is this like …compiled Clojure or interpreted?

phronmophobic10:06:27

the eval is interpreted by sci

phronmophobic10:06:32

but sci is compiled to native

raspasov10:06:42

This is totally wild 🙂

clojure-spin 2
raspasov10:06:09

So do we get full Clojure here or Sci? (sorry, I am not very familiar with sci, need to learn more)

borkdude10:06:37

https://github.com/borkdude/sci you get sci, but you can hook it up to whatever Clojure library you want

borkdude10:06:09

Should be fun for making a 4clojure app in ios or so

phronmophobic10:06:09

right. the union of whatever is graalvm compatible or can be executed by sci

borkdude10:06:38

or exposing the nrepl server to do whatever from a distance

borkdude10:06:01

like, making a picture when you tell it to? dunno ;)

raspasov10:06:09

That is totally wild I gotta say 🙂 Is there a big performance penalty, do you expect to be able to just code a full app with this at this point?

phronmophobic10:06:52

not totally sure, but I think so. phones are pretty powerful these days

borkdude10:06:21

@raspasov if you are familiar with babashka, it's the same interpreter. performance is pretty good for say, replacing bash scripts

borkdude10:06:53

you can try this "full stack app" in babashka + scittle (the CLJS version of sci): https://github.com/kloimhardt/babashka-scittle-guestbook

raspasov10:06:10

Got it, cool 🙂

borkdude10:06:51

The thing where it becomes noticeably slower is when you have a loop with 1M iterations. In sci this can take 500ms whereas in Clojure it's only 20ms for example, because Clojure emits direct bytecode.

raspasov10:06:51

@smith.adriane what about that demo where you had some UI, was this using the same method?

borkdude10:06:49

But note that the functions you can hook into sci can be natively compiled, so you only pay the performance penalty for the "glue" code

raspasov10:06:07

@borkdude understood; That much looping is actually rare in a mobile app; so for some UI dev work definitely useable, I assume.

phronmophobic10:06:55

more or less. I also linked in a graphics library called skia. I have a cross platform UI library that can draw render using skia.

phronmophobic10:06:19

not sure it’s ready for general use, but you’re welcome to try

raspasov10:06:07

So you can actually get a REPL running in this? So actually do dev work, like change the UI, etc? You’d need some way to constantly serve the updated code, ala figwheel-main, shadow-cljs etc I assume.

phronmophobic10:06:00

babashka has a nrepl compatible server

phronmophobic10:06:25

I use emacs/cider, so it "just worked" for me

raspasov10:06:40

That should be no problem then, yes.

borkdude10:06:02

to do actual dev work, it depends what is evaluated at runtime and what is baked statically into the binary

raspasov10:06:33

@borkdude that’s a good point… Wonder if there’s gonna be a difference there between UIKit and SwiftUI

raspasov10:06:51

UIKit/Objective-C is very dynamic, I think you can do almost anything at runtime.

raspasov10:06:59

Not sure about SwiftUI though.

raspasov10:06:33

I lack enough knowledge about the Objective-C runtime/Swift itself to say with 100% certainty.

raspasov10:06:19

But definitely very cool, wide open possibilities 🙂

phronmophobic10:06:33

just pushed my changes that start an nrepl server

raspasov10:06:45

@smith.adriane Do you have an end goal with this experiment, or it’s just an exploration? I think if you can actually code native UI’s through Clojure, that can serve a niche, even if small.

raspasov10:06:35

Ok, I’ll pull.

borkdude10:06:58

How do you guys deploy the app to your phone? I have 0 experience with mobile, but I do have an iPhone :)

raspasov10:06:19

XCode, you need a dev account (I think?)

phronmophobic10:06:21

eventually, I'd like to replace html/css/javascript with pure clojure, but no specific timeline 😛

raspasov10:06:27

I forget if you need a dev account to run on the phone.

raspasov10:06:43

$99 a year… But you can definitely run on simulator without an account.

phronmophobic10:06:08

I think you're supposed to be able to run apps on your phone with a free account, but there's a 10 day expiration after each deploy

phronmophobic10:06:20

if I recall correctly

raspasov10:06:34

Ah, got it… @borkdude it comes down to knowing where to click inside of XCode, and it’s confusing 🙂

👆 2
raspasov10:06:04

Gotta select a team…

raspasov10:06:28

And that’s about it, it should be able to run at this point, assuming no build errors.

raspasov10:06:53

(Selecting Team applies the correct certificate)

borkdude10:06:08

ok, I might try it in the weekend

👌 2
borkdude10:06:44

what's the link of the repo again?

raspasov10:06:28

iOS simulator is pretty good, so you won’t get much out of the phone per-se. Unless you need to access camera, and some APIs which are not available on the simulator. For most UI work, the simulator is 99% accurate (performance aside, that can be misleading).

phronmophobic10:06:51

I'll try to update the docs by this weekend based on this chat

nice 2
borkdude10:06:41

cool, I'll try the simulator as well. but for me it's not real unless I can tell others to download the app and install it :)

clojure-spin 2
raspasov10:06:06

Haha for sure. Submitting the app is a whole another can of worms.

borkdude10:06:25

There is a side-loading thing for iOS right?

phronmophobic10:06:34

I haven't tried to compile for the simulator yet. I assume there's some script changes necessary

raspasov10:06:36

TestFlight, yes. That’s easier to setup.

raspasov10:06:47

@smith.adriane let me try, should be the same

raspasov10:06:18

Except for IP changes, Simulator is pretty much identical on iOS/XCode. It’s one of the few good things about Xcode 🙂

raspasov10:06:48

Ha! Actually… error

phronmophobic10:06:32

yea, I think the architecture is different

raspasov10:06:52

Ok, that is strange now. I just pulled the changes… maybe that changed something.

borkdude10:06:02

how long does compilation take on your machines? it seems it's stuck at the setup step on mine

phronmophobic10:06:48

the repo adds a new shared library function

raspasov10:06:12

Ah… Gotta recompile!

raspasov10:06:38

I just managed to compile it 30 min ago, but now I get this error.

borkdude10:06:49

I mean the shared lib

raspasov10:06:06

@borkdude yes… We went through those problems in the chat….

raspasov10:06:18

You’re referring to

raspasov10:06:24

$ ./scripts/compile-shared

phronmophobic10:06:24

you'll have to recompile the shared library

borkdude10:06:40

I am just compiling the shared library

borkdude10:06:50

this is what I was referring to, it's not working for me

borkdude10:06:01

well, it takes longer than I would expect, let's say

raspasov10:06:41

Yes… try restarting the compilation.

raspasov10:06:56

Or nuking “library” folder… It was not very clear what was the cause of that issue.

borkdude10:06:08

it seems like a deadlock, which could be related to native library loading

raspasov10:06:20

Yeah it was strange.

borkdude10:06:19

Pressing ctrl-\ dumps a thread dump

phronmophobic10:06:12

I don't think the current repo is loading any native libraries.

raspasov10:06:39

@smith.adriane FWIW, killing it right now and starting again without nuking “library” made it continue for me…

phronmophobic10:06:17

yea, that seems like a promising thread to pull

phronmophobic10:06:34

maybe it's as simple as creating all the necessary directories?

phronmophobic10:06:57

like ./library/tmp

raspasov10:06:02

Got an error: Fatal error:org.graalvm.compiler.debug.GraalError: LLVM linking failed into batch 8 (f8000-f9000). Use -H:LLVMMaxFunctionsPerBatch=1 to compile each method individually. (/Users/raspasov/projects/github/mobiletest/scripts/../library/tmp/SVM-1623926169792/llvm/b8.bc): 1

phronmophobic10:06:36

I've seen that error, but I thought it was usually when I compile with the wrong jvm

phronmophobic10:06:53

maybe it's something different or some cache error

raspasov10:06:00

[email protected] mobiletest % java --version       openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05, mixed mode, sharing)

raspasov10:06:06

It should be correct.

raspasov10:06:14

Ok let me try deleting.

raspasov10:06:35

It has a suggestion: -H:LLVMMaxFunctionsPerBatch=1

phronmophobic10:06:56

I've tried that before, but it never seems to help

raspasov10:06:02

Ok, good to know.

phronmophobic10:06:30

however, I've been using quite a bit of guess and check without 100% understanding what every flag does, so any improvements or experimentation are welcome

👌 2
raspasov10:06:14

Yeah… This is getting stuck again for me. Perhaps you’re seeing it less often because you’re on M1, and if it is a deadlock like borkdude was suggesting, it could be behaving differently on different CPUs.

phronmophobic10:06:40

at least, not directly from clojure

raspasov10:06:00

(compiling again with the new changes)

borkdude10:06:36

same problem

borkdude10:06:46

I'll check back later, exciting stuff

👍 4
raspasov11:06:55

Yeah, unfortunately this is getting stuck for me as well, and not able to compile anymore 😞

raspasov11:06:27

I’ll check back later as well, chat soon.

borkdude14:06:05

btw, you can always make an issue at oracle/graal about the (seemingly) deadlock thing, as long as you provide clear build instructions (which you already have in the repo)

👍 2
borkdude14:06:20

maybe make a branch (to keep a reference for the issue)