Bug 1140872

Summary: kernel compilation fails comparing on vta-toggle
Product: [Fedora] Fedora Reporter: Josh Stone <jistone>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fche, jakub, jistone, law
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-4.9.1-11.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-29 15:44:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
sources, objects, save-temps, and dump-final-insns none

Description Josh Stone 2014-09-11 22:05:27 UTC
Created attachment 936701 [details]
sources, objects, save-temps, and dump-final-insns

Description of problem:
I'm trying to verify whether the kernel's vta codegen issues have been fully fixed, e.g. gcc pr61904.  With GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle, almost everything builds ok, but br_netlink.o and tcp.o both report -fcompare-debug failures.

Version-Release number of selected component (if applicable):
gcc-4.9.1-7.fc22.x86_64

I'm building an upstream kernel tree at git v3.17-rc4-158-ge874a5fe3efa, borrowing the config from kernel-3.17.0-0.rc4.git2.1.fc22.x86_64.
(I doubt the exact kernel versions matter -- just citing what I've got.)

How reproducible:
100%

Steps to Reproduce:
1. export GCC_COMPARE_DEBUG=-fvar-tracking-assignments-toggle
2. git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
3. cd linux && git checkout e874a5fe3efa
4. cp /boot/config-3.17.0-0.rc4.git2.1.fc22.x86_64 .config && make oldconfig
2. make -k net/bridge/br_netlink.o net/ipv4/tcp.o

Actual results:
  CC [M]  net/bridge/br_netlink.o
gcc: error: net/bridge/br_netlink.c: -fcompare-debug failure
scripts/Makefile.build:257: recipe for target 'net/bridge/br_netlink.o' failed
make[1]: *** [net/bridge/br_netlink.o] Error 1
Makefile:1520: recipe for target 'net/bridge/br_netlink.o' failed
make: *** [net/bridge/br_netlink.o] Error 2
  CC      net/ipv4/tcp.o
gcc: error: net/ipv4/tcp.c: -fcompare-debug failure (length)
scripts/Makefile.build:257: recipe for target 'net/ipv4/tcp.o' failed
make[1]: *** [net/ipv4/tcp.o] Error 1
Makefile:1520: recipe for target 'net/ipv4/tcp.o' failed
make: *** [net/ipv4/tcp.o] Error 2

Expected results:
no errors

Additional info:
A simple GCC_COMPARE_DEBUG=-gtoggle is fine.  That's with VTA disabled per commit 2062afb4f804a.  If I force that Makefile line to instead enable VTA, -gtoggle is still fine.  If I remove that line, leaving VTA to its default, then -gtoggle fails the same way that vta-toggle does above.

The attachment contains temps and dumps of the two files in question.  Both object files are identical after strip -g, so I think there's no real codegen bug here.  The actual differences in dump-final-insns also look harmless to my eyes:

--- br_netlink.o.gkd    2014-09-11 13:43:57.843386808 -0700
+++ br_netlink-vta.o.gkd        2014-09-11 13:43:57.850386745 -0700
@@ -6114,7 +6114,7 @@
             (set (reg:DI 42 r13 [orig:83 D.49920 ] [83])
                 (const_int 0 [0]))
             (clobber (reg:CC 17 flags))
-        ]) net/bridge/br_netlink.c:271# {*movdi_xor}
+        ]) net/bridge/br_netlink.c:269# {*movdi_xor}
      (expr_list:REG_UNUSED (reg:CC 17 flags)
         (nil)))
 (code_label 303 0 0 12 303 "" [5 uses])
--- tcp.o.gkd   2014-09-11 13:43:57.859386666 -0700
+++ tcp-vta.o.gkd       2014-09-11 13:43:57.867386595 -0700
@@ -23384,7 +23384,7 @@
         (mem/j:SI (plus:DI (reg/v/f:DI 42 r13 [orig:361 sk ] [361])
                 (const_int 2004 [0x7d4])) [ MEM[(struct tcp_sock *)sk_77(D)].copied_seq+0 S4 A32])) net/ipv4/tcp.c:1862# {*movsi_internal}
      (nil))
