This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-16
Channels
- # announcements (19)
- # babashka (13)
- # beginners (7)
- # calva (8)
- # cider (25)
- # clj-kondo (12)
- # cljsrn (7)
- # clojure (60)
- # clojure-australia (5)
- # clojure-europe (59)
- # clojure-france (14)
- # clojure-gamedev (2)
- # clojure-nl (1)
- # clojure-uk (7)
- # clojurescript (43)
- # community-development (8)
- # core-async (2)
- # cursive (15)
- # datomic (75)
- # deps-new (31)
- # depstar (1)
- # fulcro (6)
- # graalvm (53)
- # holy-lambda (1)
- # juxt (3)
- # jvm (13)
- # kaocha (8)
- # lsp (109)
- # malli (14)
- # off-topic (62)
- # pathom (11)
- # pedestal (12)
- # polylith (12)
- # releases (5)
- # sci (5)
- # shadow-cljs (15)
- # sql (16)
- # tools-deps (27)
- # vim (1)
- # xtdb (14)
Sharing here as it's a good example of embedded Graal configuration with C files which I didn't see before in any other Clojure Graalvm compiled lroject
@ericdallo can you tell me more what is specifically new about this project? I don't know where to look.
I think there are some details how @huahaiy did it https://github.com/juji-io/datalevin/issues/44#issuecomment-920596489, but AFAICS there is a new jar with the native stuff inside it that already has the C files built-in
I found more details https://github.com/juji-io/datalevin/tree/master/native#compiling-datalevin-dependency-to-native-image as well
> Like all Clojure applications, class initialization needs to be done at image build time, otherwise, native image build will fail due to link errors. During the native image build time, our class initialization code extracts native libraries from the `datalevin-native` jar and put them in the GraalVM's default `CLibraryPath` for the platform (e.g. `${GRAALVM_HOME}/lib/svm/clibraries/linux-amd64/`). Make sure you have write permission for the directory. About this part: > Make sure you have write permission for the directory. @huahaiy Unfortunately this won't work for nix users like me :(
Maybe we could have a custom java class that creates a temp dir, move the C files and add the custom flag to graalvm to use that dir as the c files?
> put them in the GraalVM's default `CLibraryPath` for the platform (e.g. `${GRAALVM_HOME}/lib/svm/clibraries/linux-amd64/`) It doesn't seem like a good idea to me to write build-specific native libraries into the system installation of graalvm
But if user has no write permission on that folder it won't work, right? Do you think we can try that temp folder idea?
The reason for doing this is to support windows, as windows temporary directory path is not certain
we can use project directory where probably has a bigger chance to user has permission on that and then delete after the compilation, right?
since CLIbraryPath
is not programmatically configurable, there’s no way to specify it in our code, only as an option, that is to say, it has to be hard coded in config, which doesn’t work
the alternative is to force user to set an environment variable, which would work, but it’s extra configuration required
writing into a system installation might also be seen as suspicious by virus scanners etc. feels like a hack
yeah, for nix users for example, everything installed is imutable and doesn´t allow to write
so for me personally it's not a problem, but still, I don't like the idea of tools messing with my graalvm install. what if there is a bug and the tool removes stuff by accident for example. no.
I'd still suggest ask on graalvm slack if there is an option to override that programatically
well, they probably got too much other work to do, also they seems to prefer lock things down rather than opening it up i sense
they don’t like me asking in two channels, general have more people so i thought it is better ask there
There is also a Github Discussions board where you can ask btw, I've had some luck over there as well
@huahaiy In other new, the --initialize-at-build-time
will be deprecated in GraalVM 22. You should then remove it from your properties and use a library like https://github.com/clj-easy/graal-build-time to take care of this.