diff --git a/.gitignore b/.gitignore index 0d2c2eac..ef246df0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ initrd/bin/** base/usr/bin/** base/usr/include/** base/usr/lib/** +base/usr/libexec/** base/usr/share/pkgdb/** !base/usr/share/fonts/* !base/usr/share/icons/* diff --git a/ports/README.md b/ports/README.md index 615c89a0..ecaf91e6 100644 --- a/ports/README.md +++ b/ports/README.md @@ -13,6 +13,7 @@ Name | Version | Description | URL ---|---|--- | --- bc | 6.6.0 | An implementation of the POSIX bc calculator | https://github.com/gavinhoward/bc binutils | 2.39 | The GNU suite of binary utilities | https://www.gnu.org/software/binutils +gcc | 12.2.0 | The GNU Compiler Collection | https://www.gnu.org/software/gcc gmp | 6.3.0 | The GNU Multiple Precision Arithmetic Library | https://gmplib.org minitar | 1.7.5 | Tiny and easy-to-use C library to read/write tar archives | https://git.cloudapio.eu/apio/minitar mpc | 1.3.1 | The GNU Multiple Precision Complex Library | https://www.multiprecision.org diff --git a/ports/gcc/PACKAGE b/ports/gcc/PACKAGE new file mode 100644 index 00000000..5d777874 --- /dev/null +++ b/ports/gcc/PACKAGE @@ -0,0 +1,35 @@ +# Basic information +name="gcc" +version="12.2.0" +dependencies=(gmp mpc mpfr binutils) + +# Download options +format="tar" +url="https://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz" +output="gcc-$version.tar.xz" +sha256sum="e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff" + +# Build instructions +do_patch() +{ + patch -ui $portdir/gcc.patch -p 1 -d $srcdir/.. +} + +do_configure() +{ + $srcdir/configure --prefix=/usr --target=$LUNA_ARCH-luna --host=$LUNA_ARCH-luna --disable-nls --with-build-sysroot=$BUILD_SYSROOT --enable-languages=c,c++ +} + +do_build() +{ + export ac_cv_c_bigendian=no + + make all-gcc -j$MAKEJOBS + make all-target-libgcc -j$MAKEJOBS CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone' +} + +do_install() +{ + make install-gcc + make install-target-libgcc +} diff --git a/ports/gcc/gcc.patch b/ports/gcc/gcc.patch new file mode 100644 index 00000000..8e322273 --- /dev/null +++ b/ports/gcc/gcc.patch @@ -0,0 +1,251 @@ +diff --color -rN -u vanilla/gcc-12.2.0/config.sub gcc-12.2.0/config.sub +--- a/gcc-12.2.0/config.sub 2022-08-19 10:09:52.128656687 +0200 ++++ b/gcc-12.2.0/config.sub 2023-08-08 20:42:05.032843544 +0200 +@@ -1723,7 +1723,7 @@ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ +- | os9* | macos* | osx* | ios* \ ++ | os9* | macos* | osx* | ios* | luna* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ +diff --color -rN -u vanilla/gcc-12.2.0/fixincludes/mkfixinc.sh gcc-12.2.0/fixincludes/mkfixinc.sh +--- a/gcc-12.2.0/fixincludes/mkfixinc.sh 2022-08-19 10:09:52.160657095 +0200 ++++ b/gcc-12.2.0/fixincludes/mkfixinc.sh 2023-08-08 20:42:05.034843561 +0200 +@@ -12,6 +12,8 @@ + # Check for special fix rules for particular targets + case $machine in + i?86-*-cygwin* | \ ++ *-luna* | \ ++ *-*-luna* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ + powerpc-*-eabisim* | \ +diff --color -rN -u vanilla/gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel +--- a/gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel 1970-01-01 01:00:00.000000000 +0100 ++++ b/gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel 2023-08-08 20:42:05.038843594 +0200 +@@ -0,0 +1,4 @@ ++#Add libgcc multilib variant without red-zone requirement, for use in the kernel ++ ++MULTILIB_OPTIONS += mno-red-zone ++MULTILIB_DIRNAMES += no-red-zone +\ No newline at end of file +diff --color -rN -u vanilla/gcc-12.2.0/gcc/config/luna.h gcc-12.2.0/gcc/config/luna.h +--- a/gcc-12.2.0/gcc/config/luna.h 1970-01-01 01:00:00.000000000 +0100 ++++ b/gcc-12.2.0/gcc/config/luna.h 2023-08-08 20:42:05.040843610 +0200 +@@ -0,0 +1,36 @@ ++#undef TARGET_LUNA ++#define TARGET_LUNA 1 ++ ++/* Default arguments you want when running your ++ i686-luna-gcc/x86_64-luna-gcc toolchain */ ++#undef LIB_SPEC ++#define LIB_SPEC "-lc" /* link against C standard library */ ++ ++/* Files that are linked before user code. ++ The %s tells GCC to look for these files in the library directory. */ ++#undef STARTFILE_SPEC ++#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s" ++ ++/* Files that are linked after user code. */ ++#undef ENDFILE_SPEC ++#define ENDFILE_SPEC "crtend.o%s crtn.o%s" ++ ++#undef SIZE_TYPE ++#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int") ++ ++/* Ensure that ptrdiff_t matches the actual pointer size */ ++#undef PTRDIFF_TYPE ++#define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int") ++ ++/* Additional predefined macros. */ ++#undef TARGET_OS_CPP_BUILTINS ++#define TARGET_OS_CPP_BUILTINS() \ ++ do { \ ++ builtin_define("__luna__"); \ ++ builtin_define("__unix__"); \ ++ builtin_assert("system=luna"); \ ++ builtin_assert("system=unix"); \ ++ builtin_assert("system=posix"); \ ++ } while (0); ++ ++#undef LINK_SPEC +diff --color -rN -u vanilla/gcc-12.2.0/gcc/config.gcc gcc-12.2.0/gcc/config.gcc +--- a/gcc-12.2.0/gcc/config.gcc 2022-08-19 10:09:52.552662114 +0200 ++++ b/gcc-12.2.0/gcc/config.gcc 2023-08-08 20:42:05.044843643 +0200 +@@ -895,6 +895,12 @@ + ;; + esac + ;; ++*-*-luna*) ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ use_gcc_stdint=provide ++ ;; + *-*-netbsd*) + tm_p_file="${tm_p_file} netbsd-protos.h" + tmake_file="t-netbsd t-slibgcc" +@@ -1901,6 +1907,13 @@ + x86_64-*-elf*) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h" + ;; ++i[34567]86-*-luna*) ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h luna.h" ++ ;; ++x86_64-*-luna*) ++ tmake_file="${tmake_file} i386/x86_64-luna-kernel" ++ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h luna.h" ++ ;; + x86_64-*-rtems*) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h i386/rtemself.h rtems.h" + ;; +diff --color -rN -u vanilla/gcc-12.2.0/libgcc/config.host gcc-12.2.0/libgcc/config.host +--- a/gcc-12.2.0/libgcc/config.host 2022-08-19 10:09:54.664689148 +0200 ++++ b/gcc-12.2.0/libgcc/config.host 2023-08-08 20:42:05.046843660 +0200 +@@ -783,6 +783,14 @@ + ;; + i[34567]86-*-lynxos*) + ;; ++i[34567]86-*-luna*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; ++x86_64-*-luna*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtend.o crtn.o" ++ tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; + i[34567]86-*-nto-qnx*) + tmake_file="$tmake_file i386/t-nto t-libgcc-pic" + extra_parts=crtbegin.o +diff --color -rN -u vanilla/gcc-12.2.0/libgcc/libgcov.h gcc-12.2.0/libgcc/libgcov.h +--- a/gcc-12.2.0/libgcc/libgcov.h 2022-08-19 10:09:54.728689966 +0200 ++++ b/gcc-12.2.0/libgcc/libgcov.h 2023-08-08 20:42:05.048843677 +0200 +@@ -194,6 +194,7 @@ + #endif + + #include "gcov-io.h" ++#include + + /* Structures embedded in coveraged program. The structures generated + by write_profile must match these. */ +diff --color -rN -u vanilla/gcc-12.2.0/libstdc++-v3/acinclude.m4 gcc-12.2.0/libstdc++-v3/acinclude.m4 +--- a/gcc-12.2.0/libstdc++-v3/acinclude.m4 2022-08-19 10:09:55.380698313 +0200 ++++ b/gcc-12.2.0/libstdc++-v3/acinclude.m4 2023-08-08 21:08:00.777765701 +0200 +@@ -1356,6 +1356,10 @@ + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; ++ luna*) ++ ac_has_clock_monotonic=yes ++ ac_has_clock_realtime=yes ++ ;; + # VxWorks has nanosleep as soon as the kernel is configured with + # INCLUDE_POSIX_TIMERS, which is normally/most-often the case. + vxworks*) +@@ -2421,7 +2425,7 @@ + dragonfly* | freebsd*) + enable_clocale_flag=dragonfly + ;; +- openbsd*) ++ openbsd* | luna*) + enable_clocale_flag=newlib + ;; + *) +diff --color -rN -u vanilla/gcc-12.2.0/libstdc++-v3/configure gcc-12.2.0/libstdc++-v3/configure +--- a/gcc-12.2.0/libstdc++-v3/configure 2022-08-19 10:09:55.416698774 +0200 ++++ b/gcc-12.2.0/libstdc++-v3/configure 2023-08-09 11:34:54.810282202 +0200 +@@ -16481,6 +16481,9 @@ + openbsd*) + enable_clocale_flag=newlib + ;; ++ luna*) ++ enable_clocale_flag=generic ++ ;; + *) + if test x"$with_newlib" = x"yes"; then + enable_clocale_flag=newlib +@@ -20493,6 +20496,10 @@ + ac_has_nanosleep=yes + ac_has_sched_yield=yes + ;; ++ luna*) ++ ac_has_clock_monotonic=yes ++ ac_has_clock_realtime=yes ++ ;; + # VxWorks has nanosleep as soon as the kernel is configured with + # INCLUDE_POSIX_TIMERS, which is normally/most-often the case. + vxworks*) +diff --color -rN -u vanilla/gcc-12.2.0/libstdc++-v3/configure.host gcc-12.2.0/libstdc++-v3/configure.host +--- a/gcc-12.2.0/libstdc++-v3/configure.host 2022-08-19 10:09:55.420698825 +0200 ++++ b/gcc-12.2.0/libstdc++-v3/configure.host 2023-08-09 11:35:05.734185945 +0200 +@@ -306,6 +306,9 @@ + vxworks*) + os_include_dir="os/vxworks" + ;; ++ luna*) ++ os_include_dir="os/generic" ++ ;; + *) + os_include_dir="os/generic" + ;; +diff --color -rN -u vanilla/gcc-12.2.0/libstdc++-v3/crossconfig.m4 gcc-12.2.0/libstdc++-v3/crossconfig.m4 +--- a/gcc-12.2.0/libstdc++-v3/crossconfig.m4 2022-08-19 10:09:55.420698825 +0200 ++++ b/gcc-12.2.0/libstdc++-v3/crossconfig.m4 2023-08-08 21:16:12.897071194 +0200 +@@ -277,6 +277,12 @@ + GLIBCXX_CHECK_MATH_SUPPORT + GLIBCXX_CHECK_STDLIB_SUPPORT + ;; ++ *-luna*) ++ GLIBCXX_CHECK_COMPILER_FEATURES ++ GLIBCXX_CHECK_LINKER_FEATURES ++ GLIBCXX_CHECK_MATH_SUPPORT ++ GLIBCXX_CHECK_STDLIB_SUPPORT ++ ;; + *-vxworks*) + AC_DEFINE(HAVE_ACOSF) + AC_DEFINE(HAVE_ASINF) +diff --color -rN -u toolchain/build/gcc-12.2.0/libcody/netserver.cc ports/temp/gcc-12.2.0/libcody/netserver.cc +--- a/gcc-12.2.0/libcody/netserver.cc 2022-08-19 10:09:54.620688586 +0200 ++++ b/gcc-12.2.0/libcody/netserver.cc 2023-10-15 11:26:18.755350163 +0200 +@@ -78,6 +78,10 @@ + + int ListenInet6 (char const **e, char const *name, int port, unsigned backlog) + { ++#ifdef __luna__ ++ errno = ENOTSUP; ++ return -1; ++#else + addrinfo *addrs = nullptr; + int fd = -1; + char const *errstr = nullptr; +@@ -150,6 +154,7 @@ + + return fd; ++#endif + } + + } + #endif +diff --color -rN -u toolchain/build/gcc-12.2.0/libcody/netclient.cc ports/temp/gcc-12.2.0/libcody/netclient.cc +--- a/gcc-12.2.0/libcody/netclient.cc 2022-08-19 10:09:54.620688586 +0200 ++++ b/gcc-12.2.0/libcody/netclient.cc 2023-10-15 11:32:45.205953424 +0200 +@@ -71,6 +71,10 @@ + + int OpenInet6 (char const **e, char const *name, int port) + { ++#ifdef __luna__ ++ errno = ENOTSUP; ++ return -1; ++#else + addrinfo *addrs = nullptr; + int fd = -1; + char const *errstr = nullptr; +@@ -133,6 +137,7 @@ + + return fd; ++#endif + } + + }