Opened 5 weeks ago

Closed 5 weeks ago

Last modified 8 days ago

#14160 closed bug (fixed)

Haiku x86_64 built with GCC 7.3 KDLs on startup

Reported by: waddlesplash Owned by: Ingo Weinhold
Priority: normal Milestone: Unscheduled
Component: Build System Version: R1/Development
Keywords: Cc: korli, Alexander von Gluck
Blocked By: Blocking:
Has a Patch: no Platform: All



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 5 weeks ago.
should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd
gcc7.png (140.8 KB) - added by Alexander von Gluck 5 weeks ago.
Running tests... gcc7 builds seem ok so far.
gpe.png (27.4 KB) - added by korli 5 weeks ago.
KDL screenshot

Download all attachments as: .zip

Change History (13)

Changed 5 weeks ago by waddlesplash

Attachment: x86_64 added

should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd

comment:1 Changed 5 weeks ago by waddlesplash

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,)


comment:2 Changed 5 weeks ago by waddlesplash

Actually looking at it might be the lifetime-dse one, based on and other comments about C++ code.

comment:3 Changed 5 weeks ago by waddlesplash

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

Last edited 5 weeks ago by waddlesplash (previous) (diff)

comment:4 Changed 5 weeks ago by waddlesplash

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

comment:5 Changed 5 weeks ago by waddlesplash

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 :
+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 Changed 5 weeks ago by waddlesplash

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
	# 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 Changed 5 weeks ago by waddlesplash

Added in hrev51968.

comment:8 Changed 5 weeks ago by korli

Please attach kdl screenshot to the bug tracker.

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

Changed 5 weeks ago by Alexander von Gluck

Attachment: gcc7.png added

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

Changed 5 weeks ago by korli

Attachment: gpe.png added

KDL screenshot

comment:9 Changed 5 weeks ago by waddlesplash

Resolution: fixed
Status: newclosed

Fixed (for now at least) by that commit.

comment:10 Changed 8 days ago by waddlesplash

Actual fix pushed in hrev52020.

Note: See TracTickets for help on using tickets.