This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-27
Channels
- # announcements (10)
- # beginners (95)
- # biff (2)
- # calva (33)
- # cherry (1)
- # clj-kondo (16)
- # clojure (96)
- # clojure-australia (1)
- # clojure-china (1)
- # clojure-europe (42)
- # clojure-filipino (1)
- # clojure-france (2)
- # clojure-hk (1)
- # clojure-indonesia (1)
- # clojure-japan (1)
- # clojure-korea (1)
- # clojure-my (1)
- # clojure-nl (1)
- # clojure-norway (24)
- # clojure-sg (11)
- # clojure-taiwan (1)
- # clojure-uk (1)
- # clojurescript (21)
- # cursive (22)
- # data-science (3)
- # events (7)
- # fulcro (3)
- # graalvm (4)
- # gratitude (6)
- # helix (11)
- # honeysql (7)
- # hoplon (1)
- # introduce-yourself (1)
- # jobs (2)
- # jobs-discuss (16)
- # lsp (15)
- # malli (14)
- # nbb (73)
- # practicalli (3)
- # reagent (8)
- # reitit (5)
- # releases (1)
- # ring (5)
- # rum (3)
- # sci (17)
- # scittle (7)
- # shadow-cljs (22)
- # tools-deps (26)
- # xtdb (9)
I wanted to check which code has requiring-resolve
in bb dependencies since when hitting that at runtime, the image can blow up in size, even when you require the namespace before-hand. I noticed there was one introduced in core.async in the latest release, which is used in bb.
So I wrote this hack:
(def old-requiring-resolve requiring-resolve)
(defmacro static-requiring-resolve [sym]
(prn :sym sym)
`(old-requiring-resolve ~sym))
(alter-var-root #'requiring-resolve (constantly @#'static-requiring-resolve))
(doto #'requiring-resolve (.setMacro))
(require '[babashka.main])
Sure enough, the only occurrence was the one just introduced in core.async
's go
macro which isn't used in bb and thus causes no problems.
:sym (quote clojure.core.async.impl.ioc-macros/state-machine)
This might also be useful for detecting resolve
, require
and find-var
usages, but I haven't tried that yet.If you do use the go
macro with native image it might be interesting to see how your image size fairs after the core.async update. /cc @ericdallo
I also found nice trick for detecting require
as a literal usage (as opposed to the ns form):
;; Enable this for detecting literal usages of require
;; ---
;; (def old-require require)
;; (defmacro static-require [& syms]
;; (when (meta &form)
;; (prn :require &form ))
;; `(old-require ~@syms))
;; (alter-var-root #'require (constantly @#'static-require))
;; (doto #'require (.setMacro))
;; ---
You can also look at the metadata of the form to see if it wasn't a top level form (by approximation, the column should be larger than 1 or so)