[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-10-16 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #21 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
Author: trippels
Date: Fri Oct 17 05:10:07 2014
New Revision: 216361

URL: https://gcc.gnu.org/viewcvs?rev=216361root=gccview=rev
Log:
Fix pr61848, linux kernel miscompile

This patch cures the linux kernel boot failure when compiled using
trunk gcc.

At its heart, the problem is caused by merge_decls merging from the
old decl to the new decl, then copying back to the old decl and
discarding the new.  When Jan moved some fields to the symtab,
copying back to the old decl was lost for those fields.  Really,
it would be best if merge_decls was rewritten to merge everything to
the kept decl, but here I'm just doing that for fields accessed via
decl_with_vis.symtab_node.

2014-10-17  Alan Modra  amo...@gmail.com

gcc/c/
PR middle-end/61848
* c-decl.c (merge_decls): Don't merge section name or tls model
to newdecl symtab node, instead merge to olddecl.  Override
existing olddecl section name.  Set tls_model for all thread-local
vars, not just OMP thread-private ones.  Remove incorrect comment.
gcc/cp/
PR middle-end/61848
* decl.c (merge_decls): Don't merge section name, comdat group or
tls model to newdecl symtab node, instead merge to olddecl.
Override existing olddecl section name.  Set tls_model for all
thread-local vars, not just OMP thread-private ones.  Remove
incorrect comment.

2014-10-17  Markus Trippelsdorf  mar...@trippelsdorf.de

PR middle-end/61848
* g++.dg/torture/pr61848.C: New testcase.
* gcc.c-torture/compile/pr61848.c: New testcase.

Added:
trunk/gcc/testsuite/g++.dg/torture/pr61848.C
trunk/gcc/testsuite/gcc.c-torture/compile/pr61848.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c/c-decl.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl.c
trunk/gcc/testsuite/ChangeLog


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-10-16 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Markus Trippelsdorf trippels at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |trippels at gcc dot 
gnu.org

--- Comment #22 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
Finally fixed. Thanks.


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-10-15 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Alan Modra amodra at gmail dot com changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   Assignee|amodra at gcc dot gnu.org  |unassigned at gcc dot 
gnu.org


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-28 Thread andi-gcc at firstfloor dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #16 from Andi Kleen andi-gcc at firstfloor dot org ---
Can Alan's patch be submitted please?

I always need to apply it now before compiling a kernel.


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-28 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/ml/gcc-
   ||patches/2014-09/msg01146.ht
   ||ml
   Assignee|pinskia at gcc dot gnu.org |amodra at gcc dot 
gnu.org

--- Comment #17 from Andrew Pinski pinskia at gcc dot gnu.org ---
(In reply to Andi Kleen from comment #16)
 Can Alan's patch be submitted please?

It was https://gcc.gnu.org/ml/gcc-patches/2014-09/msg01146.html .


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-28 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Markus Trippelsdorf trippels at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords|patch   |
URL|https://gcc.gnu.org/ml/gcc- |
   |patches/2014-09/msg01146.ht |
   |ml  |
   Assignee|amodra at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org

--- Comment #18 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
(In reply to Andi Kleen from comment #16)
 Can Alan's patch be submitted please?
 
 I always need to apply it now before compiling a kernel.

See deadlocked discussion:
http://thread.gmane.org/gmane.comp.gcc.patches/321758/

Here's a testcase suitable for both C++ and C:

/* { dg-do compile } */
/* { dg-require-effective-target named_sections } */
/* { dg-final { scan-assembler mysection } } */
extern char foo;
char foo __attribute__ ((__section__(.mysection)));


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-28 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Markus Trippelsdorf trippels at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/ml/gcc-
   ||patches/2014-09/msg01146.ht
   ||ml
   Assignee|pinskia at gcc dot gnu.org |amodra at gcc dot 
gnu.org

--- Comment #19 from Markus Trippelsdorf trippels at gcc dot gnu.org ---
didn't mean to change the headers.


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-28 Thread andi-gcc at firstfloor dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #20 from Andi Kleen andi-gcc at firstfloor dot org ---
So the only problem was the missing test case, which you supplied?


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-26 Thread andi-gcc at firstfloor dot org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Andi Kleen andi-gcc at firstfloor dot org changed:

   What|Removed |Added

 CC||andi-gcc at firstfloor dot org

--- Comment #15 from Andi Kleen andi-gcc at firstfloor dot org ---
*** Bug 63382 has been marked as a duplicate of this bug. ***


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-23 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

 CC||mliska at suse dot cz

--- Comment #14 from Andrew Pinski pinskia at gcc dot gnu.org ---
*** Bug 63344 has been marked as a duplicate of this bug. ***


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-18 Thread sasha.levin at oracle dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Sasha Levin sasha.levin at oracle dot com changed:

   What|Removed |Added

 CC||sasha.levin at oracle dot com

--- Comment #13 from Sasha Levin sasha.levin at oracle dot com ---
*** Bug 63279 has been marked as a duplicate of this bug. ***


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-12 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Alan Modra amodra at gmail dot com changed:

   What|Removed |Added

 CC||amodra at gmail dot com

--- Comment #10 from Alan Modra amodra at gmail dot com ---
Created attachment 33480
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=33480action=edit
A different approach to fixing this bug

I was playing with this one today, before I found your bugzilla Andrew.  It has
been regression tested on x86_64, fixes the loss of section attributes, and
builds a 3.16 x86_64 defconfig kernel - haven't checked if it boots yet..

Adds a fix for C++ which has the same problem as C.  (The s/olddecl/newdecl/
lines are because if (TREE_CODE (newdecl) == FUNCTION_DECL) ... else switch
(TREE_CODE (olddecl)) looks horrible.  Cosmetic really since we exit the
function before this code if TREE_CODE (newdecl) != TREE_CODE (olddecl).)


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-12 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #11 from Alan Modra amodra at gmail dot com ---
It boots
Linux version 3.17.0-rc4-00222-gc73f6fd-dirty (anton@tul181p1) (gcc version
5.0.0 20140912 (experimental) (GCC) ) #23 SMP Fri Sep 12 21:19:06 UTC 2014


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-12 Thread amodra at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #12 from Alan Modra amodra at gmail dot com ---
extern char foo;
char foo __attribute__ ((__section__(.machine.desc)));
char foo __attribute__ ((__section__(.mymachine.desc)));

It looks like we should take out the DECL_SECTION_NAME (olddecl) == NULL
checks.
The above gives no diagnostic with older compilers, and results in section
.mymachine.desc being used.  trunk+patch results in section .machine.desc.


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-10 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jan.sm...@alcatel-lucent.co
   ||m

--- Comment #9 from Andrew Pinski pinskia at gcc dot gnu.org ---
*** Bug 63221 has been marked as a duplicate of this bug. ***


[Bug middle-end/61848] [5 Regression] a previous declaration causes the section attribute to be lost

2014-09-03 Thread ryabinin.a.a at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61848

--- Comment #8 from Andrey Ryabinin ryabinin.a.a at gmail dot com ---
Hi, may I ask what's the status of this?

Besides of section mismatches in linux kernel it also breaks kernel's modules.
Variable __this_module doesn't get into section .gnu.linkonce.this_module,
therefore module refuses to load.