]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Remove D-specific version definitions from target headers
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 17 Oct 2022 17:32:52 +0000 (19:32 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sat, 29 Oct 2022 07:16:47 +0000 (09:16 +0200)
This splits up the targetdm sources so that each file only handles one
target platform.

Having all logic kept in the headers means that they could become out of
sync when a new target is added (loongarch*-*-linux*) or accidentally
broken if some headers in tm_file are changed about.

gcc/ChangeLog:

* config.gcc: Split out glibc-d.o into linux-d.o, kfreebsd-d.o,
kopensolaris-d.o, and gnu-d.o.  Split out cygwin-d.o from winnt-d.o.
* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/i386/cygwin.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/mingw32.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/i386/t-cygming: Add cygwin-d.o.
* config/i386/winnt-d.cc (winnt_d_os_builtins): Only add
MinGW-specific version condition.
* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Remove.
* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Remove.
* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Remove.
* config/t-glibc: Remove glibc-d.o, add gnu-d.o, kfreebsd-d.o,
kopensolaris-d.o.
* config/t-linux: Add linux-d.o.
* config/glibc-d.cc: Remove file.
* config/gnu-d.cc: New file.
* config/i386/cygwin-d.cc: New file.
* config/kfreebsd-d.cc: New file.
* config/kopensolaris-d.cc: New file.
* config/linux-d.cc: New file.

20 files changed:
gcc/config.gcc
gcc/config/arm/linux-eabi.h
gcc/config/gnu-d.cc [moved from gcc/config/glibc-d.cc with 65% similarity]
gcc/config/gnu.h
gcc/config/i386/cygwin-d.cc [new file with mode: 0644]
gcc/config/i386/cygwin.h
gcc/config/i386/linux-common.h
gcc/config/i386/mingw32.h
gcc/config/i386/t-cygming
gcc/config/i386/winnt-d.cc
gcc/config/kfreebsd-d.cc [new file with mode: 0644]
gcc/config/kfreebsd-gnu.h
gcc/config/kopensolaris-d.cc [new file with mode: 0644]
gcc/config/kopensolaris-gnu.h
gcc/config/linux-android.h
gcc/config/linux-d.cc [new file with mode: 0644]
gcc/config/linux.h
gcc/config/mips/linux-common.h
gcc/config/t-glibc
gcc/config/t-linux

index e8fe623c6fe0cafb5d97550d28994cbcd14c8fc5..ac1c08f1936bac77782a451db7d3d1f7b956e439 100644 (file)
@@ -882,10 +882,8 @@ case ${target} in
   esac
   c_target_objs="${c_target_objs} glibc-c.o"
   cxx_target_objs="${cxx_target_objs} glibc-c.o"
-  d_target_objs="${d_target_objs} glibc-d.o"
   tmake_file="${tmake_file} t-glibc"
   target_has_targetcm=yes
-  target_has_targetdm=yes
   case $target in
     *-*-*uclibc* | *-*-uclinuxfdpiceabi)
       ;;
@@ -894,6 +892,24 @@ case ${target} in
       gcc_cv_initfini_array=yes
       ;;
   esac
+  case $target in
+    *-*-*linux*)
+      d_target_objs="${d_target_objs} linux-d.o"
+      target_has_targetdm=yes
+      ;;
+    *-*-kfreebsd*-gnu)
+      d_target_objs="${d_target_objs} kfreebsd-d.o"
+      target_has_targetdm=yes
+      ;;
+    *-*-kopensolaris*-gnu)
+      d_target_objs="${d_target_objs} kopensolaris-d.o"
+      target_has_targetdm=yes
+      ;;
+    *-*-gnu*)
+      d_target_objs="${d_target_objs} gnu-d.o"
+      target_has_targetdm=yes
+      ;;
+  esac
   ;;
 *-*-netbsd*)
   tm_p_file="${tm_p_file} netbsd-protos.h"
@@ -2054,7 +2070,7 @@ i[34567]86-*-cygwin*)
        extra_objs="${extra_objs} winnt.o winnt-stubs.o"
        c_target_objs="${c_target_objs} msformat-c.o"
        cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
