public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvptx: Don't use global constructor for SSP setup
       [not found] <ae825c453f484ffd99c9be34af726089@mentor.com>
@ 2023-01-19 21:53 ` Thomas Schwinge
  2023-01-19 21:53   ` [PATCH 2/2] nvptx: Remove newlib ELIX level 1 restriction Thomas Schwinge
  2023-01-19 21:53 ` [PATCH] nvptx: Provide stub 'getpid', 'kill', 'stat' Thomas Schwinge
  1 sibling, 1 reply; 3+ messages in thread
From: Thomas Schwinge @ 2023-01-19 21:53 UTC (permalink / raw)
  To: newlib; +Cc: tdevries, ams, Thomas Schwinge

Given that nvptx newlib currently restricts itself to ELIX level 1, this
is not already a problem.  However, in the following we'd like to lift
that restriction, and then run into:

    [...]/newlib/libc/ssp/stack_protector.c: In function ‘__stack_chk_init’:
    [...]/newlib/libc/ssp/stack_protector.c:31:1: sorry, unimplemented: global constructors not supported on this target
       31 | }
          | ^

GCC patch "nvptx: Support global constructors/destructors via 'collect2'"
has been posted, but not yet accepted.  Until that is resolved, use the
same manual SSP setup as for GCN.
---
 newlib/libc/ssp/stack_protector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libc/ssp/stack_protector.c b/newlib/libc/ssp/stack_protector.c
index cd51543f0..5e9d75f0f 100644
--- a/newlib/libc/ssp/stack_protector.c
+++ b/newlib/libc/ssp/stack_protector.c
@@ -5,8 +5,8 @@
 #include <string.h>
 #include <unistd.h>

-#if defined(__AMDGCN__)
-/* GCN does not support constructors, yet.  */
+#if defined(__AMDGCN__) || defined(__nvptx__)
+/* Global constructors not supported on this target, yet.  */
 uintptr_t __stack_chk_guard = 0x00000aff; /* 0, 0, '\n', 255  */

 #else
--
2.25.1

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

* [PATCH 2/2] nvptx: Remove newlib ELIX level 1 restriction
  2023-01-19 21:53 ` [PATCH 1/2] nvptx: Don't use global constructor for SSP setup Thomas Schwinge
@ 2023-01-19 21:53   ` Thomas Schwinge
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Schwinge @ 2023-01-19 21:53 UTC (permalink / raw)
  To: newlib; +Cc: tdevries, ams, Thomas Schwinge

Such a hard-coded ELIX level restriction is only being applied for nvptx
newlib -- but we'd actually like higher levels' functions available there,
too.  (Users continue to be able to override this via newlib 'configure',
as for every other newlib target.)

This already enables GCC test cases that currently FAIL due to
'unresolved symbol strndup' ('gcc.dg/builtin-dynamic-object-size-0.c'), or
'unresolved symbol mempcpy' ('gcc.dg/torture/pr45636.c'), for example.

Co-authored-by: Andrew Stubbs <ams@codesourcery.com>
---
 newlib/NEWS           | 1 +
 newlib/configure.host | 5 -----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/newlib/NEWS b/newlib/NEWS
index 9aa82920d..ee456f9b8 100644
--- a/newlib/NEWS
+++ b/newlib/NEWS
@@ -13,6 +13,7 @@
 - use global stdio streams for all configurations
 - use global atexit data for all configurations
 - vectorized math routines added for amdgcn platform
+- nvptx: remove newlib ELIX level 1 restriction

 *** Major changes in newlib version 4.2.0:

diff --git a/newlib/configure.host b/newlib/configure.host
index 7157877ff..0a1ba282a 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -938,11 +938,6 @@ fi
 # Target-specific defaults
 case "${host_cpu}" in
   nvptx*)
-       if [ "x${newlib_elix_level}" = "x0" ]; then
-               newlib_elix_level=1;
-       elif [ "x${newlib_elix_level}" != "x1" ]; then
-               newlib_msg_warn="nvptx does not support elix level > 1";
-       fi
        if [[ -z ${newlib_global_stdio_streams} ]]; then
                newlib_global_stdio_streams="yes";
        fi
--
2.25.1

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

* [PATCH] nvptx: Provide stub 'getpid', 'kill', 'stat'
       [not found] <ae825c453f484ffd99c9be34af726089@mentor.com>
  2023-01-19 21:53 ` [PATCH 1/2] nvptx: Don't use global constructor for SSP setup Thomas Schwinge
@ 2023-01-19 21:53 ` Thomas Schwinge
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Schwinge @ 2023-01-19 21:53 UTC (permalink / raw)
  To: newlib; +Cc: tdevries, Thomas Schwinge, Andrew Stubbs

... as implemented for GCN in 'newlib/libc/sys/amdgcn/*' files, but (for now)
still adding to the catch-all 'newlib/libc/machine/nvptx/misc.c' file.

This is necessary for the GCC/Fortran I/O system, for example.

Co-authored-by: Andrew Stubbs <ams@codesourcery.com>
---
 newlib/libc/machine/nvptx/misc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/newlib/libc/machine/nvptx/misc.c b/newlib/libc/machine/nvptx/misc.c
index 897ddc807..56e66b9f3 100644
--- a/newlib/libc/machine/nvptx/misc.c
+++ b/newlib/libc/machine/nvptx/misc.c
@@ -36,11 +36,22 @@ gettimeofday (struct timeval *tv, void *tz) {
   return -1;
 }

+int
+getpid (void) {
+  return 0;
+}
+
 int
 isatty (int fd) {
   return fd == 1;
 }

+int
+kill (int pid, int sig) {
+  errno = ESRCH;
+  return -1;
+}
+
 off_t
 lseek(int fd, off_t offset, int whence) {
   return 0;
@@ -56,6 +67,12 @@ read(int fd, void *buf, size_t count) {
   return 0;
 }

+int
+stat (const char *file, struct stat *pstat) {
+  errno = EACCES;
+  return -1;
+}
+
 void
 sync (void) {
 }
--
2.25.1

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

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

end of thread, other threads:[~2023-01-19 21:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ae825c453f484ffd99c9be34af726089@mentor.com>
2023-01-19 21:53 ` [PATCH 1/2] nvptx: Don't use global constructor for SSP setup Thomas Schwinge
2023-01-19 21:53   ` [PATCH 2/2] nvptx: Remove newlib ELIX level 1 restriction Thomas Schwinge
2023-01-19 21:53 ` [PATCH] nvptx: Provide stub 'getpid', 'kill', 'stat' Thomas Schwinge

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).