tools: Build libstdc++
This commit is contained in:
parent
0c64b6e040
commit
181b4c151b
@ -198,6 +198,9 @@ extern "C"
|
||||
/* Change a file's buffering mode to line buffered. */
|
||||
void setlinebuf(FILE* stream);
|
||||
|
||||
/* Move a file's location across a file system. */
|
||||
int rename(const char* oldpath, const char* newpath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -752,4 +752,13 @@ extern "C"
|
||||
{
|
||||
setvbuf(stream, NULL, _IOLBF, 0);
|
||||
}
|
||||
|
||||
int rename(const char* oldpath, const char* newpath)
|
||||
{
|
||||
// FIXME: Implement this atomically in-kernel.
|
||||
unlink(newpath);
|
||||
if (link(oldpath, newpath) < 0) return -1;
|
||||
unlink(oldpath);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,14 @@
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
// Otherwise, this is defined in libstdc++.
|
||||
#ifdef USE_FREESTANDING
|
||||
|
||||
namespace std
|
||||
{
|
||||
const nothrow_t nothrow;
|
||||
}
|
||||
#endif
|
||||
|
||||
static constexpr int BLOCK_USED = 1 << 0;
|
||||
static constexpr int BLOCK_START_MEM = 1 << 1;
|
||||
@ -417,6 +421,8 @@ void dump_heap_usage()
|
||||
dbgln("-- Heap memory in use: %zu bytes", alloc_used);
|
||||
}
|
||||
|
||||
// Otherwise, this is defined in libstdc++.
|
||||
#ifdef USE_FREESTANDING
|
||||
void* operator new(usize size, const std::nothrow_t&) noexcept
|
||||
{
|
||||
return malloc_impl(size).value_or(nullptr);
|
||||
@ -446,3 +452,4 @@ void operator delete[](void* p, usize) noexcept
|
||||
{
|
||||
free_impl(p);
|
||||
}
|
||||
#endif
|
||||
|
110
tools/gcc.patch
110
tools/gcc.patch
@ -1,6 +1,6 @@
|
||||
diff --color -rN -u gcc-12.2.0/config.sub build/gcc-12.2.0/config.sub
|
||||
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 2022-10-02 11:27:45.660055384 +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* \
|
||||
@ -10,9 +10,9 @@ diff --color -rN -u gcc-12.2.0/config.sub build/gcc-12.2.0/config.sub
|
||||
| mpw* | magic* | mmixware* | mon960* | lnews* \
|
||||
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
|
||||
| aos* | aros* | cloudabi* | sortix* | twizzler* \
|
||||
diff --color -rN -u gcc-12.2.0/fixincludes/mkfixinc.sh build/gcc-12.2.0/fixincludes/mkfixinc.sh
|
||||
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 2022-10-02 11:27:45.662055397 +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
|
||||
@ -22,18 +22,18 @@ diff --color -rN -u gcc-12.2.0/fixincludes/mkfixinc.sh build/gcc-12.2.0/fixinclu
|
||||
i?86-*-mingw32* | \
|
||||
x86_64-*-mingw32* | \
|
||||
powerpc-*-eabisim* | \
|
||||
diff --color -rN -u gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel build/gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel
|
||||
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/gcc-12.2.0/gcc/config/i386/x86_64-luna-kernel 2022-10-02 11:45:30.955856133 +0200
|
||||
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 gcc-12.2.0/gcc/config/luna.h build/gcc-12.2.0/gcc/config/luna.h
|
||||
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/gcc-12.2.0/gcc/config/luna.h 2022-10-02 11:27:45.663055404 +0200
|
||||
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
|
||||
@ -71,11 +71,9 @@ diff --color -rN -u gcc-12.2.0/gcc/config/luna.h build/gcc-12.2.0/gcc/config/lun
|
||||
+ } while (0);
|
||||
+
|
||||
+#undef LINK_SPEC
|
||||
+#define LINK_SPEC "-z max-page-size=4096"
|
||||
\ No newline at end of file
|
||||
diff --color -rN -u gcc-12.2.0/gcc/config.gcc build/gcc-12.2.0/gcc/config.gcc
|
||||
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 2022-10-02 11:45:18.311797546 +0200
|
||||
+++ b/gcc-12.2.0/gcc/config.gcc 2023-08-08 20:42:05.044843643 +0200
|
||||
@@ -895,6 +895,12 @@
|
||||
;;
|
||||
esac
|
||||
@ -103,9 +101,9 @@ diff --color -rN -u gcc-12.2.0/gcc/config.gcc build/gcc-12.2.0/gcc/config.gcc
|
||||
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 gcc-12.2.0/libgcc/config.host build/gcc-12.2.0/libgcc/config.host
|
||||
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 2022-10-02 11:27:45.671055461 +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*)
|
||||
@ -121,9 +119,9 @@ diff --color -rN -u gcc-12.2.0/libgcc/config.host build/gcc-12.2.0/libgcc/config
|
||||
i[34567]86-*-nto-qnx*)
|
||||
tmake_file="$tmake_file i386/t-nto t-libgcc-pic"
|
||||
extra_parts=crtbegin.o
|
||||
diff --color -rN -u gcc-12.2.0/libgcc/libgcov.h build/gcc-12.2.0/libgcc/libgcov.h
|
||||
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 2022-10-02 11:41:48.571807335 +0200
|
||||
+++ b/gcc-12.2.0/libgcc/libgcov.h 2023-08-08 20:42:05.048843677 +0200
|
||||
@@ -194,6 +194,7 @@
|
||||
#endif
|
||||
|
||||
@ -132,3 +130,79 @@ diff --color -rN -u gcc-12.2.0/libgcc/libgcov.h build/gcc-12.2.0/libgcc/libgcov.
|
||||
|
||||
/* 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)
|
||||
|
@ -47,7 +47,7 @@ unset CXX
|
||||
unset LD
|
||||
unset AR
|
||||
|
||||
../gcc-$LUNA_GCC_VERSION_REQUIRED/configure --prefix="$BUILD_PREFIX" --target=$BUILD_TARGET --disable-nls --with-sysroot=$BUILD_SYSROOT --enable-languages=c,c++ --without-headers
|
||||
../gcc-$LUNA_GCC_VERSION_REQUIRED/configure --prefix="$BUILD_PREFIX" --target=$BUILD_TARGET --disable-nls --with-sysroot=$BUILD_SYSROOT --enable-languages=c,c++
|
||||
|
||||
echo Building GCC...
|
||||
|
||||
@ -58,3 +58,10 @@ echo Installing GCC...
|
||||
|
||||
make install-gcc
|
||||
make install-target-libgcc
|
||||
|
||||
mkdir -p $LUNA_BUILD_DIR
|
||||
cmake -S $LUNA_ROOT -B $LUNA_BUILD_DIR -G "$LUNA_CMAKE_GENERATOR_NAME"
|
||||
cmake --build $LUNA_BUILD_DIR --target libc
|
||||
|
||||
make all-target-libstdc++-v3 CXXFLAGS_FOR_TARGET="-fno-exceptions" -j$(nproc)
|
||||
make DESTDIR=$LUNA_BASE/usr install-target-libstdc++-v3
|
||||
|
Loading…
Reference in New Issue
Block a user