-       d_target_objs="${d_target_objs} winnt-d.o"
+       d_target_objs="${d_target_objs} cygwin-d.o"
        target_has_targetdm="yes"
        if test x$enable_threads = xyes; then
                thread_file='posix'
@@ -2072,7 +2088,7 @@ x86_64-*-cygwin*)
        extra_objs="${extra_objs} winnt.o winnt-stubs.o"
        c_target_objs="${c_target_objs} msformat-c.o"
        cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
-       d_target_objs="${d_target_objs} winnt-d.o"
+       d_target_objs="${d_target_objs} cygwin-d.o"
        target_has_targetdm="yes"
        if test x$enable_threads = xyes; then
                thread_file='posix'
index 50cc0bc6d08c27628be352ddbb6e5725f7665215..6d803ceca1e402b462562b68de2d667fab5e3f14 100644 (file)
@@ -30,9 +30,6 @@
     }                                          \
   while (false)
 
-#define EXTRA_TARGET_D_OS_VERSIONS()           \
-  ANDROID_TARGET_D_OS_VERSIONS();
-
 /* We default to a soft-float ABI so that binaries can run on all
    target hardware.  If you override this to use the hard-float ABI then
    change the setting of GLIBC_DYNAMIC_LINKER_DEFAULT as well.  */
similarity index 65%
rename from gcc/config/glibc-d.cc
rename to gcc/config/gnu-d.cc
index 1411f1973e548045fc7da898cf5a1ed2626f68db..1c0dff2afe7b0f0bcb00ab98b786afe70d8f7e3b 100644 (file)
@@ -1,4 +1,4 @@
-/* Glibc support needed only by D front-end.
+/* GNU system support needed only by D front-end.
    Copyright (C) 2017-2022 Free Software Foundation, Inc.
 
 GCC is free software; you can redistribute it and/or modify it under
@@ -23,41 +23,33 @@ along with GCC; see the file COPYING3.  If not see
 #include "d/d-target.h"
 #include "d/d-target-def.h"
 
-/* Implement TARGET_D_OS_VERSIONS for Glibc targets.  */
+/* Implement TARGET_D_OS_VERSIONS for GNU targets.  */
 
 static void
-glibc_d_os_builtins (void)
+gnu_d_os_builtins (void)
 {
   d_add_builtin_version ("Posix");
-
-#define builtin_version(TXT) d_add_builtin_version (TXT)
-
-#ifdef GNU_USER_TARGET_D_OS_VERSIONS
-  GNU_USER_TARGET_D_OS_VERSIONS ();
-#endif
-
-#ifdef EXTRA_TARGET_D_OS_VERSIONS
-  EXTRA_TARGET_D_OS_VERSIONS ();
-#endif
+  d_add_builtin_version ("Hurd");
+  d_add_builtin_version ("CRuntime_Glibc");
 }
 
 /* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
 
 static tree
-glibc_d_handle_target_object_format (void)
+gnu_d_handle_target_object_format (void)
 {
   const char *objfmt = "elf";
 
   return build_string_literal (strlen (objfmt) + 1, objfmt);
 }
 
-/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Glibc targets.  */
+/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for GNU targets.  */
 
 static void
-glibc_d_register_target_info (void)
+gnu_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
-    { "objectFormat", glibc_d_handle_target_object_format },
+    { "objectFormat", gnu_d_handle_target_object_format },
     { NULL, NULL },
   };
 
@@ -65,9 +57,9 @@ glibc_d_register_target_info (void)
 }
 
 #undef TARGET_D_OS_VERSIONS
-#define TARGET_D_OS_VERSIONS glibc_d_os_builtins
+#define TARGET_D_OS_VERSIONS gnu_d_os_builtins
 
 #undef TARGET_D_REGISTER_OS_TARGET_INFO
-#define TARGET_D_REGISTER_OS_TARGET_INFO glibc_d_register_target_info
+#define TARGET_D_REGISTER_OS_TARGET_INFO gnu_d_register_target_info
 
 struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
