tools-build 2021-09-11

you may want to account for the build files themselves changing, not just src

mistake I made in shadow-cljs caching code. only accounting for the actual sources, not the code or config that compiled it 😛

also local/roots transitive changes

minor enhancement ;)

I have a very strange issue with b/compile-clj. Some builds just work fine, but randomly sometimes I see:

Syntax error (IllegalAccessError) compiling at (clojure/tools/reader.clj:1:1).
read-char does not exist
when invoking it in my build. I don't even get why it's compiling tools reader, it's not even a dependency of my "basis".

you can follow some commits over here: https://github.com/clj-easy/graal-build-time/commits/debug I'm adding empty commits named debug just to trigger the build and keep the logs available (when you re-trigger a build the logs get lost)

Alex Miller (Clojure team) 2021-09-11T18:37:56.124400Z

when the compile fails, it will leave the entrails in the tmp directory if you'd like to examine them

Alex Miller (Clojure team) 2021-09-11T18:38:26.124800Z

not sure if you have access to that

it seems it doesn't even enter the compile-clj function, I included the source and added some printlns.

(defn compile-clj
  [{:keys [basis src-dirs compile-opts ns-compile filter-nses class-dir sort] :as params
    :or {sort :topo}}]
  (prn :params params)

when the build does succeed, I do see those printlns

(defn compile-sources [_]
  (println "Compiling sources")
  (if (bs/needs-compile?)
    (do
      (prn "basis:")
      (prn (keys (:classpath basis)))
      (println "Compiling Clojure sources.")
      (b/compile-clj {:basis basis
                      :src-dirs bs/sources
                      :class-dir class-dir
                      :ns-compile '[clj-easy.graal-build-time]})
      (println "Done compiling Clojure sources.")
      (println "Compiling java sources.")
      (b/javac {:src-dirs bs/sources
                :class-dir class-dir
                :basis with-svm-basis
                :javac-opts ["-source" "8" "-target" "8"]})
      (println "Done compiling java sources."))
    (println "All up to date, nothing to compile.")))
After "Compiling Clojure sources":
Syntax error (IllegalAccessError) compiling at (clojure/tools/reader.clj:1:1).
read-char does not exist
hmm.

Alex Miller (Clojure team) 2021-09-11T18:42:39.126700Z

can you run the cli with -J-Dclojure.main.report=stderr ?

Alex Miller (Clojure team) 2021-09-11T18:44:59.128300Z

that's a protocol function, maybe an ordering issue during compilation?

I noticed you also had multiple create-basis, which was triggering a race condition on an older version of tools.deps that I had on my machine.

I'm doing multiple bases

Alex Miller (Clojure team) 2021-09-11T18:46:28.131Z

on latest of tools.build / tools.deps or older?

I'll double check

Alex Miller (Clojure team) 2021-09-11T18:46:50.132100Z

actually, is tools.build using latest? don't know

good question

Interesting. I don't see this issue on the latest tools.deps, but definitely did on an older one.

Alex Miller (Clojure team) 2021-09-11T18:47:19.132900Z

no, it's using older

Alex Miller (Clojure team) 2021-09-11T18:47:48.134200Z

org.clojure/tools.deps.alpha {:mvn/version "0.12.1036"}

Alex Miller (Clojure team) 2021-09-11T18:47:55.134700Z

is latest, you can add that to your build alias

(I thought I was going mental)

If you can't upgrade for some reason, hiredman's solution in the thread I linked should work. Just preload the troublesome namespaces at the top of the build.clj.

cool, yeah, upgrading is possible

👍 1
Alex Miller (Clojure team) 2021-09-11T18:49:38.138200Z

I don't think that would do anything - compilation is in a forked jvm

Alex Miller (Clojure team) 2021-09-11T18:50:07.138800Z

oh, sorry basis creation

Alex Miller (Clojure team) 2021-09-11T18:53:55.140100Z

in the prior maven core version, they removed all the synchronization stuff, we've been having a lot of problems since then, no surprise

Alex Miller (Clojure team) 2021-09-11T18:55:08.141400Z

the latest tools.deps moves to the fixes for that, and also cleans up a bunch of things where tools.deps was redoing work (some accidentally, some knowingly)

Alex Miller (Clojure team) 2021-09-11T18:57:19.141800Z

released new tools.build v0.3.0 e418fc9 with the dep update

Alex Miller (Clojure team) 2021-09-11T19:03:13.142200Z

should make builds faster too!

this time it seems to happen while finding namespaces

perhaps it triggers compilation because of some top level compile that gets evaluated?

I'll try :ns-compile

didn't help.

why does it even invoke find-ns when I provide :ns-compile, this seems weird

managed to trigger another one (different trace): https://github.com/clj-easy/graal-build-time/runs/3576363220

that has a similar error, but doesn't fail the build

That is the race mentioned earlier

There is another thread that maven kicks off, and it calls back into clojure

Which causes a race on code loading

The reason you got a stacktrace and it didn't fail the build is it happened on the other thread that time

yeah, I figured that. hrm... I could just script the compilation manually for now

I only need a classpath basically to do that

https://ask.clojure.org/index.php/10905/control-transient-deps-that-compiled-assembled-into-uberjar?show=10913#c10913 as I suggest here you can also preload the code (by requiring the right namespace) to avoid the race

ok, I'll try

shouldn't this s3 / aws stuff be split out of tools.deps.alpha perhaps? I mean, the majority of projects probably don't even use this

we use it at work, but I also know many projects that don't

It is tricky, because it needs to be on the classpath for tools.deps to use if it is going to use it, but tools.deps is the tool for building classpaths

but wait a minute, that's true for the tools jar used by the CLI, but not for tools.build, as tools.build is just a library which you can extend by adding more libraries into the alias

Ah, of course right, and tools.deps is just another library being used as part of the build there

Alex Miller (Clojure team) 2021-09-11T21:28:15.157100Z

we consider the s3 support to be a core feature, so not going to split it out

Alex Miller (Clojure team) 2021-09-11T21:29:43.157800Z

but clearly it's time to circle back to this parallel load stuff and reeexamine