Add amdgcn support for libgfortran.

Message ID 20190607145501.23295-1-ams@codesourcery.com
State New
Headers show
Series
  • Add amdgcn support for libgfortran.
Related show

Commit Message

Andrew Stubbs June 7, 2019, 2:55 p.m.
From: Kwok Cheung Yeung <kcy@codesourcery.com>


This patch adds enough support for constructors/destructors and OS functions
to be able to link and run gfortran programs on AMD GCN.

There's no actual ability to do I/O operations on this targets, besides
"write" to stdout and stderr, so most of the functions are just stubs.
---
 newlib/configure.host              |  1 +
 newlib/libc/sys/amdgcn/Makefile.am |  3 +-
 newlib/libc/sys/amdgcn/Makefile.in | 52 ++++++++++++++++++++++++++++--
 newlib/libc/sys/amdgcn/fcntl.c     | 24 ++++++++++++++
 newlib/libc/sys/amdgcn/getpid.c    | 20 ++++++++++++
 newlib/libc/sys/amdgcn/kill.c      | 23 +++++++++++++
 newlib/libc/sys/amdgcn/open.c      | 25 ++++++++++++++
 newlib/libc/sys/amdgcn/raise.c     | 20 ++++++++++++
 newlib/libc/sys/amdgcn/stat.c      | 24 ++++++++++++++
 newlib/libc/sys/amdgcn/unlink.c    | 23 +++++++++++++
 10 files changed, 212 insertions(+), 3 deletions(-)
 create mode 100644 newlib/libc/sys/amdgcn/fcntl.c
 create mode 100644 newlib/libc/sys/amdgcn/getpid.c
 create mode 100644 newlib/libc/sys/amdgcn/kill.c
 create mode 100644 newlib/libc/sys/amdgcn/open.c
 create mode 100644 newlib/libc/sys/amdgcn/raise.c
 create mode 100644 newlib/libc/sys/amdgcn/stat.c
 create mode 100644 newlib/libc/sys/amdgcn/unlink.c

Comments

Jeff Johnston June 7, 2019, 5:56 p.m. | #1
Patch applied.

-- Jeff J.

On Fri, Jun 7, 2019 at 10:55 AM Andrew Stubbs <ams@codesourcery.com> wrote:

>

> From: Kwok Cheung Yeung <kcy@codesourcery.com>

>

> This patch adds enough support for constructors/destructors and OS

> functions

> to be able to link and run gfortran programs on AMD GCN.

>

> There's no actual ability to do I/O operations on this targets, besides

> "write" to stdout and stderr, so most of the functions are just stubs.

> ---

>  newlib/configure.host              |  1 +

>  newlib/libc/sys/amdgcn/Makefile.am |  3 +-

>  newlib/libc/sys/amdgcn/Makefile.in | 52 ++++++++++++++++++++++++++++--

>  newlib/libc/sys/amdgcn/fcntl.c     | 24 ++++++++++++++

>  newlib/libc/sys/amdgcn/getpid.c    | 20 ++++++++++++

>  newlib/libc/sys/amdgcn/kill.c      | 23 +++++++++++++

>  newlib/libc/sys/amdgcn/open.c      | 25 ++++++++++++++

>  newlib/libc/sys/amdgcn/raise.c     | 20 ++++++++++++

>  newlib/libc/sys/amdgcn/stat.c      | 24 ++++++++++++++

>  newlib/libc/sys/amdgcn/unlink.c    | 23 +++++++++++++

>  10 files changed, 212 insertions(+), 3 deletions(-)

>  create mode 100644 newlib/libc/sys/amdgcn/fcntl.c

>  create mode 100644 newlib/libc/sys/amdgcn/getpid.c

>  create mode 100644 newlib/libc/sys/amdgcn/kill.c

>  create mode 100644 newlib/libc/sys/amdgcn/open.c

>  create mode 100644 newlib/libc/sys/amdgcn/raise.c

>  create mode 100644 newlib/libc/sys/amdgcn/stat.c

>  create mode 100644 newlib/libc/sys/amdgcn/unlink.c

>

>

Patch

diff --git a/newlib/configure.host b/newlib/configure.host
index fa805d61a..87bf78a3a 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -121,6 +121,7 @@  case "${host_cpu}" in
   amdgcn*)
 	newlib_cflags="${newlib_cflags} -D__DYNAMIC_REENT__"
 	machine_dir=amdgcn
+	libc_cv_initfinit_array=yes
 	;;
   arc*)
 	machine_dir=arc
diff --git a/newlib/libc/sys/amdgcn/Makefile.am b/newlib/libc/sys/amdgcn/Makefile.am
index 171677694..2b0c63bc4 100644
--- a/newlib/libc/sys/amdgcn/Makefile.am
+++ b/newlib/libc/sys/amdgcn/Makefile.am
@@ -8,7 +8,8 @@  AM_CCASFLAGS = $(INCLUDES) $(CFLAGS)
 
 noinst_LIBRARIES = lib.a
 
-lib_a_SOURCES = close.c fstat.c isatty.c lseek.c read.c write.c
+lib_a_SOURCES = close.c fstat.c isatty.c lseek.c read.c write.c \
+                fcntl.c getpid.c kill.c open.c raise.c stat.c unlink.c
 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
 
diff --git a/newlib/libc/sys/amdgcn/Makefile.in b/newlib/libc/sys/amdgcn/Makefile.in
index dc22992e5..fd1a10b84 100644
--- a/newlib/libc/sys/amdgcn/Makefile.in
+++ b/newlib/libc/sys/amdgcn/Makefile.in
@@ -71,7 +71,11 @@  lib_a_AR = $(AR) $(ARFLAGS)
 lib_a_LIBADD =
 am_lib_a_OBJECTS = lib_a-close.$(OBJEXT) lib_a-fstat.$(OBJEXT) \
 	lib_a-isatty.$(OBJEXT) lib_a-lseek.$(OBJEXT) \
-	lib_a-read.$(OBJEXT) lib_a-write.$(OBJEXT)
+	lib_a-read.$(OBJEXT) lib_a-write.$(OBJEXT) \
+	lib_a-fcntl.$(OBJEXT) lib_a-getpid.$(OBJEXT) \
+	lib_a-kill.$(OBJEXT) lib_a-open.$(OBJEXT) \
+	lib_a-raise.$(OBJEXT) lib_a-stat.$(OBJEXT) \
+	lib_a-unlink.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
@@ -195,7 +199,9 @@  AUTOMAKE_OPTIONS = cygnus
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 AM_CCASFLAGS = $(INCLUDES) $(CFLAGS)
 noinst_LIBRARIES = lib.a
-lib_a_SOURCES = close.c fstat.c isatty.c lseek.c read.c write.c
+lib_a_SOURCES = close.c fstat.c isatty.c lseek.c read.c write.c \
+                fcntl.c getpid.c kill.c open.c raise.c stat.c unlink.c
+
 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
 lib_a_CFLAGS = $(AM_CFLAGS)
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
@@ -294,6 +300,48 @@  lib_a-write.o: write.c
 lib_a-write.obj: write.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-write.obj `if test -f 'write.c'; then $(CYGPATH_W) 'write.c'; else $(CYGPATH_W) '$(srcdir)/write.c'; fi`
 
