tools-build

thheller 2021-09-11T15:52:02.113300Z

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

thheller 2021-09-11T15:53:37.114200Z

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

borkdude 2021-09-11T16:00:59.114600Z

yeah

borkdude 2021-09-11T16:01:13.114900Z

also local/roots transitive changes

borkdude 2021-09-11T16:01:16.115100Z

minor enhancement ;)

borkdude 2021-09-11T18:29:09.123100Z

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".

borkdude 2021-09-11T18:30:32.123800Z

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

borkdude 2021-09-11T18:38:44.125200Z

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)

borkdude 2021-09-11T18:40:53.125600Z

when the build does succeed, I do see those printlns

borkdude 2021-09-11T18:42:37.126500Z

(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 ?

borkdude 2021-09-11T18:42:49.126900Z

yeah

Eddie 2021-09-11T18:44:43.127600Z

Seems very similar to what I hit in this comment thread: https://ask.clojure.org/index.php/10905/control-transient-deps-that-compiled-assembled-into-uberjar?show=10908#c10908

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

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

borkdude 2021-09-11T18:45:34.129100Z

some strange stuff happening in this build: https://github.com/clj-easy/graal-build-time/runs/3576160312

Eddie 2021-09-11T18:45:55.129700Z

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.

borkdude 2021-09-11T18:45:59.129900Z

exactly!

borkdude 2021-09-11T18:46:11.130300Z

I'm doing multiple bases

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

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

borkdude 2021-09-11T18:46:32.131300Z

latest

borkdude 2021-09-11T18:46:39.131700Z

I'll double check

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

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

borkdude 2021-09-11T18:47:00.132400Z

good question

Eddie 2021-09-11T18:47:02.132500Z

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

borkdude 2021-09-11T18:47:32.133400Z

I see...

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

borkdude 2021-09-11T18:47:57.134900Z

ok

borkdude 2021-09-11T18:48:00.135100Z

thanks!

borkdude 2021-09-11T18:48:08.135400Z

(I thought I was going mental)

Eddie 2021-09-11T18:49:19.137500Z

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.

borkdude 2021-09-11T18:49:31.137800Z

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

borkdude 2021-09-11T18:50:19.139200Z

yeah

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

borkdude 2021-09-11T18:59:25.142Z

thanks!

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

should make builds faster too!

borkdude 2021-09-11T19:34:58.142600Z

@alexmiller the issue happened again: https://github.com/clj-easy/graal-build-time/runs/3576314900

borkdude 2021-09-11T19:38:17.143Z

this time it seems to happen while finding namespaces

borkdude 2021-09-11T19:38:34.143500Z

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

borkdude 2021-09-11T19:39:35.143900Z

I'll try :ns-compile

borkdude 2021-09-11T19:42:21.144100Z

didn't help.

borkdude 2021-09-11T19:42:37.144500Z

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

borkdude 2021-09-11T19:49:06.145Z

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

borkdude 2021-09-11T19:49:48.145300Z

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

2021-09-11T20:27:46.145500Z

Yes

2021-09-11T20:27:55.145900Z

That is the race mentioned earlier

2021-09-11T20:28:25.146800Z

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

2021-09-11T20:28:39.147300Z

Which causes a race on code loading

2021-09-11T20:29:11.148500Z

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

borkdude 2021-09-11T20:29:44.149100Z

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

borkdude 2021-09-11T20:29:58.149400Z

I only need a classpath basically to do that

borkdude 2021-09-11T20:30:03.149600Z

and javac

2021-09-11T20:30:41.150700Z

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

borkdude 2021-09-11T20:31:07.151Z

ok, I'll try

borkdude 2021-09-11T20:31:38.151600Z

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

borkdude 2021-09-11T20:32:06.151900Z

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

2021-09-11T20:34:53.154200Z

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

borkdude 2021-09-11T20:35:59.154400Z

true

borkdude 2021-09-11T20:50:33.155200Z

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

2021-09-11T20:59:05.156400Z

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