Fork me on GitHub
#sci
<
2023-08-31
>
Ingy döt Net15:08:28

I'm getting this failure trying to bb run libsci:compile https://gist.github.com/ingydotnet/d6bf87f0d5d180e8d0e1bd8543f1eabb Am I doing it wrong?

borkdude15:08:03

CI still works, on afk right now but I’ll take a look in 30 mins

Ingy döt Net16:08:56

thanks. I am on ubuntu 22.04 using graalvm-community-jdk-17.0.8_linux-x64_bin.tar.gz if that matters...

borkdude16:08:21

which graalvm version? 21, 22?

borkdude16:08:30

the issue is that the svm jar is missing on your classpath

Ingy döt Net16:08:01

for graalvm I simply downloaded https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-17.0.8/graalvm-community-jdk-17.0.8_linux-x64_bin.tar.gz and untarred it as /tmp/graalvm/ and then ran:

GRAALVM_HOME=/tmp/graalvm bb --debug run libsci:compile
in the sci master root dir

Ingy döt Net16:08:28

that's my repro. not sure that's the right way.

borkdude16:08:40

can you go into your downloaded graal directory and so

$ find . | grep svm.jar
./lib/svm/builder/svm.jar

borkdude16:08:48

there should come up at least one svm.jar file

Ingy döt Net16:08:31

find . -name svm.jar finds nothing

borkdude16:08:58

ok, then I think with newer graalvm distros you should maybe include it as a mvn dependency, let me read some docs

Ingy döt Net16:08:16

yeah, for some reason @U0479UCF48H directed me to use 17.0.8

Ingy döt Net16:08:41

do you want me to try another graal?

borkdude16:08:53

or perhaps this only works when you do $GRAALVM_HOME/gu install native-image

Ingy döt Net16:08:06

I can try that

borkdude16:08:11

yes, I think you'll have better luck with the version that I posted since I only used that one

borkdude16:08:29

but I'll try to see if I can fix it for the new graal version

Ingy döt Net16:08:46

not sure why @U0479UCF48H suggested the other. I started with most recent

Ingy döt Net16:08:17

wait. which is newer?

borkdude16:08:16

to make matters more complicated, there is also Oracle GraalVM which is different from GraalVM CE

borkdude16:08:32

it's not about newer, it's about which version runs on CI with libsci currently, and that is 22.3.1

Ingy döt Net16:08:48

ok, I'll try that one

borkdude16:08:32

java 19 22.3.1 to be precise

borkdude16:08:18

I can confirm that that version still works for me locally here

borkdude16:08:34

now let's try "Oracle GraalVM JDK 20"

borkdude16:08:55

yeah that fails

borkdude16:08:02

same issue as yours

Ingy döt Net16:08:04

You said > but I'll try to see if I can fix it for the new graal version 22.3.1 works and I said 17.0.8 (which seems older) doesn't. is there a third?

Ingy döt Net16:08:19

> java 19 22.3.1 to be precise I thought java was bundled in there

borkdude16:08:06

and set GRAALVM_HOME to that

borkdude16:08:04

Meanwhile I'll try to figure out the issue with the new stuff. In newer versions GraalVM adopts the JVM version number, before they had their independent (22.3.1) version number + a JDK version, so it's matrix of choices there

Ingy döt Net16:08:11

but 22.3.1 is newer than 17.0.8 right? what's the new stuff?

borkdude16:08:00

no, 22.3.1 is a GraalVM version number from before they moved to another versioning schema and 17.0.8 is a JDK version number

borkdude16:08:18

before they used 22.3.1/17, 22.3.1/19, 22.3.1/21 etc

borkdude16:08:29

now they only do 17, 19, 21, etc

borkdude16:08:35

because they aligned with openjdk or something

Ingy döt Net16:08:55

thanks for the explanation

borkdude16:08:02

sure, it's very confusing

borkdude16:08:37

I suspect they renamed

import com.oracle.svm.core.c.CConst;
to:
import org.graalvm.nativeimage.c.type.CCharPointer;
etc.

borkdude16:08:55

but I'll verify this with the native image people

borkdude16:08:06

neh I might be wrong about this

Ingy döt Net17:08:53

Finished generating 'libsci' in 1m 58s. graalvm-ce-java19-linux-amd64-22.3.1.tar.gz thank you.

Ingy döt Net17:08:57

Is there any tooling to automate stuff like libsci/src/sci/impl/LibSci.java ?

borkdude17:08:27

automate as in code-gen that stuff? not that I know of

borkdude18:08:28

Hmm, changing the CConst package to import org.graalvm.nativeimage.c.type.CConst; worked, so it does seem a breaking change on their side, sadly.

borkdude19:08:33

