[m-rev.] for review: filter gcc output

Peter Wang novalazy at gmail.com
Fri Jul 9 16:52:32 AEST 2010


On 2010-07-09, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> 
> On Fri, 9 Jul 2010, Peter Wang wrote:
> 
> >
> >scripts/mgnuc.in:
> >       Filter gcc output with mfiltercc, but only if mfiltercc can be found
> >       on the $PATH.  The bootstrap compiler may not have mfiltercc.
> 
> You should also filter based on whether asm labels are being used or
> not, i.e. we definitely don't need the filtering in, for example, the
> hlc grades

That is a better idea.

> >@@ -917,6 +918,23 @@ gather_c_compiler_flags(Globals, PIC, AllCFlags) :-
> >        CFLAGS, " ",
> >        OverrideOpts], AllCFlags).
> >
> >+:- pred get_maybe_filtercc_command(globals::in, maybe(string)::out) is det.
> >+
> >+get_maybe_filtercc_command(Globals, MaybeFilterCmd) :-
> >+    % Only gcc 4.x compiler output needs filtering at this time, but
> >+    % Mercury.config.bootstrap doesn't specify the version so we filter output
> >+    % from all versions of gcc.
> 
> In that case, the C compiler type will just be cc_gcc(no, no, no).

Mercury.config (non-.bootstrap) may specify the gcc version.

> >+int
> >+main(void)
> 
> s/void/int argc, char **argv/ since the former may be rejected by
> particularly picky compilers (since it's not actually C).

Broken, rather: http://c-faq.com/ansi/maindecl.html

Committing with these changes.

diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m
index c63227b..62ce638 100644
--- a/compiler/compile_target_code.m
+++ b/compiler/compile_target_code.m
@@ -921,12 +921,11 @@ gather_c_compiler_flags(Globals, PIC, AllCFlags) :-
 :- pred get_maybe_filtercc_command(globals::in, maybe(string)::out) is det.
 
 get_maybe_filtercc_command(Globals, MaybeFilterCmd) :-
-    % Only gcc 4.x compiler output needs filtering at this time, but
-    % Mercury.config.bootstrap doesn't specify the version so we filter output
-    % from all versions of gcc.
-    get_c_compiler_type(Globals, C_CompilerType),
+    % At this time we only need to filter the compiler output when using
+    % assembler labels with gcc 4.x.  Mercury.config.bootstrap doesn't specify
+    % the gcc version so we don't check for it.
     (
-        C_CompilerType = cc_gcc(_, _, _),
+        globals.lookup_bool_option(Globals, asm_labels, yes),
         globals.lookup_string_option(Globals, filtercc_command, FilterCmd),
         FilterCmd \= ""
     ->
diff --git a/scripts/mgnuc.in b/scripts/mgnuc.in
index ae206d4..9616e11 100644
--- a/scripts/mgnuc.in
+++ b/scripts/mgnuc.in
@@ -639,7 +639,7 @@ else
 fi
 
 FILTERCC=""
-case $COMPILER in gcc)
+case $asm_labels in true)
     # Check if mfiltercc is available as we may be bootstrapping with
     # an older compiler which did not have it.
     if mfiltercc=`which mfiltercc`

--------------------------------------------------------------------------
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