Re: [PATCH] d: Remove D-specific version definitions from target headers

2022-10-24 Thread Richard Biener via Gcc-patches
On Sun, 23 Oct 2022, ibuc...@gdcproject.org wrote:

> > On 17/10/2022 20:08 CEST Iain Buclaw  wrote:
> > 
> >  
> > Hi,
> > 
> > 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 omitted or changed about.
> > 
> > There might be an open bikeshed question as to appropriate names for
> > some of the platform sources (kfreebsd-d.cc or kfreebsd-gnu-d.cc).
> > 
> > Bootstrapped and regression tested on x86_64-linux-gnu, and also built
> > i686-cygwin, i686-gnu, i686-kfreebsd-gnu, i686-kopensolaris-gnu,
> > x86_64-cygwin, x86_64-w64-mingw32 cross compilers, the dumps of all
> > predefined version identifiers remain correct in all configurations.
> > 
> > OK?
> > 
> 
> Ping?
> 
> I'll apply this tomorrow, but there is a general open question about 
> whether taking logic out of target headers and putting it in config.gcc 
> is the right approach moving forward for non C/C++ front-ends.  This is 
> also relevant for Rust, which initially put all their target support 
> definitions in headers, and have since removed the entire tangled mess 
> that created.

I think Joseph has the best guidance in these areas.  My opinion is
that things that can be done in config.gcc are fine to do there,
especially if it simplifies things or avoids problems in other
places of the compiler.

Richard.


Re: [PATCH] d: Remove D-specific version definitions from target headers

2022-10-23 Thread ibuclaw--- via Gcc-patches
> On 17/10/2022 20:08 CEST Iain Buclaw  wrote:
> 
>  
> Hi,
> 
> 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 omitted or changed about.
> 
> There might be an open bikeshed question as to appropriate names for
> some of the platform sources (kfreebsd-d.cc or kfreebsd-gnu-d.cc).
> 
> Bootstrapped and regression tested on x86_64-linux-gnu, and also built
> i686-cygwin, i686-gnu, i686-kfreebsd-gnu, i686-kopensolaris-gnu,
> x86_64-cygwin, x86_64-w64-mingw32 cross compilers, the dumps of all
> predefined version identifiers remain correct in all configurations.
> 
> OK?
> 

Ping?

I'll apply this tomorrow, but there is a general open question about whether 
taking logic out of target headers and putting it in config.gcc is the right 
approach moving forward for non C/C++ front-ends.  This is also relevant for 
Rust, which initially put all their target support definitions in headers, and 
have since removed the entire tangled mess that created.

Regards,
Iain.


[PATCH] d: Remove D-specific version definitions from target headers

2022-10-17 Thread Iain Buclaw via Gcc-patches
Hi,

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 omitted or changed about.

There might be an open bikeshed question as to appropriate names for
some of the platform sources (kfreebsd-d.cc or kfreebsd-gnu-d.cc).

Bootstrapped and regression tested on x86_64-linux-gnu, and also built
i686-cygwin, i686-gnu, i686-kfreebsd-gnu, i686-kopensolaris-gnu,
x86_64-cygwin, x86_64-w64-mingw32 cross compilers, the dumps of all
predefined version identifiers remain correct in all configurations.

OK?

Regards,
Iain.

---
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.
---
 gcc/config.gcc  | 24 +++--
 gcc/config/arm/linux-eabi.h |  3 --
 gcc/config/{glibc-d.cc => gnu-d.cc} | 30 ---
 gcc/config/gnu.h|  6 ---
 gcc/config/i386/cygwin-d.cc | 83 +
 gcc/config/i386/cygwin.h|  9 
 gcc/config/i386/linux-common.h  |  3 --
 gcc/config/i386/mingw32.h   | 12 -
 gcc/config/i386/t-cygming   |  4 ++
 gcc/config/i386/winnt-d.cc  | 10 ++--
 gcc/config/kfreebsd-d.cc| 65 ++
 gcc/config/kfreebsd-gnu.h   |  6 ---
 gcc/config/kopensolaris-d.cc| 65 ++
 gcc/config/kopensolaris-gnu.h   |  6 ---
 gcc/config/linux-android.h  |  6 ---
 gcc/config/linux-d.cc   | 78 +++
 gcc/config/linux.h  | 13 -
 gcc/config/mips/linux-common.h  |  3 --
 gcc/config/t-glibc  | 10 +++-
 gcc/config/t-linux  |  4 ++
 20 files changed, 345 insertions(+), 95 deletions(-)
 rename gcc/config/{glibc-d.cc => gnu-d.cc} (65%)
 create mode 100644 gcc/config/i386/cygwin-d.cc
 create mode 100644 gcc/config/kfreebsd-d.cc
 create mode 100644 gcc/config/kopensolaris-d.cc
 create mode 100644 gcc/config/linux-d.cc

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 2af30b4a6ec..2c9b9a06564 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -879,10 +879,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)
   ;;
@@ -891,6 +889,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"
@@ -2051,7 +2067,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;