diff mbox

Properly do the LTO bytecode version check

Message ID alpine.LSU.2.11.1403041351110.11121@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener March 4, 2014, 12:51 p.m. UTC
On Tue, 4 Mar 2014, Richard Biener wrote:

> On Tue, 4 Mar 2014, Jan-Benedict Glaw wrote:
> 
> > On Tue, 2014-03-04 12:22:12 +0100, Richard Biener <rguenther@suse.de> wrote:
> > > 
> > > We're doing the LTO bytecode version check only for two section
> > > types at the moment - specifically _not_ for the first section
> > > we read.  Which causes us to crash instead of reporting a
> > > version mismatch ...
> > > 
> > > Fixed by doing the version check in the most appropriate place.
> > > 
> > > LTO bootstrapped on x86_64-unknown-linux-gnu, applied.
> > > 
> > > Richard.
> > > 
> > > 2014-03-04  Richard Biener  <rguenther@suse.de>
> > > 
> > > 	PR lto/60405
> > > 	* lto-streamer-in.c (lto_read_body): Remove LTO bytecode version
> > > 	check.
> > > 	(lto_input_toplevel_asms): Likewise.
> > > 	* lto-section-in.c (lto_get_section_data): Instead do it here
> > > 	for every section.
> > 
> > Breaks for the Build Robot with g++ (GCC) 4.9.0 20131121 like this:
> > 
> > g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../../gcc/gcc -I../../../gcc/gcc/. -I../../../gcc/gcc/../include -I../../../gcc/gcc/../libcpp/include -I/opt/cfarm/mpc/include  -I../../../gcc/gcc/../libdecnumber -I../../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../../gcc/gcc/../libbacktrace    -o lto-section-in.o -MT lto-section-in.o -MMD -MP -MF ./.deps/lto-section-in.TPo ../../../gcc/gcc/lto-section-in.c
> > ../../../gcc/gcc/lto-section-in.c: In function ‘const char* lto_get_section_data(lto_file_decl_data*, lto_section_type, const char*, size_t*)’:
> > ../../../gcc/gcc/lto-section-in.c:177:37: error: cast from type ‘const char*’ to type ‘lto_header*’ casts away qualifiers [-Werror=cast-qual]
> >    lto_check_version (((lto_header *)data)->major_version,
> >                                      ^
> > ../../../gcc/gcc/lto-section-in.c:178:23: error: cast from type ‘const char*’ to type ‘lto_header*’ casts away qualifiers [-Werror=cast-qual]
> >         ((lto_header *)data)->minor_version);
> >                        ^
> > cc1plus: all warnings being treated as errors
> > make[2]: *** [lto-section-in.o] Error 1
> > 
> > 
> > See eg.
> > http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=156703
> > --> http://toolchain.lug-owl.de/buildbot/deliver_artifact.php?mode=view&id=1152984
> > 
> > MfG, JBG
> 
> Bah - I committed the wrong version ...

Fixed like so (what was actually tested).

Richard.

2014-03-04  Richard Biener  <rguenther@suse.de>

	* lto-section-in.c (lto_get_section_data): Fix const cast.
diff mbox

Patch

Index: gcc/lto-section-in.c
===================================================================
--- gcc/lto-section-in.c	(revision 208314)
+++ gcc/lto-section-in.c	(working copy)
@@ -174,8 +174,8 @@  lto_get_section_data (struct lto_file_de
       data = buffer.data + header_length;
     }
 
-  lto_check_version (((lto_header *)data)->major_version,
-		     ((lto_header *)data)->minor_version);
+  lto_check_version (((const lto_header *)data)->major_version,
+		     ((const lto_header *)data)->minor_version);
   return data;
 }