Compare commits

...

8 Commits

Author SHA1 Message Date
Bananymous 8c569ac7bf 2500th COMMIT: ports: Add gcc port
I've had this laying around locally for a while. binutils was not
working so I didn't feel like this was worth pushing. My new stdio FILE
buffering rewrite fixed binutils and now gcc actually works!
2025-01-25 18:40:16 +02:00
Bananymous a84fb57e32 ports: Add binutils port 2025-01-25 18:40:16 +02:00
Bananymous 7314d2b577 ports: Add mpc port
This will be used by gcc
2025-01-25 18:40:16 +02:00
Bananymous ba83ede0d1 ports: Add mpfr port
This will be used by gcc
2025-01-25 18:40:08 +02:00
Bananymous 42500ce043 ports: Add gmp port
This will be used by gcc
2025-01-25 18:40:04 +02:00
Bananymous caa8c1da90 LibC: Add stub implementations for set{rlimit,priority} 2025-01-25 18:15:50 +02:00
Bananymous cbcb9f9044 Kernel: Warn on unsupport `clock_gettime` `clock_id`s 2025-01-25 17:31:17 +02:00
Bananymous 60bffb5f49 LibC: Implement `clock` in terms of `clock_gettime`
This allows clock to "just work" after I update clock_gettime to support
CLOCK_PROCESS_CPUTIME_ID.
2025-01-24 19:58:44 +02:00
14 changed files with 148 additions and 6 deletions

View File

@ -1917,16 +1917,13 @@ namespace Kernel
switch (clock_id)
{
case CLOCK_MONOTONIC:
{
*tp = SystemTimer::get().time_since_boot();
break;
}
case CLOCK_REALTIME:
{
*tp = SystemTimer::get().real_time();
break;
}
default:
dwarnln("TODO: clock_gettime({})", clock_id);
return BAN::Error::from_errno(ENOTSUP);
}
return 0;

24
ports/binutils/build.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash ../install.sh
NAME='binutils'
VERSION='2.39'
DOWNLOAD_URL="https://ftp.gnu.org/gnu/binutils/binutils-$VERSION.tar.gz#d12ea6f239f1ffe3533ea11ad6e224ffcb89eb5d01bbea589e9158780fa11f10"
DEPENDENCIES=('zlib')
CONFIGURE_OPTIONS=(
"--target=$BANAN_TOOLCHAIN_TRIPLE"
'--with-sysroot=/'
"--with-build-sysroot=$BANAN_SYSROOT"
'--enable-initfini-array'
'--enable-shared'
'--enable-lto'
'--disable-nls'
'--disable-werror'
)
build() {
# This file is not even used. binutils just requires it to exist
touch "$BANAN_SYSROOT/usr/include/memory.h"
make -j$(nproc) || exit 1
find . -type f -executable -exec strip --strip-unneeded {} + 2>/dev/null
}

View File

@ -0,0 +1 @@
../../../toolchain/binutils-2.39.patch

29
ports/gcc/build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash ../install.sh
NAME='gcc'
VERSION='12.2.0'
DOWNLOAD_URL="https://ftp.gnu.org/gnu/gcc/gcc-$VERSION/gcc-$VERSION.tar.gz#ac6b317eb4d25444d87cf29c0d141dedc1323a1833ec9995211b13e1a851261c"
DEPENDENCIES=('binutils' 'gmp' 'mpfr' 'mpc')
CONFIGURE_OPTIONS=(
"--target=$BANAN_TOOLCHAIN_TRIPLE"
'--with-sysroot=/'
"--with-build-sysroot=$BANAN_SYSROOT"
'--enable-initfini-array'
'--enable-shared'
'--enable-lto'
'--disable-nls'
'--enable-languages=c,c++'
)
build() {
make -j$(nproc) all-gcc || exit 1
make -j$(nproc) all-target-libgcc || exit 1
make -j$(nproc) all-target-libstdc++-v3 || exit 1
find . -type f -executable -exec strip --strip-unneeded {} + 2>/dev/null
}
install() {
make install-gcc DESTDIR="$BANAN_SYSROOT" || exit 1
make install-target-libgcc DESTDIR="$BANAN_SYSROOT" || exit 1
make install-target-libstdc++-v3 DESTDIR="$BANAN_SYSROOT" || exit 1
}

View File

