[m-rev.] diff: treat clang as a separate C compiler type
Julien Fischer
juliensf at csse.unimelb.edu.au
Mon Jul 11 17:23:33 AEST 2011
Branches: main, 11.07
Recognise clang as a separate C compiler type.
(We don't use this yet; that requires a separate change to the
configure script and elsewhere.)
compiler/globals.m:
Add clang as a separate C compiler type.
Add code for determining the clang version number.
compiler/compile_target_code.m:
Conform to the above change.
Julien.
Index: compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.170
diff -u -r1.170 compile_target_code.m
--- compile_target_code.m 23 May 2011 05:08:01 -0000 1.170
+++ compile_target_code.m 11 Jul 2011 07:21:51 -0000
@@ -707,7 +707,8 @@
[i(BytesPerWord)])
;
% XXX Check whether we need to do anything for these C compilers?
- ( C_CompilerType = cc_lcc
+ ( C_CompilerType = cc_clang(_)
+ ; C_CompilerType = cc_lcc
; C_CompilerType = cc_cl
),
C_FnAlignOpt = ""
Index: globals.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/globals.m,v
retrieving revision 1.101
diff -u -r1.101 globals.m
--- globals.m 23 May 2011 05:08:02 -0000 1.101
+++ globals.m 11 Jul 2011 07:21:51 -0000
@@ -141,10 +141,14 @@
% The patch level, if known.
% This is only available since gcc 3.0.
)
+ ; cc_clang(maybe(clang_version))
; cc_lcc
; cc_cl
; cc_unknown.
+:- type clang_version
+ ---> clang_version(int, int, int).
+
% The strategy for determining the reuse possibilities, i.e., either
% reuse is only allowed between terms that have exactly the same cons_id,
% or reuse is also allowed between terms that have different cons_id, yet
@@ -386,6 +390,7 @@
is semidet.
convert_c_compiler_type_simple("gcc", cc_gcc(no, no, no)).
+convert_c_compiler_type_simple("clang", cc_clang(no)).
convert_c_compiler_type_simple("lcc", cc_lcc).
convert_c_compiler_type_simple("cl", cc_cl).
convert_c_compiler_type_simple("unknown", cc_unknown).
@@ -398,7 +403,9 @@
CC_Str),
( Tokens = ["gcc", Major, Minor, Patch] ->
convert_gcc_version(Major, Minor, Patch, C_CompilerType)
- ;
+ ; Tokens = ["clang", Major, Minor, Patch] ->
+ convert_clang_version(Major, Minor, Patch, C_CompilerType)
+ ;
false
).
@@ -459,6 +466,28 @@
false
).
+ % Create the value of C compiler type when we have (some) version
+ % information for clang available.
+ % We only accept version information that has the following form:
+ %
+ % <major>_<minor>_<patch>
+ %
+:- pred convert_clang_version(string::in, string::in, string::in,
+ c_compiler_type::out) is semidet.
+
+convert_clang_version(MajorStr, MinorStr, PatchStr, C_CompilerType) :-
+ ( if
+ string.to_int(MajorStr, Major),
+ string.to_int(MinorStr, Minor),
+ string.to_int(PatchStr, Patch),
+ Major >= 0, Minor >= 0, Patch >= 0
+ then
+ ClangVersion = clang_version(Major, Minor, Patch),
+ C_CompilerType = cc_clang(yes(ClangVersion))
+ else
+ false
+ ).
+
convert_env_type("posix", env_type_posix).
convert_env_type("cygwin", env_type_cygwin).
convert_env_type("msys", env_type_msys).
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list