aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/main/hipe.erl
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-04-01 14:51:25 +0200
committerSverker Eriksson <[email protected]>2014-04-01 14:51:25 +0200
commit95432b67aed0d1f7dd7c2737efc0f80b610b3f14 (patch)
tree1adda4a6fcf9b20b7097ebe8dfff25be82ce93f7 /lib/hipe/main/hipe.erl
parent6a5e712203407e846905776d579f641ea39a38cf (diff)
parentf03a23984ddaf9edab26d7b7b6cf97af876e36c8 (diff)
downloadotp-95432b67aed0d1f7dd7c2737efc0f80b610b3f14.tar.gz
otp-95432b67aed0d1f7dd7c2737efc0f80b610b3f14.tar.bz2
otp-95432b67aed0d1f7dd7c2737efc0f80b610b3f14.zip
Merge branch 'yiannist/erllvm-fixes'
* yiannist/erllvm-fixes: Fix frame size adjustment of stack descriptors Fix counting of arguments of closures Check for required LLVM version or issue error
Diffstat (limited to 'lib/hipe/main/hipe.erl')
-rw-r--r--lib/hipe/main/hipe.erl32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/hipe/main/hipe.erl b/lib/hipe/main/hipe.erl
index d47eced6d8..539ce883c0 100644
--- a/lib/hipe/main/hipe.erl
+++ b/lib/hipe/main/hipe.erl
@@ -200,6 +200,7 @@
compile_core/4,
file/1,
file/2,
+ llvm_support_available/0,
load/1,
help/0,
help_hiper/0,
@@ -648,7 +649,18 @@ run_compiler_1(DisasmFun, IcodeFun, Options) ->
%% The full option expansion is not done
%% until the DisasmFun returns.
{Code, CompOpts} = DisasmFun(Options),
- Opts = expand_options(Options ++ CompOpts),
+ Opts0 = expand_options(Options ++ CompOpts),
+ Opts =
+ case proplists:get_bool(to_llvm, Opts0) andalso
+ not llvm_support_available() of
+ true ->
+ ?error_msg("No LLVM version 3.4 or greater "
+ "found in $PATH; aborting "
+ "native code compilation.\n", []),
+ ?EXIT(cant_find_required_llvm_version);
+ false ->
+ Opts0
+ end,
check_options(Opts),
?when_option(verbose, Options,
?debug_msg("Options: ~p.\n",[Opts])),
@@ -1537,4 +1549,22 @@ check_options(Opts) ->
ok
end.
+-spec llvm_support_available() -> boolean().
+
+llvm_support_available() ->
+ get_llvm_version() >= 3.4.
+
+get_llvm_version() ->
+ OptStr = os:cmd("opt -version"),
+ SubStr = "LLVM version ", N = length(SubStr),
+ case string:str(OptStr, SubStr) of
+ 0 -> % No opt available
+ 0.0;
+ S ->
+ case string:to_float(string:sub_string(OptStr, S + N)) of
+ {error, _} -> 0.0; %XXX: Assumes no revision numbers in versioning
+ {Float, _} -> Float
+ end
+ end.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%