Skip to content

Conversation

arohner
Copy link
Contributor

@arohner arohner commented Oct 6, 2025

Under Bazel, building for the compilation platform is considered a separate architecture than the production platform, typically e.g. darwin-opt-exec vs. darwin-fastbuild. This causes bazel to build some artifacts twice, even if they are architecture independent. This is also the source of a race condition that prevents #70 from merging.

This PR adds support for path mapping to rules_clojure. See bazelbuild/bazel#22658 for more detail, but TL;DR, we have to pass Bazel File to rules, not String paths, which necessitated getting rid of passing JSON strings to rules_clojure.

There are no user visible behavior changes yet, we have to enable path mapping via --experimental_output_paths=strip in banksy. We can't enable that until we upgrade e.g. rules_jvm_external, which requires moving to Bazel 8 and modules, coming in another PR.

Comment on lines +151 to +159
[[nil "--classes-dir dir" "output directory where classfiles will be written"]
[nil "--output-jar jar" "output jar name"]
[nil "--resource-strip-prefix path" ]
[nil "--aot-nses ns" "names of namespaces to AOT. May be repeated"
:default []
:update-fn conj
:multi true]
[nil "--classpath cp" "classpath to use while compiling, separated by :"
:parse-fn parse-classpath]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need --srcs and --resources too?

Comment on lines +144 to +145
;; [--classes-dir bazel-out/darwin_arm64-fastbuild/bin/external/deps/.ns_metosin_reitit_core_reitit_exception.classes --output-jar bazel-out/darwin_arm64-fastbuild/bin/external/deps/ns_metosin_reitit_core_reitit_exception.jar --resource-strip-prefix '' --aot-ns reitit.exception --classpath external/deps/repository/metosin/reitit-core/0.6.0/reitit-core-0.6.0.jar:external/deps/repository/meta-merge/meta-merge/1.0.0/meta-merge-1.0.0.jar:external/deps/repository/org/clojure/clojure/1.12.2/clojure-1.12.2.jar:external/deps/repository/org/clojure/core.specs.alpha/0.4.74/core.specs.alpha-0.4.74.jar:external/deps/repository/org/clojure/spec.alpha/0.5.238/spec.alpha-0.5.238.jar:bazel-out/darwin_arm64-fastbuild/bin/external/rules_clojure/src/rules_clojure/libcompile.jar]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
;; [--classes-dir bazel-out/darwin_arm64-fastbuild/bin/external/deps/.ns_metosin_reitit_core_reitit_exception.classes --output-jar bazel-out/darwin_arm64-fastbuild/bin/external/deps/ns_metosin_reitit_core_reitit_exception.jar --resource-strip-prefix '' --aot-ns reitit.exception --classpath external/deps/repository/metosin/reitit-core/0.6.0/reitit-core-0.6.0.jar:external/deps/repository/meta-merge/meta-merge/1.0.0/meta-merge-1.0.0.jar:external/deps/repository/org/clojure/clojure/1.12.2/clojure-1.12.2.jar:external/deps/repository/org/clojure/core.specs.alpha/0.4.74/core.specs.alpha-0.4.74.jar:external/deps/repository/org/clojure/spec.alpha/0.5.238/spec.alpha-0.5.238.jar:bazel-out/darwin_arm64-fastbuild/bin/external/rules_clojure/src/rules_clojure/libcompile.jar]

Comment on lines +51 to +52
;; bazel requires us to write to stdout, and doesn't reliably report
;; stderr, so log to a temp file to guarantee we find everything.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird. these docs say

Writing it to the stderr of the worker process is safe, but the result is collected in a per-worker log file [...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It works ~80-90% of the time. The main place I've noticed it not working is when rules_clojure hangs forever and you have to interrupt it (Ctrl+C), you get no logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants