Closed lread closed 4 months ago
Stop testing single-segment namespaces
I vote for that one
@borkdude and I chatted. I shared that the --initialize-at-build-time
for the single segment namespace worked in my local testing. He found that surprising because he did not have success with this kind of thing in the past:
If you compile that namespace, you'll see many more classes than just this one. previously I got errors when not explicitly mentioning them
I will:
I experimented with digest by using its (now deprecated) single-segement digest
namespace.
org.clj-commons/digest {:mvn/version "1.4.100"}
dep to test-hello-world/deps.edn
test-hello-world/src/hello_word/main.clj
[digest]
under to :require
-main
like so: (println "md5 digest for clojure" (digest/md5 "clojure"))
cd test-hello-world
bb clean
bb build
java -jar target/hello-world.jar
Resulted in, as expected:
md5 digest for clojure 32c0d97f82a20e67c6d184620f6bd322
Hello world
From project root:
bb clean
bb native-image-test
Yielded native-image
error reported in this issue, but instead for digest$digest
.
Edited test-hello-world/bb.edn
to include --initialize-at-build-time=digest$digest
for native-image
calls.
From project root:
bb clean
bb native-image-test
This run shows probably more of what @borkdude experienced.
The native-image
error matched the error reported in this issue, but instead for each of: digest$fn__193
, digest$fn__191
, digest$fn__189
,digest$fn__187
,digest$fn__179
,digest$fn__177
, and digest$fn__164
.
Single-segment namespaces cannot be handled easily by via --initialize-at-build-time
.
Perhaps there is some way to initialize them properly with an agent?
As single-segment namespaces are an anti-pattern in Clojure, I'm happy not to invest any time in finding a way to make them work in conjunction with graal-build-time and to continue to consider them out of scope and unsupported.
So option 3, Stop testing single-segment namespaces, it is!
I think I'll leave our single-segment warning message in, it could be a helpful hint as to why the build has failed.
Starting with GraalVM 22,
--strict-image-heap
is enabled by default.Here's the error we now get if I run
bb native-image-test
using GraalVM 22.0.1:Congrats to the Graal team for the comprehensive error message!
So what's happening is that we skip registering the single-segment namespace for build-time initialization because it has no package, but with
--strict-image-heap
now enabled by default, because the single-segment namespace is not initialized at build time, we get the error above.This breaks our native image test but seems like reasonable behaviour to me.
Options to fix our
native-image-test
:-H:-StrictImageHeap
option tonative-image
to disable strict image heap--initialize-at-build-time=single_segment_example$dummy
option tonative-image
native-image
to failI think I like option 2. It gives some hint to the dogged how they might actually init a single segment namespace while not encouraging turning off the now default strict image heap.