From efc2a789388d1bb4fa5997f9c9b491170933ede0 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Wed, 21 Apr 2021 08:06:18 +0900 Subject: [PATCH] toaru: Add target definition for ToaruOS --- config.sub | 6 +++++- fixincludes/mkfixinc.sh | 2 ++ gcc/config.gcc | 12 ++++++++++++ gcc/config/toaru.h | 21 +++++++++++++++++++++ libgcc/config.host | 8 ++++++++ libstdc++-v3/crossconfig.m4 | 6 ++++++ 6 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 gcc/config/toaru.h diff --git a/config.sub b/config.sub index a318a46868500..e0b5153934f9d 100755 --- a/config.sub +++ b/config.sub @@ -581,6 +581,10 @@ case $1 in basic_machine=pdp10-xkl os=tops20 ;; + toaru) + basic_machine=x86_64-pc + os=toaru + ;; tpf) basic_machine=s390x-ibm os=tpf @@ -1363,7 +1367,7 @@ case $os in | os2* | vos* | palmos* | uclinux* | nucleus* \ | morphos* | superux* | rtmk* | windiss* \ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* | toaru* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix) diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh index df90720b716f2..701fa1b19f8fb 100755 --- a/fixincludes/mkfixinc.sh +++ b/fixincludes/mkfixinc.sh @@ -14,6 +14,8 @@ case $machine in i?86-*-cygwin* | \ i?86-*-mingw32* | \ x86_64-*-mingw32* | \ + i?86-*-toaru* | \ + x86_64-*-toaru* | \ powerpc-*-eabisim* | \ powerpc-*-eabi* | \ powerpc-*-rtems* | \ diff --git a/gcc/config.gcc b/gcc/config.gcc index 6fcdd771d4c32..8dcc1ce4552e8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -963,6 +963,12 @@ case ${target} in esac target_has_targetdm=yes ;; +*-*-toaru*) + gas=yes + gnu_ld=yes + default_use_cxa_atexit=yes + use_gcc_stdint=wrap + ;; *-*-*vms*) extra_options="${extra_options} vms/vms.opt" xmake_file=vms/x-vms @@ -1908,6 +1914,12 @@ x86_64-*-rdos*) 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/rdos.h i386/rdos64.h" tmake_file="i386/t-i386elf t-svr4" ;; +i[34567]86-*-toaru) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h toaru.h" + ;; +x86_64-*-toaru*) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h toaru.h" + ;; i[34567]86-*-dragonfly*) tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h dragonfly.h dragonfly-stdint.h i386/dragonfly.h" tmake_file="${tmake_file} i386/t-crtstuff" diff --git a/gcc/config/toaru.h b/gcc/config/toaru.h new file mode 100644 index 0000000000000..a0a782512ce35 --- /dev/null +++ b/gcc/config/toaru.h @@ -0,0 +1,21 @@ +#undef TARGET_OS_CPP_BUILTINS +#define TARGET_OS_CPP_BUILTINS() \ + do { \ + builtin_define_std ("toaru"); \ + builtin_define_std ("unix"); \ + builtin_assert ("system=toaru"); \ + builtin_assert ("system=unix"); \ + } while (0); + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC "%{!shared: %{!pg:crt0.o%s}} crti.o%s %{!shared:crtbegin.o%s}" + +#undef ENDFILE_SPEC +#define ENDFILE_SPEC "%{!shared:crtend.o%s} crtn.o%s" + +#undef LIB_SPEC +#define LIB_SPEC "%{pthread:-lpthread} -lc" + +#undef LINK_SPEC +#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld.so}}}" + diff --git a/libgcc/config.host b/libgcc/config.host index c529cc40f0c8d..7d2633e3468d0 100644 --- a/libgcc/config.host +++ b/libgcc/config.host @@ -886,6 +886,14 @@ x86_64-*-mingw*) extra_parts="$extra_parts vtv_start.o vtv_end.o vtv_start_preinit.o vtv_end_preinit.o" fi ;; +i[34567]87-*-toaru*) + 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-*-toaru*) + 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" + ;; ia64*-*-elf*) extra_parts="$extra_parts crtbeginS.o crtendS.o crtfastmath.o" tmake_file="ia64/t-ia64 ia64/t-ia64-elf ia64/t-eh-ia64 t-crtfm t-softfp-tf ia64/t-softfp t-softfp ia64/t-softfp-compat" diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 index fe1828835368d..ce34f42cdded5 100644 --- a/libstdc++-v3/crossconfig.m4 +++ b/libstdc++-v3/crossconfig.m4 @@ -243,6 +243,12 @@ case "${host}" in GLIBCXX_CHECK_MATH_SUPPORT GLIBCXX_CHECK_STDLIB_SUPPORT ;; + *-toaru*) + GLIBCXX_CHECK_COMPILER_FEATURES + GLIBCXX_CHECK_LINKER_FEATURES + GLIBCXX_CHECK_MATH_SUPPORT + GLIBCXX_CHECK_STDLIB_SUPPORT + ;; *-tpf) SECTION_FLAGS='-ffunction-sections -fdata-sections' SECTION_LDFLAGS='-Wl,--gc-sections $SECTION_LDFLAGS'