nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]

This is still not properly resolving <https://gcc.gnu.org/PR85463>
'[nvptx] "exit" in offloaded region doesn't terminate process', but is
one step into that direction, and allows for simplifying some GCC code.
This commit is contained in:
Thomas Schwinge 2023-01-19 18:24:50 +01:00
parent 29b137af80
commit 05a2d7a8b3
1 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,7 @@
*/
#include <unistd.h>
#include <stdlib.h>
/* Sadly, PTX doesn't support weak declarations, only weak
definitions. Weakly define it here in case we're not using crt0
@ -26,7 +27,15 @@ void __attribute__((noreturn))
_exit (int status)
{
if (__exitval_ptr)
*__exitval_ptr = status;
for (;;)
asm ("exit;" ::: "memory");
{
*__exitval_ptr = status;
for (;;)
asm ("exit;" ::: "memory");
}
else /* offloading */
{
/* Map to 'abort'; see <https://gcc.gnu.org/PR85463>
'[nvptx] "exit" in offloaded region doesn't terminate process'. */
abort ();
}
}