Fork me on GitHub
#sci
<
2023-09-01
>
Ingy döt Net18:09:21

I just noticed this command after the native-image build in bb run libsci:compile

/usr/lib/jvm/java-17-openjdk-amd64/bin/java \
    -XX:-OmitStackTraceInFastThrow \
    -classpath /home/ingy/.deps.clj/1.11.1.1347/ClojureTools/clojure-tools-1.11.1.1347.jar \
    clojure.main \
    -m clojure.tools.deps.script.make-classpath2 \
    --config-user /home/ingy/.clojure/deps.edn \
    --config-project deps.edn \
    --basis-file .cpcache/F6929CC9A17B2FF3D31EE7A6D061797C.basis \
    --cp-file .cpcache/F6929CC9A17B2FF3D31EE7A6D061797C.cp \
    --jvm-file .cpcache/F6929CC9A17B2FF3D31EE7A6D061797C.jvm \
    --main-file .cpcache/F6929CC9A17B2FF3D31EE7A6D061797C.main \
    --manifest-file .cpcache/F6929CC9A17B2FF3D31EE7A6D061797C.manifest \
    --config-data '{:deps {borkdude/deps.clj {:mvn/version "0.0.1"}}}'
what is that for?

borkdude18:09:14

This is just dependency stuff that you would not normally see, but since you added the print thing you now see it

Ingy döt Net18:09:59

🙂 thanks. looked like something I didn't need. good to confirm.

Ingy döt Net18:09:42

I'm getting closer... Might have 1 or 2 more questions...

Ingy döt Net22:09:02

what does do for the libsci example?

Ingy döt Net22:09:41

I can build libyamlscript.so and it has my eval_ys_to_json entrypoint, but I get

java.lang.ExceptionInInitializerError: null
    at clojure.lang.Namespace.<init>(Namespace.java:34)
    at clojure.lang.Namespace.findOrCreate(Namespace.java:176)
    at clojure.lang.Var.internPrivate(Var.java:153)
    at libyamlscript.core.<clinit>(null:-1)
    at libyamlscript.Core.evalYsToJson(Core.java:18)
when I call it from python with:
#!/usr/bin/env python3

import sys
from ctypes import *

ys_input = sys.stdin.read()

print(ys_input)

libyamlscript = CDLL("./lib/libyamlscript.so")
isolate = c_void_p()
isolatethread = c_void_p()
libyamlscript.graal_create_isolate(None, byref(isolate), byref(isolatethread))

eval_ys_to_json = libyamlscript.eval_ys_to_json
eval_ys_to_json.restype = c_char_p

print(eval_ys_to_json)

result = eval_ys_to_json(isolatethread, c_char_p(bytes(ys_input, "utf8")))

print(result)

borkdude22:09:52

it allows you to do Java interop on those classes, if, you also include those classes in the SCI context

Ingy döt Net22:09:58

Trying to determine which options are required for native-image

borkdude22:09:19

it seems you haven't included --initialize-at-runtime options here

Ingy döt Net22:09:25

currently only using

native-image \
    --silent \
    --no-fallback \
    --shared \
    -jar target/libyamlscript-0.1.0-standalone.jar \
    -cp src \
    -H:Name=/home/ingy/src/yamlscript/libyamlscript/lib/libyamlscript

borkdude22:09:54

yeah, this is bad

Ingy döt Net22:09:57

right, when I use that the build blows up

borkdude22:09:45

I can look into more detail tomorrow, I have dealt with quite a few of these problems myself, if you have any links to failing builds, etc. It's night time here now, so ttyl

Ingy döt Net22:09:35

thanks. have a good night. I'll leave stuff here as appropriate.