added 1 changeset to branch 'refs/remotes/xyzzy-github/x86_64' old head: 294818c5fdcfba4246c738f97bbe30bcf43fb9d2 new head: c864ba1a2d8525aeabd6199c01675f70f5abd7bd ---------------------------------------------------------------------------- c864ba1: Build a separate libsupc++ for the kernel with correct flags. Kernel mode code on x86_64 needs to be built with -mno-red-zone as interrupts would corrupt the red zone if it were in use. However, the kernel is linked with libsupc++, which was not compiled with -mno-red-zone. If an interrupt occurred in libsupc++ code the red zone would get corrupted. This was causing random panics, particularly under heavy system load. Therefore, on x86_64 a separate build of libsupc++ with -mno-red-zone is now done for the kernel to use. Note: this commit will require a rerun of configure and rebuild of cross tools. [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Commit: c864ba1a2d8525aeabd6199c01675f70f5abd7bd Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Thu Aug 16 12:47:49 2012 UTC ---------------------------------------------------------------------------- 10 files changed, 44 insertions(+), 11 deletions(-) build/jam/BuildSetup | 4 +++ build/jam/KernelRules | 4 +-- build/scripts/build_cross_tools_gcc4 | 21 ++++++++++++++-- configure | 12 +++++++++ src/add-ons/kernel/file_systems/bindfs/Jamfile | 2 +- src/add-ons/kernel/file_systems/packagefs/Jamfile | 2 +- src/add-ons/kernel/file_systems/ramfs/Jamfile | 2 +- src/add-ons/kernel/file_systems/reiserfs/Jamfile | 2 +- .../file_systems/userlandfs/kernel_add_on/Jamfile | 2 +- src/system/kernel/Jamfile | 4 +-- ---------------------------------------------------------------------------- diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index 53c6118..8ca0b1a 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -1035,6 +1035,8 @@ if $(TARGET_PLATFORM) = haiku { TARGET_GCC_LIBGCC = $(HAIKU_GCC_LIBGCC) ; TARGET_GCC_LIBGCC_OBJECTS = $(HAIKU_GCC_LIBGCC_OBJECTS) ; + TARGET_KERNEL_LIBGCC = $(HAIKU_KERNEL_LIBGCC) ; + TARGET_KERNEL_LIBSUPC++ = $(HAIKU_KERNEL_LIBSUPC++) ; TARGET_BOOT_LIBGCC = $(HAIKU_BOOT_LIBGCC) ; TARGET_BOOT_LIBSUPC++ = $(HAIKU_BOOT_LIBSUPC++) ; @@ -1054,6 +1056,8 @@ if $(TARGET_PLATFORM) = haiku { TARGET_GCC_LIBGCC = ; TARGET_GCC_LIBGCC_OBJECTS = ; + TARGET_KERNEL_LIBGCC = ; + TARGET_KERNEL_LIBSUPC++ = ; TARGET_BOOT_LIBGCC = ; TARGET_BOOT_LIBSUPC++ = ; diff --git a/build/jam/KernelRules b/build/jam/KernelRules index 091e100..0ea34e8 100644 --- a/build/jam/KernelRules +++ b/build/jam/KernelRules @@ -48,9 +48,9 @@ rule KernelLd # libsupc++ is opt-out. local libs ; if ! [ on $(1) return HAIKU_NO_LIBSUPC++ ] { - libs += $(TARGET_STATIC_LIBSUPC++) ; + libs += $(TARGET_KERNEL_LIBSUPC++) ; } - LINKLIBS on $(1) = $(libs) $(TARGET_GCC_LIBGCC) ; + LINKLIBS on $(1) = $(libs) $(TARGET_KERNEL_LIBGCC) ; # TODO: Do we really want to invoke SetupKernel here? The objects should # have been compiled with KernelObjects anyway, so we're doing that twice. diff --git a/build/scripts/build_cross_tools_gcc4 b/build/scripts/build_cross_tools_gcc4 index d8960f3..9397c7a 100755 --- a/build/scripts/build_cross_tools_gcc4 +++ b/build/scripts/build_cross_tools_gcc4 @@ -33,6 +33,7 @@ x86_64-*) # failure binutilsConfigureArgs="" gccConfigureArgs="" + kernelSupcxxFlags="-mno-red-zone" ;; m68k-*) binutilsConfigureArgs="--enable-multilib" @@ -45,6 +46,7 @@ arm-*) *) binutilsConfigureArgs="--disable-multilib" gccConfigureArgs="--disable-multilib" + kernelSupcxxFlags= ;; esac @@ -101,13 +103,14 @@ installDir=$haikuOutputDir/cross-tools objDir=$haikuOutputDir/cross-tools-build binutilsObjDir=$objDir/binutils gccObjDir=$objDir/gcc +stdcxxObjDir=$objDir/stdcxx tmpIncludeDir=$objDir/sysincludes tmpLibDir=$objDir/syslibs rm -rf $installDir $objDir -mkdir -p $installDir $objDir $binutilsObjDir $gccObjDir $tmpIncludeDir \ - $tmpLibDir || exit 1 +mkdir -p $installDir $objDir $binutilsObjDir $gccObjDir $stdcxxObjDir \ + $tmpIncludeDir $tmpLibDir || exit 1 mkdir -p $installDir/lib/gcc/$haikuMachine/$gccVersion @@ -163,6 +166,20 @@ $MAKE $additionalMakeArgs install || { exit 1 } +# build libsupc++ for the kernel if the target arch requires it +if [ -n "$kernelSupcxxFlags" ]; then + cd $stdcxxObjDir + CFLAGS="-O2 $kernelSupcxxFlags" CXXFLAGS="-O2 $kernelSupcxxFlags" \ + $gccSourceDir/libstdc++-v3/configure --prefix=$installDir \ + --target=$haikuMachine --host=$haikuMachine --disable-shared \ + --disable-multilib || exit 1 + $MAKE $additionalMakeArgs -C libsupc++ || { + echo "Error: Building kernel libsupc++ failed." >&2 + exit 1 + } + cp libsupc++/.libs/libsupc++.a $installDir/$haikuMachine/lib/libsupc++-kernel.a +fi + # cleanup # remove the system headers from the installation dir diff --git a/configure b/configure index b11cf98..571f3a0 100755 --- a/configure +++ b/configure @@ -244,9 +244,19 @@ standard_gcc_settings() esac if [ "$targetArch" = "x86_64" ]; then + # Kernel doesn't need libgcc, and has a special version of libsupc++ + # built with the correct flags. Note: Should libgcc ever be needed for + # the x86_64 kernel, a separate build of it will be needed with + # -mno-red-zone, like for libsupc++. + HAIKU_KERNEL_LIBGCC= + HAIKU_KERNEL_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++-kernel.a` + + # Boot loader is 32-bit, need the 32-bit libs. HAIKU_BOOT_LIBGCC=`$HAIKU_CC -m32 -print-libgcc-file-name` HAIKU_BOOT_LIBSUPCXX=`$HAIKU_CC -m32 -print-file-name=libsupc++.a` else + HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC + HAIKU_KERNEL_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX HAIKU_BOOT_LIBGCC=$HAIKU_GCC_LIBGCC HAIKU_BOOT_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX fi @@ -570,6 +580,8 @@ HAIKU_STATIC_LIBSUPC++ ?= ${HAIKU_STATIC_LIBSUPCXX} ; HAIKU_SHARED_LIBSUPC++ ?= ${HAIKU_SHARED_LIBSUPCXX} ; HAIKU_C++_HEADERS_DIR ?= ${HAIKU_CXX_HEADERS_DIR} ; +HAIKU_KERNEL_LIBGCC ?= ${HAIKU_KERNEL_LIBGCC} ; +HAIKU_KERNEL_LIBSUPC++ ?= ${HAIKU_KERNEL_LIBSUPCXX} ; HAIKU_BOOT_LIBGCC ?= ${HAIKU_BOOT_LIBGCC} ; HAIKU_BOOT_LIBSUPC++ ?= ${HAIKU_BOOT_LIBSUPCXX} ; diff --git a/src/add-ons/kernel/file_systems/bindfs/Jamfile b/src/add-ons/kernel/file_systems/bindfs/Jamfile index dd5d190..4e6892d 100644 --- a/src/add-ons/kernel/file_systems/bindfs/Jamfile +++ b/src/add-ons/kernel/file_systems/bindfs/Jamfile @@ -16,7 +16,7 @@ HAIKU_BIND_FS_SOURCES = KernelAddon bindfs : $(HAIKU_BIND_FS_SOURCES) - : $(HAIKU_STATIC_LIBSUPC++) + : $(HAIKU_KERNEL_LIBSUPC++) ; diff --git a/src/add-ons/kernel/file_systems/packagefs/Jamfile b/src/add-ons/kernel/file_systems/packagefs/Jamfile index d0576a0..d3df799 100644 --- a/src/add-ons/kernel/file_systems/packagefs/Jamfile +++ b/src/add-ons/kernel/file_systems/packagefs/Jamfile @@ -89,7 +89,7 @@ KernelAddon packagefs $(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES) $(libSharedSources) - : $(HAIKU_STATIC_LIBSUPC++) libz.a + : $(HAIKU_KERNEL_LIBSUPC++) libz.a ; diff --git a/src/add-ons/kernel/file_systems/ramfs/Jamfile b/src/add-ons/kernel/file_systems/ramfs/Jamfile index 9dc1ba8..5e04563 100644 --- a/src/add-ons/kernel/file_systems/ramfs/Jamfile +++ b/src/add-ons/kernel/file_systems/ramfs/Jamfile @@ -45,5 +45,5 @@ KernelAddon ramfs SymLink.cpp Volume.cpp - : $(HAIKU_LIBSUPC++) + : $(HAIKU_KERNEL_LIBSUPC++) ; diff --git a/src/add-ons/kernel/file_systems/reiserfs/Jamfile b/src/add-ons/kernel/file_systems/reiserfs/Jamfile index 571c2a1..b28d32f 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/Jamfile +++ b/src/add-ons/kernel/file_systems/reiserfs/Jamfile @@ -28,5 +28,5 @@ KernelAddon reiserfs VNode.cpp Volume.cpp - : $(HAIKU_STATIC_LIBSUPC++) + : $(HAIKU_KERNEL_LIBSUPC++) ; diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Jamfile b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Jamfile index 153fd26..7c842e7 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Jamfile +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Jamfile @@ -41,5 +41,5 @@ KernelAddon userlandfs UserlandFS.cpp Volume.cpp - : $(HAIKU_STATIC_LIBSUPC++) + : $(HAIKU_KERNEL_LIBSUPC++) ; diff --git a/src/system/kernel/Jamfile b/src/system/kernel/Jamfile index 0937fbb..568a113 100644 --- a/src/system/kernel/Jamfile +++ b/src/system/kernel/Jamfile @@ -126,7 +126,7 @@ KernelLd kernel_$(TARGET_ARCH) : kernel_lib_posix_arch_$(TARGET_ARCH).o kernel_misc.o - $(HAIKU_STATIC_LIBSUPC++) + $(HAIKU_KERNEL_LIBSUPC++) : $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/kernel.ld : -Bdynamic -export-dynamic -dynamic-linker /foo/bar @@ -168,7 +168,7 @@ if $(HAIKU_ARCH) = x86_64 { kernel_lib_posix_arch_$(TARGET_ARCH).o kernel_misc.o - $(HAIKU_STATIC_LIBSUPC++) + $(HAIKU_KERNEL_LIBSUPC++) : $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/kernel.ld : -Bdynamic -shared -export-dynamic -dynamic-linker /foo/bar