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
+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