public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH,GDC] Add netbsd support to GDC
@ 2019-01-22 16:29 Maya Rashish
  2019-01-22 19:37 ` Iain Buclaw
  0 siblings, 1 reply; 5+ messages in thread
From: Maya Rashish @ 2019-01-22 16:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: ibuclaw

libphobos/libdruntime changes were contributed upstream:
https://github.com/dlang/druntime/pull/2472
(caveat: pending a change to netbsd/execinfo.d)

One missing patch is needed for GDC to work.

gcc/config.gcc (*-*-netbsd*): add netbsd-d.o
gcc/config/t-netbsd: add netbsd-d.o

gcc/d/d-builtins.cc: add NetBSD
gcc/d/d-system.h: NetBSD is POSIX
gcc/d/dmd/globals.h: add isNetBSD

libphobos/configure.tgt: Mark netbsd/x86 as supported

---
 gcc/config.gcc          | 2 ++
 gcc/config/t-netbsd     | 4 ++++
 gcc/d/d-builtins.cc     | 2 ++
 gcc/d/d-system.h        | 3 ++-
 gcc/d/dmd/globals.h     | 1 +
 libphobos/configure.tgt | 2 ++
 6 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index a189cb19f63..c5d3044b017 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -839,6 +839,7 @@ case ${target} in
   tm_p_file="${tm_p_file} netbsd-protos.h"
   tmake_file="t-netbsd t-slibgcc"
   extra_objs="${extra_objs} netbsd.o"
+  d_target_objs="${d_target_objs} netbsd-d.o"
   gas=yes
   gnu_ld=yes
   use_gcc_stdint=wrap
@@ -847,6 +848,7 @@ case ${target} in
   esac
   nbsd_tm_file="netbsd.h netbsd-stdint.h netbsd-elf.h"
   default_use_cxa_atexit=yes
+  target_has_targetdm=yes
   ;;
 *-*-openbsd*)
   tmake_file="t-openbsd"
diff --git a/gcc/config/t-netbsd b/gcc/config/t-netbsd
index 4626e963ebf..716a94f86c6 100644
--- a/gcc/config/t-netbsd
+++ b/gcc/config/t-netbsd
@@ -19,3 +19,7 @@
 netbsd.o: $(srcdir)/config/netbsd.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
+
+netbsd-d.o: $(srcdir)/config/netbsd-d.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index b0a315a3ed9..ca105c7635d 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -382,6 +382,8 @@ d_add_builtin_version (const char* ident)
     global.params.isWindows = true;
   else if (strcmp (ident, "FreeBSD") == 0)
     global.params.isFreeBSD = true;
+  else if (strcmp (ident, "NetBSD") == 0)
+    global.params.isNetBSD = true;
   else if (strcmp (ident, "OpenBSD") == 0)
     global.params.isOpenBSD = true;
   else if (strcmp (ident, "Solaris") == 0)
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
index cd59b827812..c32825d4ad1 100644
--- a/gcc/d/d-system.h
+++ b/gcc/d/d-system.h
@@ -24,7 +24,8 @@
 
 /* Used by the dmd front-end to determine if we have POSIX-style IO.  */
 #define POSIX (__linux__ || __GLIBC__ || __gnu_hurd__ || __APPLE__ \
-	       || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun)
+	       || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ \
+	       || __sun)
 
 /* Forward assert invariants to gcc_assert.  */
 #undef assert
diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h
index 6c37cca3236..4fb96fecef4 100644
--- a/gcc/d/dmd/globals.h
+++ b/gcc/d/dmd/globals.h
@@ -84,6 +84,7 @@ struct Param
     bool isOSX;         // generate code for Mac OSX
     bool isWindows;     // generate code for Windows
     bool isFreeBSD;     // generate code for FreeBSD
+    bool isNetBSD;      // generate code for NetBSD
     bool isOpenBSD;     // generate code for OpenBSD
     bool isSolaris;     // generate code for Solaris
     bool hasObjectiveC; // target supports Objective-C
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 2b2a9746811..0471bfd816b 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -30,6 +30,8 @@ case "${target}" in
 	;;
   x86_64-*-linux* | i?86-*-linux*)
 	;;
+  x86_64-*-netbsd* | i?86-*-netbsd*)
+	;;
   *)
 	UNSUPPORTED=1
 	;;
-- 
2.20.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH,GDC] Add netbsd support to GDC
  2019-01-22 16:29 [PATCH,GDC] Add netbsd support to GDC Maya Rashish
@ 2019-01-22 19:37 ` Iain Buclaw
  2019-01-23  9:48   ` coypu
  0 siblings, 1 reply; 5+ messages in thread
From: Iain Buclaw @ 2019-01-22 19:37 UTC (permalink / raw)
  To: Maya Rashish; +Cc: gcc-patches

On Tue, 22 Jan 2019 at 17:29, Maya Rashish <coypu@sdf.org> wrote:
>
> libphobos/libdruntime changes were contributed upstream:
> https://github.com/dlang/druntime/pull/2472
> (caveat: pending a change to netbsd/execinfo.d)
>
> One missing patch is needed for GDC to work.
>
> gcc/config.gcc (*-*-netbsd*): add netbsd-d.o
> gcc/config/t-netbsd: add netbsd-d.o
>
> gcc/d/d-builtins.cc: add NetBSD
> gcc/d/d-system.h: NetBSD is POSIX
> gcc/d/dmd/globals.h: add isNetBSD
>
> libphobos/configure.tgt: Mark netbsd/x86 as supported
>
> ---
>  gcc/config.gcc          | 2 ++
>  gcc/config/t-netbsd     | 4 ++++
>  gcc/d/d-builtins.cc     | 2 ++
>  gcc/d/d-system.h        | 3 ++-
>  gcc/d/dmd/globals.h     | 1 +
>  libphobos/configure.tgt | 2 ++
>  6 files changed, 13 insertions(+), 1 deletion(-)
>

Thanks.

> diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
> index b0a315a3ed9..ca105c7635d 100644
> --- a/gcc/d/d-builtins.cc
> +++ b/gcc/d/d-builtins.cc
> @@ -382,6 +382,8 @@ d_add_builtin_version (const char* ident)
>      global.params.isWindows = true;
>    else if (strcmp (ident, "FreeBSD") == 0)
>      global.params.isFreeBSD = true;
> +  else if (strcmp (ident, "NetBSD") == 0)
> +    global.params.isNetBSD = true;
>    else if (strcmp (ident, "OpenBSD") == 0)
>      global.params.isOpenBSD = true;
>    else if (strcmp (ident, "Solaris") == 0)

Is this necessary?  I'd prefer to not set this field if it can be
avoided.  The same goes for the others, I intend to remove them at
soonest convenience once the problematic parts of the front-end logic
has been abstracted away.

Other than that, looks reasonable to me.

Iain.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH,GDC] Add netbsd support to GDC
  2019-01-22 19:37 ` Iain Buclaw