alright, merged the change, now it only works with the newest graalvm version, see the latest commit on master. Note that this is a practice we don't like in the clojure ecosystem: they removed a class which is a breaking change

borkdude19:08:10

in this case it doesn't really matter since libsci is more a demo than a library, but anway

Ingy döt Net20:08:17

it's the perfect demo for what I need to do today

Ingy döt Net20:08:29

so glad it works

Ingy döt Net20:08:17

libsci is almost a perfect recipe for the libyamlscript shared lib system I'm building and binding to various languages starting with python. so glad you did libsci 🙂

👍 2
borkdude17:08:27

it's a convention by the gen-class stuff

borkdude17:08:34

see gen-class's docs

2
Ingy döt Net22:08:38

is this important https://github.com/babashka/sci/blob/master/project.clj#L20 ? the libsci:compile target uses it

borkdude22:08:18

not important, any newer version should work

2
Ingy döt Net22:08:55

why not just 1.11.1?

Ingy döt Net22:08:53

Not sure what's this

$ /tmp/graalvm/bin/javac -cp target/libyamlscript-0.1.0-standalone.jar:/tmp/graalvm/lib/svm/builder/svm.jar src/libyamlscript/Core.java 
src/libyamlscript/Core.java:9: error: cannot find symbol
import com.oracle.svm.core.c.CConst;
                            ^
  symbol:   class CConst
  location: package com.oracle.svm.core.c
src/libyamlscript/Core.java:15: error: cannot find symbol
        @CConst CCharPointer s

2
Ingy döt Net22:08:28

those 2 jars exist

Ingy döt Net22:08:39

I think I copied your old code

Ingy döt Net22:08:22

Trying to understand this line https://github.com/babashka/sci/blob/master/libsci/src/sci/impl/LibSci.java#L12 String result = sci.impl.libsci.evalString(expr); is sci.impl.libsci there referring to the clj code or the java code?

Ingy döt Net22:08:23

I guess clj, as there's no (lowercase) libsci

Ingy döt Net22:08:12

I have these 2 files modeled after the libsci example: https://github.com/yaml/yamlscript/blob/clojure/libyamlscript/src/libyamlscript/core.clj > https://github.com/babashka/sci/blob/master/libsci/src/sci/impl/libsci.clj https://github.com/yaml/yamlscript/blob/clojure/libyamlscript/src/libyamlscript/Core.java > https://github.com/babashka/sci/blob/master/libsci/src/sci/impl/LibSci.java but when I try to compile the java (after building the clojure uberjar) I get:

★ ~/src/yamlscript/libyamlscript clojure $ lein do clean, uberjar
Created /home/ingy/src/yamlscript/libyamlscript/target/libyamlscript-0.1.0.jar
Created /home/ingy/src/yamlscript/libyamlscript/target/libyamlscript-0.1.0-standalone.jar
★ ~/src/yamlscript/libyamlscript clojure $ /tmp/graalvm/bin/javac -cp target/libyamlscript-0.1.0-standalone.jar:/tmp/graalvm/lib/svm/builder/svm.jar src/libyamlscript/Core.java 
src/libyamlscript/Core.java:18: error: cannot find symbol
        String json = libyamlscript.core.evalYsToJson(ys);
                                   ^
  symbol:   class core
  location: package libyamlscript
1 error
any help would be appreciated

2
Ingy döt Net23:08:01

★ /tmp/sci master $ git clean -dxf
★ /tmp/sci master $ lein uberjar
Compiling sci.impl.main
Created /tmp/sci/target/sci-0.8.40.jar
Created /tmp/sci/target/sci-0.8.40-standalone.jar
★ /tmp/sci master $ unzip -l target/sci-0.8.40.jar | grep libsci
★ /tmp/sci master $ git clean -dxf
Removing target/
★ /tmp/sci master $ lein with-profiles +libsci,+native-image uberjar
Compiling sci.impl.main
Compiling sci.impl.libsci
Created /tmp/sci/target/sci-0.8.40.jar
Created /tmp/sci/target/sci-0.8.40-standalone.jar
★ /tmp/sci master $ unzip -l target/sci-0.8.40.jar | grep libsci
     1349  2023-08-31 16:39   sci/impl/libsci$fn__5658.class
     2176  2023-08-31 16:39   sci/impl/libsci$loading__6737__auto____4946.class
     2599  2023-08-31 16:39   sci/impl/libsci__init.class
     1465  2023-08-31 16:39   sci/impl/libsci$_evalString.class
     1936  2023-08-31 16:39   sci/impl/libsci$_evalString$fn__5660.class
     2243  2023-08-31 16:39   sci/impl/libsci.class
      560  2023-08-31 07:37   sci/impl/libsci.clj
getting closer

Ingy döt Net23:08:43

I need :aot [yamlscript.core]