Fork me on GitHub
#graalvm
<
2021-03-09
>
Huahai18:03:15

i have a question, it may be obvious, but why all the native image build guides for Clojure recommend --initialize-at-build-time ?

borkdude19:03:02

@huahaiy Have you tried without this flag?

Huahai19:03:38

yes, i did, and it failed. clojure.lang.PersistentList$EmptyList etc. will be initialized and it is not allowed.

Huahai19:03:51

so it is because initializing these at build time is unavoidable?

borkdude19:03:49

Afaik build time = better for perf, but sometimes you need to delay this until runtime because of side effects like starting threads

Huahai19:03:01

ok, thanks. the reason i asked is because some guys in graalvm channel seems to think that initialize at build time should be exception rather than the norm.

Huahai19:03:33

the problem i am trying to solve is to build native image on windows, it fails with “other” has different root

borkdude19:03:34

@huahaiy You can override this for some classes with --initialize-at-runtime=foo.bar.Clazz

borkdude19:03:09

Your issue also seems related to the reflection issue with clojure.lang.Reflector

borkdude19:03:11

WARNING: Method java.lang.reflect.Method.canAccess(Object) not found.

Huahai19:03:20

i don’t have a windows machine, so i have to use github action, they put the files on different disk, hence the error i guess

Huahai19:03:35

that one is ok, i have that in linxu and mac as well

Huahai19:03:46

they build just fine

borkdude19:03:08

I do have a Windows machine, I could test tomorrow

borkdude19:03:25

if you have some clear instructions

Huahai19:03:32

that would be great

Huahai19:03:30

i can check in the workflow yml file that i used for testing windows build on github actions, would that be sufficient?

borkdude19:03:40

@huahaiy Are you absolutely sure it's not related to the reflector issue? Fatal error:java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'other' has different root # Static libraries: at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

borkdude19:03:50

Try to add the suggested config from clj-graal-docs

Huahai19:03:51

right, that’s the error

borkdude19:03:16

yeah, might not be related, but one less thing to worry about

Huahai19:03:51

i think i know why, it’s because there are two disks involved c:\ and d:\

Huahai19:03:24

the compiler has trouble dealing with that

borkdude19:03:52

why does it have 2 disks?

Huahai19:03:59

if you have windows machine, you will probably not have the problem

Huahai19:03:19

github actions put user file under d:\ and their own libs under c:\

Huahai19:03:42

i guess that confused the compiler, hence the error

borkdude19:03:02

maybe try appveyor. I build all my graalvm stuff there for Windows

borkdude19:03:16

honestly Github actions is quite slow too compared to the rest (CircleCI, Appveyor)

Huahai19:03:22

cool, let me try that

Huahai19:03:34

do you have an example config that i can steal?

Huahai19:03:11

yes, github action is very slow, it took like 13 minutes to build datalevin

Huahai19:03:02

thanks a lot, I will go try appveyor

ericdallo19:03:12

I use github actions for windows graalvm compilation 🙂

lread19:03:26

A couple of things GitHub Actions have that are kinda nice if you need/want them: macOS in the free tier and more RAM.

ericdallo19:03:28

it takes 8mins to build each platform

Huahai19:03:08

i guess it is because i build datalevin twice, once for the command line tool, once for the native tests

lread19:03:56

I’m currently on GitHub Actions for rewrite-clj v1 where I do some GraalVM native-image testing.

Huahai19:03:20

thanks for the example. I will see if it helps. one thing that might be different is that i do need to build C code

borkdude19:03:01

rewrite-clj / clj-kondo / clojure-lsp aren't such heavy tools, but as soon as you require a little bit more, Github actions really shows that it's just built for "actions" on your source code, rather than building stuff with good performance. Probably good enough for JavaScript projects

Huahai19:03:06

i suspect that’s where the different root problem come from, when loading the built c lib

Huahai19:03:45

thanks a lot, i will try some options