@ 2019-01-23  9:48   ` coypu
  2019-02-11  8:28     ` coypu
  0 siblings, 1 reply; 5+ messages in thread
From: coypu @ 2019-01-23  9:48 UTC (permalink / raw)
  To: Iain Buclaw; +Cc: gcc-patches

(Oops, added the wrong email out of habit to the first reply :-))

On Tue, Jan 22, 2019 at 08:37:25PM +0100, Iain Buclaw wrote:
> > diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
> > index b0a315a3ed9..ca105c7635d 100644
> > --- a/gcc/d/d-builtins.cc
> > +++ b/gcc/d/d-builtins.cc
> > @@ -382,6 +382,8 @@ d_add_builtin_version (const char* ident)
> >      global.params.isWindows = true;
> >    else if (strcmp (ident, "FreeBSD") == 0)
> >      global.params.isFreeBSD = true;
> > +  else if (strcmp (ident, "NetBSD") == 0)
> > +    global.params.isNetBSD = true;
> >    else if (strcmp (ident, "OpenBSD") == 0)
> >      global.params.isOpenBSD = true;
> >    else if (strcmp (ident, "Solaris") == 0)
> 
> Is this necessary?  I'd prefer to not set this field if it can be
> avoided.  The same goes for the others, I intend to remove them at
> soonest convenience once the problematic parts of the front-end logic
> has been abstracted away.
> 
> Other than that, looks reasonable to me.

It's not necessary. Here's an updated diff without it.
I also forgot to add netbsd-d.c, which is referenced in the previous
diff.

libphobos/libdruntime changes were contributed upstream:
https://github.com/dlang/druntime/pull/2472
(caveat: pending a change to netbsd/execinfo.d)

gcc/config.gcc (*-*-netbsd*): add netbsd-d.o
gcc/config/t-netbsd: add netbsd-d.o
gcc/config/netbsd-d.c: New, define Posix and NetBSD builtins for NetBSD targets

gcc/d/d-system.h: NetBSD is POSIX
libphobos/configure.tgt: Mark netbsd/x86 as supported
---
 gcc/config.gcc          |  2 ++
 gcc/config/netbsd-d.c   | 41 +++++++++++++++++++++++++++++++++++++++++
 gcc/config/t-netbsd     |  4 ++++
 gcc/d/d-system.h        |  3 ++-
 libphobos/configure.tgt |  2 ++
 5 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/netbsd-d.c

diff --git a/gcc/config.gcc b/gcc/config.gcc
index a189cb19f63..c5d3044b017 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -839,6 +839,7 @@ case ${target} in
   tm_p_file="${tm_p_file} netbsd-protos.h"
   tmake_file="t-netbsd t-slibgcc"
   extra_objs="${extra_objs} netbsd.o"