+lib_a-fcntl.o: fcntl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fcntl.o `test -f 'fcntl.c' || echo '$(srcdir)/'`fcntl.c
+
+lib_a-fcntl.obj: fcntl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fcntl.obj `if test -f 'fcntl.c'; then $(CYGPATH_W) 'fcntl.c'; else $(CYGPATH_W) '$(srcdir)/fcntl.c'; fi`
+
+lib_a-getpid.o: getpid.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getpid.o `test -f 'getpid.c' || echo '$(srcdir)/'`getpid.c
+
+lib_a-getpid.obj: getpid.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getpid.obj `if test -f 'getpid.c'; then $(CYGPATH_W) 'getpid.c'; else $(CYGPATH_W) '$(srcdir)/getpid.c'; fi`
+
+lib_a-kill.o: kill.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-kill.o `test -f 'kill.c' || echo '$(srcdir)/'`kill.c
+
+lib_a-kill.obj: kill.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-kill.obj `if test -f 'kill.c'; then $(CYGPATH_W) 'kill.c'; else $(CYGPATH_W) '$(srcdir)/kill.c'; fi`
+
+lib_a-open.o: open.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-open.o `test -f 'open.c' || echo '$(srcdir)/'`open.c
+
+lib_a-open.obj: open.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-open.obj `if test -f 'open.c'; then $(CYGPATH_W) 'open.c'; else $(CYGPATH_W) '$(srcdir)/open.c'; fi`
+
+lib_a-raise.o: raise.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-raise.o `test -f 'raise.c' || echo '$(srcdir)/'`raise.c
+
+lib_a-raise.obj: raise.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-raise.obj `if test -f 'raise.c'; then $(CYGPATH_W) 'raise.c'; else $(CYGPATH_W) '$(srcdir)/raise.c'; fi`
+
+lib_a-stat.o: stat.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stat.o `test -f 'stat.c' || echo '$(srcdir)/'`stat.c
+
+lib_a-stat.obj: stat.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stat.obj `if test -f 'stat.c'; then $(CYGPATH_W) 'stat.c'; else $(CYGPATH_W) '$(srcdir)/stat.c'; fi`
+
+lib_a-unlink.o: unlink.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-unlink.o `test -f 'unlink.c' || echo '$(srcdir)/'`unlink.c
+
+lib_a-unlink.obj: unlink.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-unlink.obj `if test -f 'unlink.c'; then $(CYGPATH_W) 'unlink.c'; else $(CYGPATH_W) '$(srcdir)/unlink.c'; fi`
+
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
diff --git a/newlib/libc/sys/amdgcn/fcntl.c b/newlib/libc/sys/amdgcn/fcntl.c
new file mode 100644
index 000000000..b334715e8
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/fcntl.c
@@ -0,0 +1,24 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <errno.h>
+
+int fcntl (int fd,
+	   int flag,
+	   int arg)
+{
+  errno = EINVAL;
+  return -1;
+}
diff --git a/newlib/libc/sys/amdgcn/getpid.c b/newlib/libc/sys/amdgcn/getpid.c
new file mode 100644
index 000000000..5e9cb5973
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/getpid.c
@@ -0,0 +1,20 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+int
+getpid (void)
+{
+  return 0;
+}
diff --git a/newlib/libc/sys/amdgcn/kill.c b/newlib/libc/sys/amdgcn/kill.c
new file mode 100644
index 000000000..94c6843bf
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/kill.c
@@ -0,0 +1,23 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <errno.h>
+
+int kill (int pid,
+	  int sig)
+{
+  errno = ESRCH;
+  return -1;
+}
diff --git a/newlib/libc/sys/amdgcn/open.c b/newlib/libc/sys/amdgcn/open.c
new file mode 100644
index 000000000..bb2c5af17
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/open.c
@@ -0,0 +1,25 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <unistd.h>
+#include <errno.h>
+
+int
+open (const char *file,
+      int flags, ...)
+{
+  errno = EACCES;
+  return -1;
+}
diff --git a/newlib/libc/sys/amdgcn/raise.c b/newlib/libc/sys/amdgcn/raise.c
new file mode 100644
index 000000000..d5c19cd84
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/raise.c
@@ -0,0 +1,20 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+int
+raise (int sig)
+{
+  return -1;
+}
diff --git a/newlib/libc/sys/amdgcn/stat.c b/newlib/libc/sys/amdgcn/stat.c
new file mode 100644
index 000000000..710074807
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/stat.c
@@ -0,0 +1,24 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <errno.h>
+
+int
+stat (const char *file,
+     struct stat *pstat)
+{
+  errno = EACCES;
+  return -1;
+}
diff --git a/newlib/libc/sys/amdgcn/unlink.c b/newlib/libc/sys/amdgcn/unlink.c
new file mode 100644
index 000000000..059c1d57c
--- /dev/null
+++ b/newlib/libc/sys/amdgcn/unlink.c
@@ -0,0 +1,23 @@ 
+/*
+ * Support file for amdgcn in newlib.
+ * Copyright (c) 2019 Mentor Graphics.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply.
+ */
+
+#include <errno.h>
+
+int
+unlink (const char *file)
+{
+  errno = EACCES;
+  return -1;
+}