Order of compilation is non-deterministic

18 views
Skip to first unread message

Stuart Sierra

unread,
Jan 29, 2010, 2:45:39 PM1/29/10
to Clojure Maven Plugin
The order in which namespaces get AOT-compiled by clojure-maven-plugin
is different depending on the filesystem, and possibly the OS.

This leads to unpredictable results. For example, clojure-contrib
builds perfectly on my machine, but fails on build.clojure.org.

I don't think there's a perfect solution to this, but sorting the
discovered namespaces before compiling would at least make it
predictable.

Sorting in reverse order might be best; that way you would get
"deeper" namespaces before the "shallower" namespaces that typically
depend on them.

-SS

Mark Derricutt

unread,
Jan 29, 2010, 2:51:10 PM1/29/10
to clojure-ma...@googlegroups.com

Out of town currently but there is an option to useDeclaredNamespaces or the like from memory.  Or maybe that was an earlier codebase?

-- Sent from an Android.  Just say no to the iPhone.

Stuart Sierra

unread,
Jan 29, 2010, 2:59:34 PM1/29/10
to Clojure Maven Plugin
On Jan 29, 2:51 pm, Mark Derricutt <m...@talios.com> wrote:
> Out of town currently but there is an option to useDeclaredNamespaces or the
> like from memory.  Or maybe that was an earlier codebase?

Yes, it's not documented but
<compileDeclaredNamespaceOnly>true</compileDeclaredNamespaceOnly>
in the plugin configuration will limit AOT-compilation to the
configured namespaces, in the order they are declared.

-SS

Chas Emerick

unread,
Jan 29, 2010, 3:02:38 PM1/29/10
to clojure-ma...@googlegroups.com
That would definitely be going into punting territory.

Stuart, the plugin is just passing the namespaces on to clojure.lang.Compile as arguments, so the order really shouldn't impact compilation as far as I understand it?

- Chas

Stuart Sierra

unread,
Jan 29, 2010, 3:09:04 PM1/29/10
to Clojure Maven Plugin
On Jan 29, 3:02 pm, Chas Emerick <cemer...@snowtide.com> wrote:
> Stuart, the plugin is just passing the namespaces on to  
> clojure.lang.Compile as arguments, so the order really shouldn't  
> impact compilation as far as I understand it?

It shouldn't, but it does. In clojure-contrib, the problematic
namespaces are:

1. c.c.pprint.ColumnWriter
2. c.c.pprint.PrettyWriter
3. c.c.pprint

The first two are gen-class'd, and PrettyWriter extends the class
generated for ColumnWriter.

Unless they are compiled in exactly the order given above, the build
fails with a ClassNotFoundException.

-SS

Chas Emerick

unread,
Jan 29, 2010, 3:17:04 PM1/29/10
to clojure-ma...@googlegroups.com
I hit this one before; I believe if you require
clojure.contrib.pprint.ColumnWriter in PrettyWriter's ns declaration
(perhaps before the :gen-class form?), then the compiler will visit
and gen CW before attempting to gen-class PW.

I remember suggesting that any classname being extended by gen-class
be implicitly required as a namespace, but I don't think that was
considered good form. *shrug*.

- Chas

Reply all
Reply to author
Forward
0 new messages