<< Back to previous view

[CLJS-592] Clojurescript compiler cannot be AOT compiled Created: 19/Sep/13  Updated: 04/Feb/14  Resolved: 04/Feb/14

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: File aot-metadata.diff    

 Description   

With Clojurescript 0.0-1859:

user=> (binding [*compile-files* true] (require 'cljs.analyzer 'cljs.compiler))
nil
user=> (cljs.compiler/with-core-cljs)
AssertionError Assert failed: set! target must be a field or a symbol naming a var
targetexpr  cljs.analyzer/fn--1668 (analyzer.clj:593)


 Comments   
Comment by David Nolen [ 05/Oct/13 2:41 PM ]

Is there any more information about what exactly is required or expected? Or hints about what needs to be done to resolve this issue? Thanks!

Comment by Ambrose Bonnaire-Sergeant [ 04/Feb/14 9:02 AM ]

The root of this issue seems to be the call to `import-macros` at the top of cljs.core.

Under AOT compilation, the macros are imported as regular functions. This seems to be due to a weird property under AOT where attaching metadata to a var def must be done with alter-meta!, rather than by attaching metadata to the second argument of `def`.

This is a telling symptom:

user=> (binding [*compile-files* true] (require 'cljs.core))
nil
user=> (-> #'cljs.core/when meta :macro)
nil

The patch adds a redundant call to `alter-meta!`.

Behaviour before patch (https://github.com/clojure/clojurescript/commit/070b677a2192912d4f9e933f34c19055b571d101):

user=> (binding [*compile-files* true] (require 'cljs.core))
nil
user=> (require '[cljs [analyzer :as ana] [compiler :as comp] [env :as env]] :verbose)
...
nil
user=> (do (env/ensure (comp/with-core-cljs)) nil)
ExceptionInfo Can't recur here at line 158 file:/home/ambrose/.m2/repository/org/clojure/clojurescript/0.0-SNAPSHOT/clojurescript-0.0-SNAPSHOT.jar!/cljs/core.cljs  clojure.core/ex-info (core.clj:4327)

After patch:

user=> (binding [*compile-files* true] (require 'cljs.core))
nil
user=> (require '[cljs [analyzer :as ana] [compiler :as comp] [env :as env]] :verbose)
(clojure.core/in-ns 'user)
(clojure.core/alias 'ana 'cljs.analyzer)
(clojure.core/in-ns 'user)
(clojure.core/alias 'comp 'cljs.compiler)
(clojure.core/in-ns 'user)
(clojure.core/alias 'env 'cljs.env)
nil
user=> (do (env/ensure (comp/with-core-cljs)) nil)
nil
Comment by David Nolen [ 04/Feb/14 9:08 AM ]

fixed https://github.com/clojure/clojurescript/commit/f7f6517d196bca522e1b6e9a1f2218a87df69e69

Generated at Wed Oct 01 03:17:46 CDT 2014 using JIRA 4.4#649-r158309.