-(insn# 0 0 39 (set (reg:CCZ 17 flags)
+(insn:TI# 0 0 39 (set (reg:CCZ 17 flags)
         (compare:CCZ (mem/j:SI (plus:DI (reg/v/f:DI 42 r13 [orig:361 sk ] [361])
                     (const_int 2000 [0x7d0])) [ MEM[(struct tcp_sock *)sk_77(D)].rcv_nxt+0 S4 A64])
             (reg:SI 0 ax [609]))) net/ipv4/tcp.c:1862# {*cmpsi_1}

... but I guess that may be enough to fail -fcompare-debug.

Comment 1 Jakub Jelinek 2014-09-15 13:44:04 UTC
gcc-4.9.1-7.fc2* didn't contain all the -fcompare-debug fixes.

Please try gcc-4.9.1-9.fc2{1,2} instead.

Comment 2 Josh Stone 2014-09-15 22:27:54 UTC
gcc-4.9.1-9.fc22.x86_64 still fails with the exact same gkd differences.
I can attach the new intermediate files if you like.

Comment 3 Jakub Jelinek 2014-09-16 17:20:56 UTC
So, what is the exact command line you are trying to compile br_netlink.i and/or tcp.i with that you get -fcompare-debug failure?
I'm not getting any errors on:
./xgcc -B ./ -S -fcompare-debug -fpreprocessed -m64 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -maccumulate-outgoing-args -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -mfentry -march=x86-64 -g -O2 -p -fno-strict-aliasing -fno-common -funit-at-a-time -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-overflow -fconserve-stack -fno-var-tracking-assignments --param allow-store-data-races=0 -frandom-seed=0xba8b6d6963f0b7a8 -fcompare-debug tcp.i

Comment 4 Jakub Jelinek 2014-09-16 17:23:24 UTC
And removing -fno-var-tracking-assignments doesn't change anything on that.

Comment 5 Josh Stone 2014-09-16 17:48:51 UTC
(FWIW, I'm using GCC_COMPARE_DEBUG, not a direct -fcompare-debug, but AIUI that's identical.)

Here's the full command for br_netlink from make V=1:

gcc -Wp,-MD,net/bridge/.br_netlink.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.1/include -I./arch/x86/include -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO  -DMODULE  -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(br_netlink)"  -D"KBUILD_MODNAME=KBUILD_STR(bridge)" -c -o net/bridge/br_netlink.o net/bridge/br_netlink.c

So taking out -I/-D/-fno-vta and running on .i:

gcc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -mfentry -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -c -o net/bridge/br_netlink.o br_netlink.i -fcompare-debug
gcc: error: br_netlink.i: -fcompare-debug failure

Taking out all -W still fails too:

gcc -fno-strict-aliasing -fno-common -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -pipe -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -mfentry -fno-strict-overflow -fconserve-stack -c -o net/bridge/br_netlink.o br_netlink.i -fcompare-debug
gcc: error: br_netlink.i: -fcompare-debug failure

Comment 6 Josh Stone 2014-09-16 18:02:23 UTC
Repeating for tcp.i, here's make V=1:

gcc -Wp,-MD,net/ipv4/.tcp.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.9.1/include -I./arch/x86/include -Iarch/x86/include/generated  -Iinclude -I./arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -g -pg -mfentry -DCC_USING_FENTRY -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO    -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(tcp)"  -D"KBUILD_MODNAME=KBUILD_STR(tcp)" -c -o net/ipv4/tcp.o net/ipv4/tcp.c

Removing -I/-D/-fno-vta and compiling .i:

gcc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -mfentry -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -c -o net/ipv4/tcp.o tcp.i -fcompare-debug
gcc: error: tcp.i: -fcompare-debug failure (length)

Dropping warnings too:

gcc -fno-strict-aliasing -fno-common -m64 -mno-mmx -mno-sse -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -pipe -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -pg -mfentry -fno-strict-overflow -fconserve-stack -c -o net/ipv4/tcp.o tcp.i -fcompare-debug
gcc: error: tcp.i: -fcompare-debug failure (length)

Comment 7 Jakub Jelinek 2014-09-16 18:03:45 UTC
Now reproduced, thanks, will reduce it and bisect.

Comment 8 Jakub Jelinek 2014-09-16 22:39:57 UTC
Reduced testcase for -O2 -fcompare-debug (not sure if it is the same bug or different though):
int a[10], *b, *d, c, f;
int fn2 (void);
void fn3 (void);
void fn4 (int);

static int
fn1 (int x)
{
  int e = a[0];
  if (e)
    return 1;
  if (b)
    switch (x)
      {
      case 1:
        if (d)
          e = fn2 ();
        else
          fn3 ();
        break;
      case 0:
        if (d)
          {
            fn3 ();
            if (c)
              fn4 (1);
          }
        else
          fn4 (0);
      }
  return e;
}

void
fn6 (void)
{
  f = fn1 (0);
}

Comment 9 Jakub Jelinek 2014-09-19 08:35:21 UTC
Please try http://koji.fedoraproject.org/scratch/jakub/task_7620345/ which has those two bugfixes backported.

Comment 10 Josh Stone 2014-09-19 21:51:56 UTC
Thanks, with gcc-4.9.1-9.fc22.1.x86_64 the build completes successfully.  I tried kernel commit e874a5fe3efa and just updated 598a0c7d0932, still using rawhide's x86_64 config as a reference.

Comment 11 Josh Stone 2014-09-19 22:36:51 UTC
FWIW, I just completed an allmodconfig build successfully too.

Comment 12 Fedora Update System 2014-10-01 14:39:17 UTC
gcc-4.9.1-11.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/gcc-4.9.1-11.fc21

Comment 13 Fedora Update System 2014-10-08 19:09:28 UTC
gcc-4.9.1-11.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.