Bug 78251
Summary: | x86/kernel/apic/apic_numachip.c: build failure with recent version of gcc | ||
---|---|---|---|
Product: | Platform Specific/Hardware | Reporter: | David Binderman (dcb314) |
Component: | x86-64 | Assignee: | platform_x86_64 (platform_x86_64) |
Status: | RESOLVED CODE_FIX | ||
Severity: | normal | CC: | alan, andrey_utkin, daniel |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 3.16-rc1 | Subsystem: | |
Regression: | Yes | Bisected commit-id: |
Description
David Binderman
2014-06-18 08:06:18 UTC
Code still broken in 3.16-rc7 ;-| I did some digging. In file arch/x86/kernel/apic/apic_numachip.c, variable apic_numachip is put into two different sections, which new gcc doesn't seem to like. [dcb@zippy4 linux-3.16-rc7]$ fgrep apic_numachip !$ fgrep apic_numachip arch/x86/kernel/apic/apic_numachip.c.sav static const struct apic apic_numachip __read_mostly; return apic == &apic_numachip; static const struct apic apic_numachip __refconst = { apic_driver(apic_numachip); [dcb@zippy4 linux-3.16-rc7]$ Section _read_mostly doesn't seem to be the same as __refconst. I bodged it by changing the forward reference [dcb@zippy4 linux-3.16-rc7]$ diff -up arch/x86/kernel/apic/apic_numachip.c.sav arch/x86/kernel/apic/apic_numachip.c --- arch/x86/kernel/apic/apic_numachip.c.sav 2014-08-01 11:33:25.924513607 +0100 +++ arch/x86/kernel/apic/apic_numachip.c 2014-08-01 11:20:44.826145444 +0100 @@ -32,7 +32,8 @@ static int numachip_system __read_mostly; -static const struct apic apic_numachip __read_mostly; +/* static const struct apic apic_numachip __read_mostly; */ +static const struct apic apic_numachip __refconst; static unsigned int get_apic_id(unsigned long x) { I've taken the liberty of adding a couple of keen folks, who may be able to turn this suggestion into a proper patch. Emailed to the developer who added those lines in commit 44b111b519160e33fdc41eadb39af86a24707edf I can't reproduce the build failure with either GCC 4.8.2 or GCC 4.9.1, building either linux v3.16-rc7 or v3.17-rc4 with CONFIG_X86_NUMACHIP. CONFIG_DEBUG_SECTION_MISMATCH is set, so I was expecting a warning if I don't get build failure, but didn't see anything. Can attach your kernel .config please? Thanks! >I can't reproduce the build failure with either GCC 4.8.2 or GCC 4.9.1 Of course. You need an even later version of gcc, like development trunk, like I said originally. >Can attach your kernel .config please? Thanks! I could do that, but it won't help. My apologies for apparently being less than clear. Let's have another go at explaining the one line fix I am suggesting. Please have another look at the call to fgrep I originally gave. Here it is again: $ fgrep apic_numachip arch/x86/kernel/apic/apic_numachip.c.sav static const struct apic apic_numachip __read_mostly; return apic == &apic_numachip; static const struct apic apic_numachip __refconst = { apic_driver(apic_numachip); $ So const struct apic_numachip is declared to be in section __read_mostly, then it is referenced, then it is defined to be in section __refconst. Section __read_mostly isn't the same as __refconst, so the declaration and the definition don't match up. Newer compilers grumble, older ones don't. The fix is to make sure the section names *do* match up. The bodge I gave looks like a proper fix to me. Can you check if this has been fixed by Andi's patch in 3.18-rc2? commit 2dee5c43da3a981489a4f18972827139afcbee82 Author: Andi Kleen <andi@firstfloor.org> Date: Wed Sep 24 06:32:19 2014 +0200 x86: Fix section conflict for numachip A variable cannot be both __read_mostly and const. This is a meaningless combination. Just make it only const. This fixes the LTO build with numachip enabled. Signed-off-by: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1411533139-25708-1-git-send-email-andi@firstfloor.org Signed-off-by: Thomas Gleixner <tglx@linutronix.de> diff --git a/arch/x86/kernel/apic/apic_numachip.c b/arch/x86/kernel/apic/apic_numachip.c index ae91539..4128b5f 100644 --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -32,7 +32,7 @@ static int numachip_system __read_mostly; -static const struct apic apic_numachip __read_mostly; +static const struct apic apic_numachip; static unsigned int get_apic_id(unsigned long x) { >Can you check if this has been fixed by Andi's patch in 3.18-rc2?
3.18-rc2 builds fine, so Andi's patch looks good to me.
|