Compare commits

..

No commits in common. "d1c82738260f65a7bbb19822c77d5c93785f38fd" and "62f6128ba1006c1f606c5973a21b30364326f864" have entirely different histories.

7 changed files with 38 additions and 141 deletions

View File

@ -28,7 +28,7 @@ set(LIBC_SOURCES
termios.cpp termios.cpp
time.cpp time.cpp
unistd.cpp unistd.cpp
math.cpp math.S
icxxabi.cpp icxxabi.cpp
../BAN/BAN/Assert.cpp ../BAN/BAN/Assert.cpp

View File

@ -1,33 +0,0 @@
.section .text
.global _start
_start:
# zero out stack frame
pushl $0
pushl $0
movl %esp, %ebp
# FIXME: handle stack alignment
ud2
# push argc, argv, environ for call to main
pushl %edx
pushl %esi
pushl %edi
# initialize libc
pushl %edx
call _init_libc
addl $4, %esp
# call global constructos
call _init
# call main, arguments are already on stack
call main
# cleanly exit the process
pushl %eax
call exit
.size _start, . - _start

View File

@ -1,16 +0,0 @@
/* i386 crti.s */
.section .init
.global _init
.type _init, @function
_init:
pushl %ebp
movl %esp, %ebp
/* gcc will nicely put the contents of crtbegin.o's .init section here. */
.section .fini
.global _fini
.type _fini, @function
_fini:
pushl %ebp
movl %esp, %ebp
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */

View File

@ -1,10 +0,0 @@
/* i386 crtn.s */
.section .init
/* gcc will nicely put the contents of crtend.o's .init section here. */
popl %ebp
ret
.section .fini
/* gcc will nicely put the contents of crtend.o's .fini section here. */
popl %ebp
ret

26
libc/math.S Normal file
View File

@ -0,0 +1,26 @@
.global floorl;
floorl:
fldt 8(%rsp)
fnstenv -28(%rsp) /* store fpu environment */
/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
than the 16 bit operations. */
movl $0x400,%edx /* round towards -oo */
orl -28(%rsp),%edx
andl $0xf7ff,%edx
movl %edx,-32(%rsp)
fldcw -32(%rsp) /* load modified control word */
frndint /* round */
/* Preserve "invalid" exceptions from sNaN input. */
fnstsw
andl $0x1, %eax
orl %eax, -24(%rsp)
fldenv -28(%rsp) /* restore original environment */
ret

View File

@ -1,63 +0,0 @@
#include <math.h>
#define BUILTINS1(func) \
float func##f(float a) { return __builtin_##func##f(a); } \
double func(double a) { return __builtin_##func(a); } \
long double func##l(long double a) { return __builtin_##func##l(a); }
#define BUILTINS2(func) \
float func##f(float a, float b) { return __builtin_##func##f(a, b); } \
double func(double a, double b) { return __builtin_##func(a, b); } \
long double func##l(long double a, long double b) { return __builtin_##func##l(a, b); } \
__BEGIN_DECLS
BUILTINS1(acos)
BUILTINS1(acosh)
BUILTINS1(asin)
BUILTINS1(asinh)
BUILTINS1(atan)
BUILTINS2(atan2)
BUILTINS1(atanh)
BUILTINS1(cbrt)
BUILTINS1(ceil)
BUILTINS2(copysign)
BUILTINS1(cos)
BUILTINS1(cosh)
BUILTINS1(erf)
BUILTINS1(erfc)
BUILTINS1(exp)
BUILTINS1(exp2)
BUILTINS1(expm1)
BUILTINS1(fabs)
BUILTINS2(fdim)
BUILTINS1(floor)
BUILTINS2(fmax)
BUILTINS2(fmin)
BUILTINS2(fmod)
BUILTINS2(hypot)
BUILTINS1(j0)
BUILTINS1(j1)
BUILTINS1(lgamma)
BUILTINS1(log)
BUILTINS1(log10)
BUILTINS1(log1p)
BUILTINS1(log2)
BUILTINS1(logb)
BUILTINS1(nearbyint)
BUILTINS2(nextafter)
BUILTINS2(pow)
BUILTINS2(remainder)
BUILTINS1(rint)
BUILTINS1(round)
BUILTINS1(sin)
BUILTINS1(sinh)
BUILTINS1(sqrt)
BUILTINS1(tan)
BUILTINS1(tanh)
BUILTINS1(tgamma)
BUILTINS1(trunc)
BUILTINS1(y0)
BUILTINS1(y1)
__END_DECLS

View File

@ -55,16 +55,10 @@ if [[ -z ${MAKE_JOBS:x} ]]; then
MAKE_JOBS="-j$(nproc)" MAKE_JOBS="-j$(nproc)"
fi fi
if [ $BANAN_ARCH = "x86_64" ]; then
XCFLAGS="-g -O2 -mcmodel=large -mno-red-zone"
else
XCFLAGS="-g -O2"
fi
enter_clean_build () { enter_clean_build () {
rm -rf build-$BANAN_ARCH rm -rf build
mkdir build-$BANAN_ARCH mkdir build
cd build-$BANAN_ARCH cd build
} }
build_binutils () { build_binutils () {
@ -116,7 +110,7 @@ build_gcc () {
--enable-languages=c,c++ --enable-languages=c,c++
make $MAKE_JOBS all-gcc make $MAKE_JOBS all-gcc
make $MAKE_JOBS all-target-libgcc CFLAGS_FOR_TARGET="$XCFLAGS" make $MAKE_JOBS all-target-libgcc CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
make install-gcc make install-gcc
make install-target-libgcc make install-target-libgcc
} }
@ -148,13 +142,13 @@ build_grub () {
} }
build_libstdcpp () { build_libstdcpp () {
if ! [[ -d $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build-$BANAN_ARCH ]]; then if ! [[ -d $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build ]]; then
echo "You have to build gcc first" echo "You have to build gcc first"
exit 1 exit 1
fi fi
cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build-$BANAN_ARCH cd $BANAN_BUILD_DIR/toolchain/$GCC_VERSION/build
make $MAKE_JOBS all-target-libstdc++-v3 CFLAGS_FOR_TARGET="$XCFLAGS" make $MAKE_JOBS all-target-libstdc++-v3 CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
make install-target-libstdc++-v3 make install-target-libstdc++-v3
} }
@ -168,14 +162,13 @@ echo "Creating dummy sysroot"
mkdir -p $BANAN_SYSROOT/usr mkdir -p $BANAN_SYSROOT/usr
cp -r $BANAN_ROOT_DIR/libc/include $BANAN_SYSROOT/usr/include cp -r $BANAN_ROOT_DIR/libc/include $BANAN_SYSROOT/usr/include
# Cleanup all old files from toolchain prefix
rm -rf $BANAN_TOOLCHAIN_PREFIX
mkdir -p $BANAN_BUILD_DIR/toolchain mkdir -p $BANAN_BUILD_DIR/toolchain
build_binutils build_binutils
build_gcc build_gcc
build_grub
# Grub is only needed for UEFI (x86_64)
if [ $BANAN_ARCH = "x86_64" ]; then
build_grub
fi
# delete sysroot and install libc # delete sysroot and install libc
rm -r $BANAN_SYSROOT rm -r $BANAN_SYSROOT