The following fixes #pragma pack effect leaking to all types built from the middle-end (so possibly even vector types built by the vectorizer?). The PR in question is about gcov_info_type where layout is affected and inconsistency between that and the libgcov.a copy causes libgcov to crash.
As the way to communicate #pragma pack to stor-layout.c is already a hack I couldn't think of a better solution like that below. Bootstrap and regtest running on x86_64-unknown-linux-gnu. Ok? Thanks, Richard. 2015-07-08 Richard Biener <rguent...@suse.de> * stor-layout.h (reset_maximum_field_alignment): Declare. * stor-layout.c (reset_maximum_field_alignment): New function. * toplev.c: Include stor-layout.h. (compile_file): Reset maximum_field_alignment after parsing. Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c (revision 225534) +++ gcc/stor-layout.c (working copy) @@ -59,6 +59,12 @@ tree sizetype_tab[(int) stk_type_kind_la The value is measured in bits. */ unsigned int maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT; +void +reset_maximum_field_alignment (void) +{ + maximum_field_alignment = TARGET_DEFAULT_PACK_STRUCT * BITS_PER_UNIT; +} + /* Nonzero if all REFERENCE_TYPEs are internal and hence should be allocated in the address spaces' address_mode, not pointer_mode. Set only by internal_reference_types called only by a front end. */ Index: gcc/stor-layout.h =================================================================== --- gcc/stor-layout.h (revision 225534) +++ gcc/stor-layout.h (working copy) @@ -118,4 +118,7 @@ extern tree variable_size (tree); /* Vector types need to check target flags to determine type. */ extern machine_mode vector_type_mode (const_tree); +/* Reset maximum_field_alignment to its default. */ +extern void reset_maximum_field_alignment (void); + #endif // GCC_STOR_LAYOUT_H Index: gcc/toplev.c =================================================================== --- gcc/toplev.c (revision 225534) +++ gcc/toplev.c (working copy) @@ -90,6 +90,7 @@ along with GCC; see the file COPYING3. #include "optabs.h" #include "tree-chkp.h" #include "omp-low.h" +#include "stor-layout.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) #include "dbxout.h" @@ -553,6 +554,11 @@ compile_file (void) if (flag_syntax_only || flag_wpa) return; + + /* Reset maximum_field_alignment, it can be adjusted by #pragma pack + and this shouldn't influence any types built by the middle-end + from now on (like gcov_info_type). */ + reset_maximum_field_alignment (); ggc_protect_identifiers = false;