[PATCH,GDC] Add netbsd support to GDC
coypu@sdf.org
coypu@sdf.org
Wed Jan 23 09:48:00 GMT 2019
(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
More information about the Gcc-patches
mailing list