AOT, CLJ-322, Leiningen, and you

96 views
Skip to first unread message

Phil Hagelberg

unread,
Dec 12, 2010, 4:58:23 PM12/12/10
to clo...@googlegroups.com
So Clojure currently has a quirk (to put it tactfully) where AOT
compiling a namespace causes all the namespace's dependencies to be
AOTed as well. Chas Emerick has been cooking up a patch for this in
CLJ-322 (http://dev.clojure.org/jira/browse/CLJ-322), but not everyone
is going to be able to upgrade to 1.3.0 once that patch is applied, so
it's important that there be a workaround that can handle any Clojure
version. Leiningen 1.4.0 contains such a workaround--after performing
AOT compilation, it checks all the .class files generated and deletes
the ones that are not part of the current project.

Unfortunately this doesn't play well with protocols--unlike regular
Clojure constructs, compiling code that uses protocols hard-codes it
to the AOTed version of the protocol--it won't work with the protocol
from the .clj file if the .class file is absent. The extent of this
problem was not discovered until after Leiningen 1.4.0 was released,
so it left the deletion turned on by default.

This message is just a heads-up to let people who are having trouble
know that they can disable this behaviour if they are AOTing code that
uses protocols. Simply set the :keep-non-project-classes key to true
in project.clj. I will release a 1.4.1 version of Leiningen soon that
has this as default behaviour.

Here's the ticket discussing the problem:
https://github.com/technomancy/leiningen/issues#issue/141

I'm up for discussing alternatives--I would love to offer a way to
automatically detect problematic .class files and exclude them from
the purge.

-Phil

Reply all
Reply to author
Forward
0 new messages