aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/main/hipe.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-05-04 15:15:31 +0200
committerMagnus Lång <[email protected]>2016-05-04 17:53:36 +0200
commit3d9b2a2b4ad7f24b7297fe2133ac65dafd297f87 (patch)
tree9c8b1f14b84f7ccfff1f36c54b7c521587dd7371 /lib/hipe/main/hipe.erl
parent6a1290f534164d1a5771dba37c23124652b9f7c9 (diff)
downloadotp-3d9b2a2b4ad7f24b7297fe2133ac65dafd297f87.tar.gz
otp-3d9b2a2b4ad7f24b7297fe2133ac65dafd297f87.tar.bz2
otp-3d9b2a2b4ad7f24b7297fe2133ac65dafd297f87.zip
hipe_llvm: Syntax compatibility with 3.7-3.8
Diffstat (limited to 'lib/hipe/main/hipe.erl')
-rw-r--r--lib/hipe/main/hipe.erl24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/hipe/main/hipe.erl b/lib/hipe/main/hipe.erl
index 0e32da1d36..01b7f34b3c 100644
--- a/lib/hipe/main/hipe.erl
+++ b/lib/hipe/main/hipe.erl
@@ -200,8 +200,9 @@
compile/4,
compile_core/4,
file/1,
- file/2,
- llvm_support_available/0,
+ file/2,
+ get_llvm_version/0,
+ llvm_support_available/0,
load/1,
help/0,
help_hiper/0,
@@ -1538,18 +1539,27 @@ check_options(Opts) ->
-spec llvm_support_available() -> boolean().
llvm_support_available() ->
- get_llvm_version() >= 3.4.
+ get_llvm_version() >= {3,4}.
+-type llvm_version() :: {Major :: integer(), Minor :: integer()}.
+
+-spec get_llvm_version() -> llvm_version() | {0, 0}.
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;
+ {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
+ case string:tokens(string:sub_string(OptStr, S + N), ".") of
+ [MajorS, MinorS | _] ->
+ case {string:to_integer(MajorS), string:to_integer(MinorS)} of
+ {{Major, ""}, {Minor, _}}
+ when is_integer(Major), is_integer(Minor) ->
+ {Major, Minor};
+ _ -> {0, 0}
+ end;
+ _ -> {0, 0} %XXX: Assumes no revision numbers in versioning
end
end.