sci

Ingy döt Net 2023-08-31T15:34:28.584779Z

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

borkdude 2023-08-31T15:50:03.000849Z

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

Ingy döt Net 2023-08-31T16:17:56.115489Z

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

borkdude 2023-08-31T16:20:21.817169Z

which graalvm version? 21, 22?

borkdude 2023-08-31T16:21:30.970849Z

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

Ingy döt Net 2023-08-31T16:24:01.681379Z

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 Net 2023-08-31T16:26:28.077019Z

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

borkdude 2023-08-31T16:26:40.667479Z

can you go into your downloaded graal directory and so

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

borkdude 2023-08-31T16:26:48.900749Z

there should come up at least one svm.jar file

Ingy döt Net 2023-08-31T16:27:31.084389Z

find . -name svm.jar finds nothing

borkdude 2023-08-31T16:27:32.807319Z

the last version that I tested was graalvm CE 22.3 https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.3.1

borkdude 2023-08-31T16:27:58.778219Z

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 Net 2023-08-31T16:28:16.136369Z

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

Ingy döt Net 2023-08-31T16:28:41.735609Z

do you want me to try another graal?

borkdude 2023-08-31T16:28:53.277969Z

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

Ingy döt Net 2023-08-31T16:29:06.537439Z

I can try that

borkdude 2023-08-31T16:29:11.993139Z

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

borkdude 2023-08-31T16:29:29.470669Z

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

Ingy döt Net 2023-08-31T16:29:46.250819Z

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

Ingy döt Net 2023-08-31T16:30:17.108519Z

wait. which is newer?

borkdude 2023-08-31T16:31:16.126399Z

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

borkdude 2023-08-31T16:31:32.717819Z

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 Net 2023-08-31T16:31:48.048999Z

ok, I'll try that one

borkdude 2023-08-31T16:32:32.664639Z

java 19 22.3.1 to be precise

borkdude 2023-08-31T16:33:18.118369Z

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

borkdude 2023-08-31T16:33:20.496159Z

for libsci

borkdude 2023-08-31T16:33:34.525879Z

now let's try "Oracle GraalVM JDK 20"

borkdude 2023-08-31T16:33:55.254419Z

yeah that fails

borkdude 2023-08-31T16:34:02.133859Z

same issue as yours

Ingy döt Net 2023-08-31T16:34:04.265459Z

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 Net 2023-08-31T16:34:19.239289Z

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

borkdude 2023-08-31T16:34:43.836069Z

This link here: https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.3.1 And choose JDK19 from the right column

borkdude 2023-08-31T16:35:06.505729Z

and set GRAALVM_HOME to that

Ingy döt Net 2023-08-31T16:35:24.124919Z

ah cool

borkdude 2023-08-31T16:36:04.201769Z

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 Net 2023-08-31T16:37:11.507819Z

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

borkdude 2023-08-31T16:39:00.478119Z

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

Ingy döt Net 2023-08-31T16:39:15.280109Z

aha

borkdude 2023-08-31T16:39:18.607249Z

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

borkdude 2023-08-31T16:39:29.357949Z

now they only do 17, 19, 21, etc

borkdude 2023-08-31T16:39:35.073129Z

because they aligned with openjdk or something

Ingy döt Net 2023-08-31T16:39:55.853469Z

thanks for the explanation

borkdude 2023-08-31T16:40:02.113199Z

sure, it's very confusing

borkdude 2023-08-31T16:44:37.243299Z

I suspect they renamed

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

borkdude 2023-08-31T16:44:55.358449Z

but I'll verify this with the native image people

borkdude 2023-08-31T16:46:06.433339Z

neh I might be wrong about this

Ingy döt Net 2023-08-31T17:14:53.513579Z

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

Ingy döt Net 2023-08-31T17:17:57.213939Z

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

borkdude 2023-08-31T17:46:27.936759Z

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

borkdude 2023-08-31T18:44:28.135729Z

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.

borkdude 2023-08-31T19:03:33.074499Z

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

borkdude 2023-08-31T19:04:10.726889Z

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

Ingy döt Net 2023-08-31T20:24:17.124649Z

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

Ingy döt Net 2023-08-31T20:24:29.162199Z

so glad it works

Ingy döt Net 2023-08-31T20:38:22.729599Z

@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

borkdude 2023-08-31T20:41:11.980869Z

cool!

Ingy döt Net 2023-08-31T20:43:17.546319Z

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
Ingy döt Net 2023-08-31T17:46:58.142149Z

Can someone explain the - in https://github.com/babashka/sci/blob/master/libsci/src/sci/impl/libsci.clj#L7 -evalString?

borkdude 2023-08-31T17:47:27.168429Z

it's a convention by the gen-class stuff

borkdude 2023-08-31T17:47:34.704739Z

see gen-class's docs

✅ 1
Ingy döt Net 2023-08-31T22:10:38.148619Z

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

borkdude 2023-08-31T22:14:18.296209Z

not important, any newer version should work

✅ 1
Ingy döt Net 2023-08-31T22:10:55.062059Z

why not just 1.11.1?

Ingy döt Net 2023-08-31T22:22:53.390399Z

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
Ingy döt Net 2023-08-31T22:23:28.432149Z

those 2 jars exist

Ingy döt Net 2023-08-31T22:24:28.810759Z

oh...

Ingy döt Net 2023-08-31T22:24:39.676189Z

I think I copied your old code

Ingy döt Net 2023-08-31T22:24:47.771979Z

sigh. sec

Ingy döt Net 2023-08-31T22:31:41.646869Z

that was it

Ingy döt Net 2023-08-31T22:35:22.533839Z

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 Net 2023-08-31T22:36:23.201069Z

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

Ingy döt Net 2023-08-31T22:45:12.700519Z

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
Ingy döt Net 2023-08-31T23:42:01.230819Z

★ /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 Net 2023-08-31T23:43:43.673509Z

I need :aot [yamlscript.core]