Do a separate libgcc build for the kernel as well.

Turns out that libgcc is needed, for some reason building the kernel
with -O0 does not end up referencing libgcc but -O2 does. A separate
build of it is done with -mno-red-zone, same reason as for libsupc++.
Ended up being easy to rebuild with different CFLAGS: previously I'd
tried doing `CFLAGS="-mno-red-zone" make` in the libgcc dir which
didn't override, the correct way is `make CFLAGS="-mno-red-zone"`
This commit is contained in:
Alex Smith 2012-08-16 17:38:01 +01:00
parent 1eaa9e63cd
commit aaeadfcb02
2 changed files with 33 additions and 20 deletions

View File

@ -33,7 +33,7 @@ x86_64-*)
# failure
binutilsConfigureArgs=""
gccConfigureArgs=""
kernelSupcxxFlags="-mno-red-zone"
kernelCcFlags="-mno-red-zone"
;;
m68k-*)
binutilsConfigureArgs="--enable-multilib"
@ -46,7 +46,7 @@ arm-*)
*)
binutilsConfigureArgs="--disable-multilib"
gccConfigureArgs="--disable-multilib"
kernelSupcxxFlags=
kernelCcFlags=
;;
esac
@ -166,18 +166,26 @@ $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++ || {
# build libraries for the kernel if the target arch requires it
if [ -n "$kernelCcFlags" ]; then
$MAKE -C $haikuMachine/libgcc clean
$MAKE -C $haikuMachine/libgcc CFLAGS="-g -O2 $kernelCcFlags" || {
echo "Error: Building kernel libgcc failed." >&2
exit 1
}
cp $haikuMachine/libgcc/libgcc.a \
$installDir/$haikuMachine/lib/libgcc-kernel.a || exit 1
$MAKE -C $haikuMachine/libstdc++-v3/libsupc++ clean
$MAKE -C $haikuMachine/libstdc++-v3/libsupc++ CFLAGS="-g -O2 $kernelCcFlags" \
CXXFLAGS="-g -O2 $kernelCcFlags" || {
echo "Error: Building kernel libsupc++ failed." >&2
exit 1
}
cp libsupc++/.libs/libsupc++.a $installDir/$haikuMachine/lib/libsupc++-kernel.a
cp $haikuMachine/libstdc++-v3/libsupc++/.libs/libsupc++.a \
$installDir/$haikuMachine/lib/libsupc++-kernel.a || exit 1
fi
# cleanup

23
configure vendored
View File

@ -188,6 +188,17 @@ standard_gcc_settings()
HAIKU_STATIC_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++.a`
HAIKU_SHARED_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++.so`
# If the architecture has separate runtime libraries for the
# kernel, use them.
HAIKU_KERNEL_LIBGCC=`$HAIKU_CC -print-file-name=libgcc-kernel.a`
if [ $HAIKU_KERNEL_LIBGCC = libgcc-kernel.a ]; then
HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC
fi
HAIKU_KERNEL_LIBSUPCXX=`$HAIKU_CC -print-file-name=libsupc++-kernel.a`
if [ $HAIKU_KERNEL_LIBSUPCXX = libsupc++-kernel.a ]; then
HAIKU_KERNEL_LIBSUPCXX=$HAIKU_STATIC_LIBSUPCXX
fi
local headers
if [ -d $gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION ]; then
headers=$gccdir/../../../../$HAIKU_GCC_MACHINE/include/c++/$HAIKU_GCC_RAW_VERSION
@ -240,23 +251,17 @@ standard_gcc_settings()
echo "Please download it from www.haiku-os.org...";
exit 1;
fi
HAIKU_KERNEL_LIBGCC=$HAIKU_GCC_LIBGCC
HAIKU_KERNEL_LIBSUPCXX=
;;
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