index de2ead82be93eedfc238cc4ed64716fdcc058ddf..e8d72463ab23eb775fc4dcaae787ecfb929e9772 100644 (file)
@@ -31,9 +31,3 @@ along with GCC.  If not, see <http://www.gnu.org/licenses/>.
        builtin_assert ("system=unix");         \
        builtin_assert ("system=posix");        \
     } while (0)
-
-#define GNU_USER_TARGET_D_OS_VERSIONS()                \
-    do {                                       \
-       builtin_version ("Hurd");               \
-       builtin_version ("CRuntime_Glibc");     \
-    } while (0)
diff --git a/gcc/config/i386/cygwin-d.cc b/gcc/config/i386/cygwin-d.cc
new file mode 100644 (file)
index 0000000..619930b
--- /dev/null
@@ -0,0 +1,83 @@
+/* Cygwin support needed only by D front-end.
+   Copyright (C) 2021-2022 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#define IN_TARGET_CODE 1
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "target.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for Cygwin targets.  */
+
+static void
+cygwin_d_os_builtins (void)
+{
+  d_add_builtin_version ("Windows");
+  d_add_builtin_version ("Cygwin");
+  d_add_builtin_version ("Posix");
+  d_add_builtin_version ("CRuntime_Newlib");
+}
+
+/* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
+
+static tree
+cygwin_d_handle_target_object_format (void)
+{
+  const char *objfmt = "coff";
+
+  return build_string_literal (strlen (objfmt) + 1, objfmt);
+}
+
+/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Cygwin targets.  */
+
+static void
+cygwin_d_register_target_info (void)
+{
+  const struct d_target_info_spec handlers[] = {
+    { "objectFormat", cygwin_d_handle_target_object_format },
+    { NULL, NULL },
+  };
+
+  d_add_target_info_handlers (handlers);
+}
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS cygwin_d_os_builtins
+
+#undef TARGET_D_REGISTER_OS_TARGET_INFO
+#define TARGET_D_REGISTER_OS_TARGET_INFO cygwin_d_register_target_info
+
+/* Define TARGET_D_MINFO_SECTION for Cygwin targets.  */
+
+#undef TARGET_D_MINFO_SECTION
+#define TARGET_D_MINFO_SECTION "minfo"
+
+#undef TARGET_D_MINFO_START_NAME
+#define TARGET_D_MINFO_START_NAME "__start_minfo"
+
+#undef TARGET_D_MINFO_END_NAME
+#define TARGET_D_MINFO_END_NAME "__stop_minfo"
+
+/* Define TARGET_D_TEMPLATES_ALWAYS_COMDAT for Cygwin targets.  */
+
+#undef TARGET_D_TEMPLATES_ALWAYS_COMDAT
+#define TARGET_D_TEMPLATES_ALWAYS_COMDAT true
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
index d06eda369cf55ed7eebb9c199de78580c2031d18..0a604d65b320645b389e4e9e2eb373a0545cf975 100644 (file)
@@ -29,15 +29,6 @@ along with GCC; see the file COPYING3.  If not see
     }                                                          \
   while (0)
 
-#define EXTRA_TARGET_D_OS_VERSIONS()                           \
-  do                                                           \
-    {                                                          \
-      builtin_version ("Cygwin");                              \
-      builtin_version ("Posix");                               \
-      builtin_version ("CRuntime_Newlib");                     \
-    }                                                          \
-  while (0)
-
 #undef CPP_SPEC
 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
   %{!ansi:-Dunix} \
index efa7fb2072c2e348cdc665ab3a2d2c145a7b2ce3..53cf86f58e77e21d7b0f41019086c5d16131423d 100644 (file)
@@ -27,9 +27,6 @@ along with GCC; see the file COPYING3.  If not see
     }                                          \
   while (0)
 
-#define EXTRA_TARGET_D_OS_VERSIONS()           \
-  ANDROID_TARGET_D_OS_VERSIONS();
-
 #undef CC1_SPEC
 #define CC1_SPEC \
   LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
