sci 2023-08-31

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

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

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

which graalvm version? 21, 22?

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

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

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

can you go into your downloaded graal directory and so

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

there should come up at least one svm.jar file

find . -name svm.jar finds nothing

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

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

do you want me to try another graal?

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

I can try that

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

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

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

wait. which is newer?

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

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

ok, I'll try that one

java 19 22.3.1 to be precise

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

now let's try "Oracle GraalVM JDK 20"

yeah that fails

same issue as yours

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?

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

and set GRAALVM_HOME to that

ah cool

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

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

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

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

now they only do 17, 19, 21, etc

because they aligned with openjdk or something

thanks for the explanation

sure, it's very confusing

I suspect they renamed

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

but I'll verify this with the native image people

neh I might be wrong about this

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

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

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

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.

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

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

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

so glad it works

@borkdude fyi I built the the HEAD and tested the python steps from https://github.com/babashka/sci/blob/master/doc/libsci.md#using-libsci-from-python and all works

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 🙂

👍 1

it's a convention by the gen-class stuff

see gen-class's docs

✅ 1

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

not important, any newer version should work

✅ 1

why not just 1.11.1?

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

✅ 1

those 2 jars exist

I think I copied your old code

sigh. sec

that was it

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?

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

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

✅ 1

★ /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

I need :aot [yamlscript.core]