@ -0,0 +1,11 @@
diff -ruN gcc-12.2.0/gcc/configure gcc-12.2.0-banan_os/gcc/configure
--- gcc-12.2.0/gcc/configure 2022-08-19 11:09:52.736664469 +0300
+++ gcc-12.2.0-banan_os/gcc/configure 2024-08-08 09:30:58.730876253 +0300
@@ -9426,6 +9426,7 @@
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+ac_cv_c_bigendian=no
if ${ac_cv_c_bigendian+:} false; then :
$as_echo_n "(cached) " >&6
else

View File

@ -0,0 +1 @@
../../../toolchain/gcc-12.2.0.patch

5
ports/gmp/build.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash ../install.sh
NAME='gmp'
VERSION='6.3.0'
DOWNLOAD_URL="https://ftp.gnu.org/gnu/gmp/gmp-$VERSION.tar.xz#a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898"

View File

@ -0,0 +1,12 @@
diff -ruN gmp-6.3.0/configfsf.sub gmp-6.3.0-banan_os/configfsf.sub
--- gmp-6.3.0/configfsf.sub 2023-07-29 16:42:16.000000000 +0300
+++ gmp-6.3.0-banan_os/configfsf.sub 2024-08-07 21:37:12.147551767 +0300
@@ -1759,7 +1759,7 @@
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
- | fiwix* | mlibc* )
+ | fiwix* | mlibc* | banan_os* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)

10
ports/mpc/build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash ../install.sh
NAME='mpc'
VERSION='1.3.1'
DOWNLOAD_URL="https://ftp.gnu.org/gnu/mpc/mpc-$VERSION.tar.gz#ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"
DEPENDENCIES=('gmp' 'mpfr')
CONFIGURE_OPTIONS=(
"--target=$BANAN_TOOLCHAIN_TRIPLE"
"--with-sysroot=$BANAN_SYSROOT"
)

View File

@ -0,0 +1,13 @@
diff -ruN mpc-1.3.1/build-aux/config.sub mpc-1.3.1-banan_os/build-aux/config.sub
--- mpc-1.3.1/build-aux/config.sub 2022-12-08 14:23:21.000000000 +0200
+++ mpc-1.3.1-banan_os/build-aux/config.sub 2024-08-07 22:52:40.072912471 +0300
@@ -1748,7 +1748,8 @@
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
+ | banan_os* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)

10
ports/mpfr/build.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash ../install.sh
NAME='mpfr'
VERSION='4.2.1'
DOWNLOAD_URL="https://ftp.gnu.org/gnu/mpfr/mpfr-$VERSION.tar.gz#116715552bd966c85b417c424db1bbdf639f53836eb361549d1f8d6ded5cb4c6"
DEPENDENCIES=('gmp')
CONFIGURE_OPTIONS=(
"--target=$BANAN_TOOLCHAIN_TRIPLE"
'--with-sysroot=/'
)

View File

@ -0,0 +1,12 @@
diff -ruN mpfr-4.2.1/config.sub mpfr-4.2.1-banan_os/config.sub
--- mpfr-4.2.1/config.sub 2023-08-22 10:47:14.000000000 +0300
+++ mpfr-4.2.1-banan_os/config.sub 2024-08-07 22:48:27.798804026 +0300
@@ -1754,7 +1754,7 @@
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
- | fiwix* )
+ | fiwix* | banan_os* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)

View File

@ -61,3 +61,17 @@ int getrusage(int who, struct rusage* r_usage)
return 0;
}
int setrlimit(int resource, const struct rlimit* rlp)
{
dwarnln("TODO: setrlimit({}, {})", resource, rlp);
errno = ENOTSUP;
return -1;
}
int setpriority(int which, id_t who, int value)
{
dwarnln("TODO: setpriority({}, {}, {})", which, who, value);
errno = ENOTSUP;
return -1;
}

View File

@ -20,8 +20,11 @@ int nanosleep(const struct timespec* rqtp, struct timespec* rmtp)
clock_t clock(void)
{
dwarnln("TODO: clock");
return -1;
timespec ts;
if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == -1)
return -1;
return ((uint64_t)ts.tv_sec * CLOCKS_PER_SEC)
+ ((uint64_t)ts.tv_nsec * CLOCKS_PER_SEC / 1'000'000'000);
}
time_t time(time_t* tloc)