index b5f31c3da0aca9a45c0095b93de2e66c1db4db40..19a98c3d995157ab61d824ec72e1f207d5b6d697 100644 (file)
@@ -59,18 +59,6 @@ along with GCC; see the file COPYING3.  If not see
     }                                                          \
   while (0)
 
-#define EXTRA_TARGET_D_OS_VERSIONS()                           \
-  do                                                           \
-    {                                                          \
-      builtin_version ("MinGW");                               \
-      if (TARGET_64BIT && ix86_abi == MS_ABI)                  \
-       builtin_version ("Win64");                              \
-      else if (!TARGET_64BIT)                                  \
-       builtin_version ("Win32");                              \
-      builtin_version ("CRuntime_Microsoft");                  \
-    }                                                          \
-  while (0)
-
 #ifndef TARGET_USE_PTHREAD_BY_DEFAULT
 #define SPEC_PTHREAD1 "pthread"
 #define SPEC_PTHREAD2 "!no-pthread"
index d4803dea401ec31a554cca28e265507bf4b0cdf3..f892c27b71d66b4a1567d37e18be418d6544603e 100644 (file)
@@ -39,6 +39,10 @@ winnt-stubs.o: $(srcdir)/config/i386/winnt-stubs.cc $(CONFIG_H) $(SYSTEM_H) core
        $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
        $(srcdir)/config/i386/winnt-stubs.cc
 
+cygwin-d.o: $(srcdir)/config/i386/cygwin-d.cc
+       $(COMPILE) $<
+       $(POSTCOMPILE)
+
 winnt-d.o: $(srcdir)/config/i386/winnt-d.cc
        $(COMPILE) $<
        $(POSTCOMPILE)
index 00c28c3964a41a5d8d3a1510f35747c5654f5f67..a1fd3fa1fbe773aa02c19fd96d63172e3b61efac 100644 (file)
@@ -31,12 +31,14 @@ static void
 winnt_d_os_builtins (void)
 {
   d_add_builtin_version ("Windows");
+  d_add_builtin_version ("MinGW");
 
-#define builtin_version(TXT) d_add_builtin_version (TXT)
+  if (TARGET_64BIT && ix86_abi == MS_ABI)
+    d_add_builtin_version ("Win64");
+  else if (!TARGET_64BIT)
+    d_add_builtin_version ("Win32");
 
-#ifdef EXTRA_TARGET_D_OS_VERSIONS
-  EXTRA_TARGET_D_OS_VERSIONS ();
-#endif
+  d_add_builtin_version ("CRuntime_Microsoft");
 }
 
 /* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
diff --git a/gcc/config/kfreebsd-d.cc b/gcc/config/kfreebsd-d.cc
new file mode 100644 (file)
index 0000000..0bfa6bd
--- /dev/null
@@ -0,0 +1,65 @@
+/* kFreeBSD-based GNU systems support needed only by D front-end.
+   Copyright (C) 2017-2022 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for kFreeBSD targets.  */
+
+static void
+kfreebsd_d_os_builtins (void)
+{
+  d_add_builtin_version ("Posix");
+  d_add_builtin_version ("FreeBSD");
+  d_add_builtin_version ("CRuntime_Glibc");
+}
+
+/* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
+
+static tree
+kfreebsd_d_handle_target_object_format (void)
+{
+  const char *objfmt = "elf";
+
+  return build_string_literal (strlen (objfmt) + 1, objfmt);
+}
+
+/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for kFreeBSD targets.  */
+
+static void
+kfreebsd_d_register_target_info (void)
+{
+  const struct d_target_info_spec handlers[] = {
+    { "objectFormat", kfreebsd_d_handle_target_object_format },
+    { NULL, NULL },
+  };
+
+  d_add_target_info_handlers (handlers);
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS kfreebsd_d_os_builtins
+
+#undef TARGET_D_REGISTER_OS_TARGET_INFO
+#define TARGET_D_REGISTER_OS_TARGET_INFO kfreebsd_d_register_target_info
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
index f74a627bc43407a925af57f7f63a6627a6f4125e..c28fcaf54f5b5a7cfc8e787af5ff753b0977f1ce 100644 (file)
@@ -29,12 +29,6 @@ along with GCC; see the file COPYING3.  If not see
     }                                          \
   while (0)
 
