Bug 51633 - Fix on 1.12 for unsupported -Wno option detection
Summary: Fix on 1.12 for unsupported -Wno option detection
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: general (show other bugs)
Version: 1.12.2
Hardware: Other All
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-01 16:01 UTC by Gilles Espinasse
Modified: 2012-10-21 16:35 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
git patch (1.87 KB, text/plain)
2012-07-01 16:01 UTC, Gilles Espinasse
Details

Description Gilles Espinasse 2012-07-01 16:01:36 UTC
Created attachment 63681 [details]
git patch

As gcc-4.4 and later accept every -Wno option, test for the option without no to check if the option is supported.

For unsupported option, gcc warn 'unrecognized command line option' only when another warning occure.
Comment 1 Uli Schlachter 2012-07-11 19:51:14 UTC
I might be missing something, but which problem exactly should this patch fix?

As I see it, the configure checks wants to see if the compiler refuses to run when giving this flag. If it accepts the flag, it shouldn't matter if the flag does something or not (as far as configure is concerned, of course we want it to do something when run with gcc).
At least the built won't break, so what?
Comment 2 Gilles Espinasse 2012-07-11 20:29:45 UTC
I agree that build don't break for this reason.

The issue is just a supplemental 'unrecognized command line option' warning for each other warning emitted by gcc during make stage. The patch avoid this supplemental warning by properly testing if gcc really support the option.
So with gcc-4.4, the patch divide by 2 the number of warning emitted during the build.

That would be more clear with the diff of build log warnings but I can't do that today.
With gcc-4.4, configure && make 2>log1
Then make clean, use the patch, autoreconf && ./configure && make 2>log2
Then diff -u log1 log2

If you have gcc-4.5 or gcc-4.6, you should have the same effect testing -Wno-unused-local-typedefs option (added in gcc-4.7) to configure.ac.
Comment 3 Gilles Espinasse 2012-07-12 06:41:48 UTC
here is the beginning of the diff between unfixed and fixed build error log files.
--- log1	2012-07-12 08:57:13.000000000 +0200
+++ log2	2012-07-12 08:49:43.000000000 +0200
@@ -5,8 +5,6 @@
 cairo-bentley-ottmann.c:1106: warning: called from here
 cairo-bentley-ottmann.c:1701: warning: 'ymin' may be used uninitialized in this function
 cairo-bentley-ottmann.c:1701: warning: 'ymax' may be used uninitialized in this function
-At top level:
-cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable"
 cairo-botor-scan-converter.c:2132: warning: '_cairo_botor_scan_converter_add_edge' defined but not used
 cairo-botor-scan-converter.c:2151: warning: '_cairo_botor_scan_converter_add_polygon' defined but not used
 cairo-botor-scan-converter.c: In function 'edges_compare_x_for_y':
@@ -17,8 +15,6 @@
 cairo-botor-scan-converter.c:1944: warning: called from here
 cairo-botor-scan-converter.c:963: warning: inlining failed in call to 'event_insert_if_intersect_below_current_y': call is unlikely and code size would grow
 cairo-botor-scan-converter.c:1949: warning: called from here
-At top level:
-cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable"
 cairo-image-compositor.c: In function 'span_renderer_init':
 cairo-image-compositor.c:138: warning: inlining failed in call to 'color_to_pixel': call is unlikely and code size would grow
 cairo-image-compositor.c:1832: warning: called from here
@@ -33,12 +29,8 @@
 cairo-image-compositor.c: In function '_blit_xrgb32_lerp_spans':
 cairo-image-compositor.c:1922: warning: inlining failed in call to 'lerp8x4': call is unlikely and code size would grow
 cairo-image-compositor.c:2207: warning: called from here
-At top level:
-cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable"
 cairo-mesh-pattern-rasterizer.c: In function 'draw_bezier_patch':
 cairo-mesh-pattern-rasterizer.c:731: warning: cannot optimize possibly infinite loops
-At top level:
-cc1: warning: unrecognized command line option "-Wno-unused-but-set-variable"
 cairo-path-stroke-polygon.c: In function 'add_caps':
 cairo-path-stroke-polygon.c:1022: warning: ignoring return value of '_cairo_polygon_add_contour', declared with attribute warn_unused_result
 cairo-path-stroke-polygon.c:1039: warning: ignoring return value of '_cairo_polygon_add_contour', declared with attribute warn_unused_result
@@ -51,19 +43,14 @@
 cairo-path-stroke-polygon.c:236: warning: 'distance_from_face' defined but not used
 cairo-path-stroke-polygon.c:252: warning: 'distance_along_face' defined but not used
 cairo-path-stroke-polygon.c:262: warning: 'compute_inner_joint' defined but not used
...

This is not dividing the warning count by 2 as there is to often more than one remaining warning per file.
Comment 4 Gilles Espinasse 2012-07-12 06:58:21 UTC
This build test was made from cairo-1.12.2 as I had not pixman git tree packaged.
Comment 5 Uli Schlachter 2012-07-12 15:12:19 UTC
Ah, ok, you even said so before. Sorry for being unable to read.

However, there are also -Wno-missing-field-initializers, -Wno-unused-parameter, -Wno-attributes and -Wno-long-long in the current build machinery. Should something be done about them, too, or can we just assume that there is no gcc which doesn't support those?

(Next I was wondering why these warnings need to be disabled at all, but it looks like -Wall includes -Wunused-but-set-variable. Bummer.)
Comment 6 Gilles Espinasse 2012-07-14 10:36:04 UTC
-Wno-missing-field-initializers, -Wno-unused-parameter,
-Wno-attributes and -Wno-long-long 
are supported by gcc-4.4
The way this test is made, it work for older gcc version than 4.4, so there is no issue.

If new option should be conditionally disabled, that option should be added in the NO_WARN variable.

I should say there is no much sense in the MAYBE_WARN vs NO_WARN variable names.
Changing 
MAYBE_WARN to WARN_BEFORE_4_4
NO_WARN to WARN_FROM_4_4
may make sense.
Comment 7 Gilles Espinasse 2012-10-09 07:39:06 UTC
ping
Comment 8 Chris Wilson 2012-10-21 16:35:35 UTC
commit d49b2284b505e93cd415af4da3cd2cc2d3d168d3
Author: Gilles Espinasse <g.esp@free.fr>
Date:   Sat Oct 20 20:22:51 2012 +0200

    configure: fix unrecognized -Wno option
    
    gcc-4.4 and later accept every -Wno option. So we can test for the
    option without no in the name to check if the option is supported.
    
    Each time a warning is emitted and without this fix, on gcc-4.4 that will
    add this warning:
       cc1: warning: unrecognized command line option "-Wno-unused-but-set-varia
    
    bugs.freedesktop.org #51633, rediffed after 1.12.4
    
    Of course this assumes that all compilers will behave like gcc, which is
    reasonably implicit in the set of warning flags.
    
    Signed-off-by: Gilles Espinasse <g.esp@free.fr>
    [ickle: slight modification to test both -W and -Wno variants to ideally
    preserve compatability with non-GCC compilers sharing GCC options!]


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.