Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14160 closed bug (fixed)

Haiku x86_64 built with GCC 7.3 KDLs on startup

Reported by: waddlesplash Owned by: bonefish
Priority: normal Milestone: Unscheduled
Component: Build System Version: R1/Development
Keywords: Cc: korli, kallisti5
Blocked By: Blocking:
Platform: All

Description

e.g. https://keybase.pub/kallisti5/Screenshots/gpe.png

kallisti5 says this happens on QEMU-KVM but not QEMU (without KVM.)

If you want to build your own GCC 7.3 Haiku:

Attachments (3)

x86_64 (4.5 KB ) - added by waddlesplash 6 years ago.
should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd
gcc7.png (140.8 KB ) - added by kallisti5 6 years ago.
Running tests... gcc7 builds seem ok so far.
gpe.png (27.4 KB ) - added by korli 6 years ago.
KDL screenshot

Download all attachments as: .zip

Change History (13)

by waddlesplash, 6 years ago

Attachment: x86_64 added

should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd

comment:1 by waddlesplash, 6 years ago

Linux kernel makefile has these:

# clang sets -fmerge-all-constants by default as optimization, but this
# is non-conforming behavior for C and in fact breaks the kernel, so we
# need to disable it here generally.
KBUILD_CFLAGS	+= $(call cc-option,-fno-merge-all-constants)

# for gcc -fno-merge-all-constants disables everything, but it is fine
# to have actual conforming behavior enabled.
KBUILD_CFLAGS	+= $(call cc-option,-fmerge-constants)

# Make sure -fstack-check isn't enabled (like gentoo apparently did)
KBUILD_CFLAGS  += $(call cc-option,-fno-stack-check,)

Related?

comment:2 by waddlesplash, 6 years ago

Actually looking at https://gcc.gnu.org/gcc-6/porting_to.html it might be the lifetime-dse one, based on https://bugzilla.redhat.com/show_bug.cgi?id=1316999 and other comments about C++ code.

comment:3 by waddlesplash, 6 years ago

The panic only occurs with {{-O2}}; with {{-O1}} there is no panic.

Version 0, edited 6 years ago by waddlesplash (next)

comment:4 by waddlesplash, 6 years ago

The culprit pass is rtl-stv1. If you disable it using -fdisable-rtl-stv1 on the whole kernel, the KDL goes away.

comment:5 by waddlesplash, 6 years ago

Minimum patch/workaround:

diff --git a/src/system/kernel/Jamfile b/src/system/kernel/Jamfile
index 7964320883..10f61bd224 100644
--- a/src/system/kernel/Jamfile
+++ b/src/system/kernel/Jamfile
@@ -75,6 +75,10 @@ KernelMergeObject kernel_core.o :
        : $(TARGET_KERNEL_PIC_CCFLAGS)
 ;
 
+if $(HAIKU_GCC_VERSION_$(HAIKU_ARCH)[1]) >= 7 {
+       ObjectC++Flags commpage.o signal.o thread.o : -fdisable-rtl-stv1 ;
+}
+
 # Generate the header defining macros for C++ structure sizes.
 local kernelC++StructSizesHeader = [ FGristFiles kernel_c++_struct_sizes.h ] ;
 TARGET_HDRS_$(TARGET_PACKAGING_ARCH) on $(kernelC++StructSizesHeader)

I've tried a few permutations of those by themselves, but as far as I can tell, you need all 3 in order for the KDL to be fixed.

comment:6 by waddlesplash, 6 years ago

And the proposed comment for that if:

	# With the rtl-stv1 pass on these files, the kernel panics towards the end
	# of the boot process with a "General Protection Exception", see
	# https://dev.haiku-os.org/ticket/14160. The pass itself vectorizes
	# a significant number of otherwise-scalar operations, which may be why
	# disabling it fixes the problem.
	#
	# At time of writing, GCC does not seem to have a way to disable
	# vectorization as a result of optimization without disabling
	# FPU usage altogether, which of course is not what we want and
	# breaks when using libstdc++'s headers anyway.

comment:7 by waddlesplash, 6 years ago

Added in hrev51968.

comment:8 by korli, 6 years ago

Please attach kdl screenshot to the bug tracker.

It would be nice to point to the documentation reference for the GCC flag.

by kallisti5, 6 years ago

Attachment: gcc7.png added

Running tests... gcc7 builds seem ok so far.

by korli, 6 years ago

Attachment: gpe.png added

KDL screenshot

comment:9 by waddlesplash, 6 years ago

Resolution: fixed
Status: newclosed

Fixed (for now at least) by that commit.

comment:10 by waddlesplash, 6 years ago

Actual fix pushed in hrev52020.

Note: See TracTickets for help on using tickets.