-#define GNU_USER_TARGET_D_OS_VERSIONS()                \
-    do {                                       \
-       builtin_version ("FreeBSD");            \
-       builtin_version ("CRuntime_Glibc");     \
-    } while (0)
-
 #define GNU_USER_DYNAMIC_LINKER        GLIBC_DYNAMIC_LINKER
 #define GNU_USER_DYNAMIC_LINKER32      GLIBC_DYNAMIC_LINKER32
 #define GNU_USER_DYNAMIC_LINKER64      GLIBC_DYNAMIC_LINKER64
diff --git a/gcc/config/kopensolaris-d.cc b/gcc/config/kopensolaris-d.cc
new file mode 100644 (file)
index 0000000..197471a
--- /dev/null
@@ -0,0 +1,65 @@
+/* kOpenSolaris-based GNU systems support needed only by D front-end.
+   Copyright (C) 2017-2022 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for kOpenSolaris targets.  */
+
+static void
+kopensolaris_d_os_builtins (void)
+{
+  d_add_builtin_version ("Posix");
+  d_add_builtin_version ("Solaris");
+  d_add_builtin_version ("CRuntime_Glibc");
+}
+
+/* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
+
+static tree
+kopensolaris_d_handle_target_object_format (void)
+{
+  const char *objfmt = "elf";
+
+  return build_string_literal (strlen (objfmt) + 1, objfmt);
+}
+
+/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for kOpenSolaris targets.  */
+
+static void
+kopensolaris_d_register_target_info (void)
+{
+  const struct d_target_info_spec handlers[] = {
+    { "objectFormat", kopensolaris_d_handle_target_object_format },
+    { NULL, NULL },
+  };
+
+  d_add_target_info_handlers (handlers);
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS kopensolaris_d_os_builtins
+
+#undef TARGET_D_REGISTER_OS_TARGET_INFO
+#define TARGET_D_REGISTER_OS_TARGET_INFO kopensolaris_d_register_target_info
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
index 8379f960b8b731d6018fe20c639f0110933ccc72..3929d4b6955026334f5348321601626c0cf0786b 100644 (file)
@@ -30,11 +30,5 @@ along with GCC; see the file COPYING3.  If not see
     }                                          \
   while (0)
 
-#define GNU_USER_TARGET_D_OS_VERSIONS()                \
-    do {                                       \
-       builtin_version ("Solaris");            \
-       builtin_version ("CRuntime_Glibc");     \
-    } while (0)
-
 #undef GNU_USER_DYNAMIC_LINKER
 #define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
index cf340660adb6e03014e909d27d02a8ee0dd02c3a..f335ceabab53efa517f9274c025d80b4e851d73e 100644 (file)
          builtin_define ("__ANDROID__");                       \
     } while (0)
 
-#define ANDROID_TARGET_D_OS_VERSIONS()                         \
-    do {                                                       \
-       if (TARGET_ANDROID)                                     \
-         builtin_version ("Android");                          \
-    } while (0)
-
 #if ANDROID_DEFAULT
 # define NOANDROID "mno-android"
 #else
