Linux kernels above 4.3 don't boot any longer when compiled with gcc-4.9 or gcc-5. After some analysis, it seems gcc miscompiles the function blk_bio_segment_split() in block/blk-merge.c. Compiling this function with -O0 or -O1 does produce a functional Linux kernel, but when compiled with -O2 the kernel crashes during SCSI detection. I was able to extract the function from the kernel source and attached is a preprocessed file for easier analysis. It seems the variables bvprv and/or bvprvp get optimized out when compiled with -O2. This command is used to compile the file: hppa64-linux-gnu-gcc-4.9 -Wp,-MD,block/.blk-merge_part.o.d -nostdinc -isystem /usr/lib/gcc/hppa64-linux-gnu/4.9/include -I/build/linux/linux-4.4.4/arch/parisc/include -Iarch/parisc/include/generated/uapi -Iarch/parisc/include/generated -I/build/linux/linux-4.4.4/include -Iinclude -I/build/linux/linux-4.4.4/arch/parisc/include/uapi -Iarch/parisc/include/generated/uapi -I/build/linux/linux-4.4.4/include/uapi -Iinclude/generated/uapi -include /build/linux/linux-4.4.4/include/linux/kconfig.h -I/build/linux/linux-4.4.4/block -Iblock -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -pipe -mno-space-regs -mdisable-fpregs -ffunction-sections -march=2.0 -mschedule=8000 -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO -fno-cse-follow-jumps -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(blk_merge_part)" -D"KBUILD_MODNAME=KBUILD_STR(blk_merge_part)" -c -o block/.tmp_blk-merge_part.o /build/linux/linux-4.4.4/block/blk-merge_part.c
Created attachment 37939 [details] preprocessed source
Problem doesn't occur with Debian hppa64-linux-gnu-gcc-4.8.
Adding "-fno-ipa-sra" at -O2 results in same assembler code as -O1. "-fipa-sra" appears to break the iteration in this function. The problem is not with "bvprv and/or bvprvp".
Maybe related to <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932>.
Created attachment 37952 [details] blk-merge.c preprocessed source I've added the preprocessed for blk-merge.c. Although the wrong code appears to be in blk_bio_segment_split(), The -fno-ipa-sra option didn't fix the problem. Further, the problem appears with blk-merge.c compiled at both -O1 and -O2. Boot is successful when it is compiled at -O0. Try to find 4.9 regression. So far, range has been reduced to r220635 to r221480.
Hi Dave, On 13.03.2016 21:58, danglin at gcc dot gnu.org wrote: > Try to find 4.9 regression. So far, range has been reduced to r220635 to r221480. So, it compiles correctly with r220635 ? Is that then a gcc-4.8 or gcc-4.9 ? Helge
Unlikely related to 69532 -- the PA port is consistent WRT PROMOTE_MODE and friends IIRC. I'm leaving as P3 until we have this better analyzed though.
Culprit is constraints.md hunk in r220681 (4.9 branch). On hppa, it's not possible to reload all memory operands to a base register. So, we can't use define_memory_constraint for the Q and T constraints. Reverting fixes kernel build.
Author: danglin Date: Thu Mar 17 22:49:15 2016 New Revision: 234308 URL: https://gcc.gnu.org/viewcvs?rev=234308&root=gcc&view=rev Log: PR target/70188 * config/pa/constraints.md: Revert 2015-02-13 change. Use define_constraint for "Q" and "T" constraints. Modified: trunk/gcc/ChangeLog trunk/gcc/config/pa/constraints.md
Author: danglin Date: Thu Mar 17 22:55:38 2016 New Revision: 234310 URL: https://gcc.gnu.org/viewcvs?rev=234310&root=gcc&view=rev Log: PR target/70188 * config/pa/constraints.md: Revert 2015-02-13 change. Use define_constraint for "Q" and "T" constraints. Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/config/pa/constraints.md
Author: danglin Date: Thu Mar 17 22:57:19 2016 New Revision: 234311 URL: https://gcc.gnu.org/viewcvs?rev=234311&root=gcc&view=rev Log: PR target/70188 * config/pa/constraints.md: Revert 2015-02-13 change. Use define_constraint for "Q" and "T" constraints. Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/config/pa/constraints.md
64-bit Debian 4.4.4-2+b1 kernel booted successfully on c3750.