Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to and GraalVM slack:
Huahai 2021-03-09T18:50:15.104900Z

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

borkdude 2021-03-09T19:02:02.105300Z

@huahaiy Have you tried without this flag?

Huahai 2021-03-09T19:02:38.105900Z

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

Huahai 2021-03-09T19:04:51.106900Z

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

borkdude 2021-03-09T19:07:49.107600Z

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

Huahai 2021-03-09T19:13:01.109100Z

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.

Huahai 2021-03-09T19:15:33.110100Z

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

borkdude 2021-03-09T19:15:34.110200Z

@huahaiy You can override this for some classes with

borkdude 2021-03-09T19:17:09.111200Z

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

borkdude 2021-03-09T19:17:11.111400Z

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

Huahai 2021-03-09T19:17:20.111700Z

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

Huahai 2021-03-09T19:17:35.112300Z

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

Huahai 2021-03-09T19:17:46.112600Z

they build just fine

borkdude 2021-03-09T19:18:08.112900Z

I do have a Windows machine, I could test tomorrow

borkdude 2021-03-09T19:18:25.113200Z

if you have some clear instructions

Huahai 2021-03-09T19:18:32.113300Z

that would be great

Huahai 2021-03-09T19:21:30.114200Z

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

borkdude 2021-03-09T19:21:40.114600Z

@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)

borkdude 2021-03-09T19:21:50.115200Z

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

Huahai 2021-03-09T19:21:51.115300Z

right, that’s the error

borkdude 2021-03-09T19:22:16.115700Z

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

Huahai 2021-03-09T19:22:51.116300Z

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

Huahai 2021-03-09T19:23:24.117Z

the compiler has trouble dealing with that

borkdude 2021-03-09T19:23:52.117400Z

why does it have 2 disks?

Huahai 2021-03-09T19:23:59.117600Z

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

Huahai 2021-03-09T19:24:19.118100Z

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

Huahai 2021-03-09T19:24:42.118600Z

i guess that confused the compiler, hence the error

borkdude 2021-03-09T19:25:02.119Z

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

borkdude 2021-03-09T19:25:16.119500Z

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

Huahai 2021-03-09T19:25:22.119600Z

cool, let me try that

Huahai 2021-03-09T19:25:34.119900Z

do you have an example config that i can steal?

Huahai 2021-03-09T19:25:54.120500Z


Huahai 2021-03-09T19:26:11.120900Z

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

Huahai 2021-03-09T19:28:02.121400Z

thanks a lot, I will go try appveyor

ericdallo 2021-03-09T19:28:53.122700Z

@huahaiy if you need any example also, you can check clojure-lsp as well:

ericdallo 2021-03-09T19:29:12.123400Z

I use github actions for windows graalvm compilation 🙂

lread 2021-03-09T19:29:26.123900Z

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

ericdallo 2021-03-09T19:29:28.124100Z

it takes 8mins to build each platform

Huahai 2021-03-09T19:30:08.125Z

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

lread 2021-03-09T19:30:56.126500Z

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

Huahai 2021-03-09T19:31:20.127200Z

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

borkdude 2021-03-09T19:32:01.128400Z

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

Huahai 2021-03-09T19:32:06.128500Z

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

Huahai 2021-03-09T19:36:45.129700Z

thanks a lot, i will try some options