diff --git a/gcc/config/linux-d.cc b/gcc/config/linux-d.cc
new file mode 100644 (file)
index 0000000..f2ef2f0
--- /dev/null
@@ -0,0 +1,78 @@
+/* Linux support needed only by D front-end.
+   Copyright (C) 2017-2022 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for Linux targets.  */
+
+static void
+linux_d_os_builtins (void)
+{
+  d_add_builtin_version ("Posix");
+
+  d_add_builtin_version ("linux");
+#ifdef TARGET_ANDROID
+  if (TARGET_ANDROID)
+    d_add_builtin_version ("Android");
+#endif
+
+  if (OPTION_GLIBC)
+    d_add_builtin_version ("CRuntime_Glibc");
+  else if (OPTION_UCLIBC)
+    d_add_builtin_version ("CRuntime_UClibc");
+  else if (OPTION_BIONIC)
+    d_add_builtin_version ("CRuntime_Bionic");
+  else if (OPTION_MUSL)
+    d_add_builtin_version ("CRuntime_Musl");
+}
+
+/* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
+
+static tree
+linux_d_handle_target_object_format (void)
+{
+  const char *objfmt = "elf";
+
+  return build_string_literal (strlen (objfmt) + 1, objfmt);
+}
+
+/* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Linux targets.  */
+
+static void
+linux_d_register_target_info (void)
+{
+  const struct d_target_info_spec handlers[] = {
+    { "objectFormat", linux_d_handle_target_object_format },
+    { NULL, NULL },
+  };
+
+  d_add_target_info_handlers (handlers);
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS linux_d_os_builtins
+
+#undef TARGET_D_REGISTER_OS_TARGET_INFO
+#define TARGET_D_REGISTER_OS_TARGET_INFO linux_d_register_target_info
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
index 74f70793d90d5f4ff82bbddc0fac6360280b93c1..d1d6753a2f629b8aeb1cc46d67f1aff7bd851c7e 100644 (file)
@@ -58,19 +58,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
        builtin_assert ("system=posix");                        \
     } while (0)
 
-#define GNU_USER_TARGET_D_OS_VERSIONS()                                \
-    do {                                                       \
-       builtin_version ("linux");                              \
-       if (OPTION_GLIBC)                                       \
-         builtin_version ("CRuntime_Glibc");                   \
-       else if (OPTION_UCLIBC)                                 \
-         builtin_version ("CRuntime_UClibc");                  \
-       else if (OPTION_BIONIC)                                 \
-         builtin_version ("CRuntime_Bionic");                  \
-       else if (OPTION_MUSL)                                   \
-         builtin_version ("CRuntime_Musl");                    \
-    } while (0)
-
 /* Determine which dynamic linker to use depending on whether GLIBC or
    uClibc or Bionic or musl is the default C library and whether
    -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
index cf7713b16ea1295fdb942c4cff5addc6cdcee5e1..b29f4aa3a0e6f0a4f4e443cfdb425249431bc9c8 100644 (file)
@@ -27,9 +27,6 @@ along with GCC; see the file COPYING3.  If not see
     ANDROID_TARGET_OS_CPP_BUILTINS();                          \
   } while (0)
 
-#define EXTRA_TARGET_D_OS_VERSIONS()                           \
-  ANDROID_TARGET_D_OS_VERSIONS();
-
 #undef  LINK_SPEC
 #define LINK_SPEC                                                      \
   LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC,                      \
index c8b7d4e524bcdb4547181dae167b54fe053aee84..f26c37a48ac163c57af8c061e4e190251ec280c2 100644 (file)
@@ -20,6 +20,14 @@ glibc-c.o: config/glibc-c.cc
        $(COMPILE) $<
        $(POSTCOMPILE)
 
-glibc-d.o: config/glibc-d.cc
+gnu-d.o: config/gnu-d.cc
+       $(COMPILE) $<
+       $(POSTCOMPILE)
+
+kfreebsd-d.o: config/kfreebsd-d.cc
+       $(COMPILE) $<
+       $(POSTCOMPILE)
+
+kopensolaris-d.o: config/kopensolaris-d.cc
        $(COMPILE) $<
        $(POSTCOMPILE)
index d9bc9b8c9bfb6db868758e3dd12159b60957b7ea..830b9871b837e219787bdf5f854efa677f962d4c 100644 (file)
@@ -19,3 +19,7 @@
 linux.o: $(srcdir)/config/linux.cc
          $(COMPILE) $<
          $(POSTCOMPILE)
+
+linux-d.o: $(srcdir)/config/linux-d.cc
+         $(COMPILE) $<
+         $(POSTCOMPILE)