+  d_target_objs="${d_target_objs} netbsd-d.o"
   gas=yes
   gnu_ld=yes
   use_gcc_stdint=wrap
@@ -847,6 +848,7 @@ case ${target} in
   esac
   nbsd_tm_file="netbsd.h netbsd-stdint.h netbsd-elf.h"
   default_use_cxa_atexit=yes
+  target_has_targetdm=yes
   ;;
 *-*-openbsd*)
   tmake_file="t-openbsd"
diff --git a/gcc/config/netbsd-d.c b/gcc/config/netbsd-d.c
new file mode 100644
index 00000000000..8593f8bd430
--- /dev/null
+++ b/gcc/config/netbsd-d.c
@@ -0,0 +1,41 @@
+/* Functions for generic NetBSD as target machine for GNU D compiler.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+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 "tree.h"
+#include "varasm.h"
+#include "netbsd-protos.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+static void
+netbsd_d_os_builtins (void)
+{
+  d_add_builtin_version ("Posix");
+  d_add_builtin_version ("NetBSD");
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS netbsd_d_os_builtins
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
diff --git a/gcc/config/t-netbsd b/gcc/config/t-netbsd
index 4626e963ebf..716a94f86c6 100644
--- a/gcc/config/t-netbsd
+++ b/gcc/config/t-netbsd
@@ -19,3 +19,7 @@
 netbsd.o: $(srcdir)/config/netbsd.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
+
+netbsd-d.o: $(srcdir)/config/netbsd-d.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
diff --git a/gcc/d/d-system.h b/gcc/d/d-system.h
index cd59b827812..c32825d4ad1 100644
--- a/gcc/d/d-system.h
+++ b/gcc/d/d-system.h
@@ -24,7 +24,8 @@
 
 /* Used by the dmd front-end to determine if we have POSIX-style IO.  */
 #define POSIX (__linux__ || __GLIBC__ || __gnu_hurd__ || __APPLE__ \
-	       || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __sun)
+	       || __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ \
+	       || __sun)
 
 /* Forward assert invariants to gcc_assert.  */
 #undef assert
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index 2b2a9746811..0471bfd816b 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -30,6 +30,8 @@ case "${target}" in
 	;;
   x86_64-*-linux* | i?86-*-linux*)
 	;;
+  x86_64-*-netbsd* | i?86-*-netbsd*)
+	;;
   *)
 	UNSUPPORTED=1
 	;;
-- 
2.20.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH,GDC] Add netbsd support to GDC
  2019-01-23  9:48   ` coypu
@ 2019-02-11  8:28     ` coypu
  2019-02-13 21:51       ` Iain Buclaw
  0 siblings, 1 reply; 5+ messages in thread
From: coypu @ 2019-02-11  8:28 UTC (permalink / raw)
  To: Iain Buclaw; +Cc: gcc-patches

On Wed, Jan 23, 2019 at 09:35:03AM +0000, coypu@sdf.org wrote:
> > Is this necessary?  I'd prefer to not set this field if it can be
> > avoided.  The same goes for the others, I intend to remove them at
> > soonest convenience once the problematic parts of the front-end logic
> > has been abstracted away.
> > 
> > Other than that, looks reasonable to me.
> 
> It's not necessary. Here's an updated diff without it.
> I also forgot to add netbsd-d.c, which is referenced in the previous
> diff.

ping :-)
If it is good, can someone commit it? I don't have the ability to do so.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH,GDC] Add netbsd support to GDC
  2019-02-11  8:28     ` coypu
@ 2019-02-13 21:51       ` Iain Buclaw
  0 siblings, 0 replies; 5+ messages in thread
From: Iain Buclaw @ 2019-02-13 21:51 UTC (permalink / raw)
  To: Maya Rashish; +Cc: gcc-patches

On Mon, 11 Feb 2019 at 09:28, <coypu@sdf.org> wrote:
>
> On Wed, Jan 23, 2019 at 09:35:03AM +0000, coypu@sdf.org wrote:
> > > Is this necessary?  I'd prefer to not set this field if it can be
> > > avoided.  The same goes for the others, I intend to remove them at
> > > soonest convenience once the problematic parts of the front-end logic
> > > has been abstracted away.
> > >
> > > Other than that, looks reasonable to me.
> >
> > It's not necessary. Here's an updated diff without it.
> > I also forgot to add netbsd-d.c, which is referenced in the previous
> > diff.
>
> ping :-)
> If it is good, can someone commit it? I don't have the ability to do so.

Once the druntime changes have made it to the cxx branch, I'll bundle
them all together as one commit.

-- 
Iain

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-02-13 21:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-22 16:29 [PATCH,GDC] Add netbsd support to GDC Maya Rashish
2019-01-22 19:37 ` Iain Buclaw
2019-01-23  9:48   ` coypu
2019-02-11  8:28     ` coypu
2019-02-13 21:51       ` Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).