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.
This commit is contained in:
Alex Smith
2012-08-16 13:57:04 +01:00
parent 294818c5fd
commit c864ba1a2d
10 changed files with 44 additions and 11 deletions
+4
View File
@@ -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++ = ;
+2 -2
View File
@@ -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.
+19 -2
View File
@@ -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
Vendored
+12
View File
@@ -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} ;
@@ -16,7 +16,7 @@ HAIKU_BIND_FS_SOURCES =
KernelAddon bindfs
:
$(HAIKU_BIND_FS_SOURCES)
: $(HAIKU_STATIC_LIBSUPC++)
: $(HAIKU_KERNEL_LIBSUPC++)
;
@@ -89,7 +89,7 @@ KernelAddon packagefs
$(HAIKU_PACKAGE_FS_PACKAGE_READER_SOURCES)
$(libSharedSources)
: $(HAIKU_STATIC_LIBSUPC++) libz.a
: $(HAIKU_KERNEL_LIBSUPC++) libz.a
;
@@ -45,5 +45,5 @@ KernelAddon ramfs
SymLink.cpp
Volume.cpp
: $(HAIKU_LIBSUPC++)
: $(HAIKU_KERNEL_LIBSUPC++)
;
@@ -28,5 +28,5 @@ KernelAddon reiserfs
VNode.cpp
Volume.cpp
: $(HAIKU_STATIC_LIBSUPC++)
: $(HAIKU_KERNEL_LIBSUPC++)
;
@@ -41,5 +41,5 @@ KernelAddon userlandfs
UserlandFS.cpp
Volume.cpp
: $(HAIKU_STATIC_LIBSUPC++)
: $(HAIKU_KERNEL_LIBSUPC++)
;
+2 -2
View File
@@ -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