summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2015-11-30 10:54:50 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2015-11-30 10:56:32 +0100
commitb51f678cefbb43e8bc521a83e9830e4cb845a698 (patch)
treea80e6aa42c261f8f3bb859de38ddb5015776ce47
parentd05f0f2581f39c1b88c469b1c48a6b2ec4d9cc96 (diff)
downloadrabbitmq-server-git-b51f678cefbb43e8bc521a83e9830e4cb845a698.tar.gz
Fix HiPE compilation during startup
Now that several modules were moved to rabbitmq-common, they are stored in an EZ archive and do not exist as simple files on disk. hipe:c/1 expects the file to exist. So now, we get the code from code:get_object_code/1 and pass it to hipe:compile/4. Fixes #455.
-rw-r--r--src/rabbit.erl15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl
index b3e6c95438..2f9b427c27 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -281,8 +281,21 @@ hipe_compile() ->
io:format("~nHiPE compiling: |~s|~n |",
[string:copies("-", Count)]),
T1 = time_compat:monotonic_time(),
+ %% We use code:get_object_code/1 below to get the beam binary,
+ %% instead of letting hipe get it itself, because hipe:c/{1,2}
+ %% expects the given filename to actually exist on disk: it does not
+ %% work with an EZ archive (rabbit_common is one).
+ %%
+ %% Then we use the mode advanced hipe:compile/4 API because the
+ %% simpler hipe:c/3 is not exported (as of Erlang 18.1.4). This
+ %% advanced API does not load automatically the code, except if the
+ %% 'load' option is set.
PidMRefs = [spawn_monitor(fun () -> [begin
- {ok, M} = hipe:c(M, [o3]),
+ {M, Beam, _} =
+ code:get_object_code(M),
+ {ok, _} =
+ hipe:compile(M, [], Beam,
+ [o3, load]),
io:format("#")
end || M <- Ms]
end) ||