Files
Astral/patches/gcc/jinx-working-patch.patch
T

364 lines
11 KiB
Diff

diff --git gcc-clean/config.sub gcc-workdir/config.sub
index 38f3d03..ee981b0 100755
--- gcc-clean/config.sub
+++ gcc-workdir/config.sub
@@ -1749,7 +1749,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
- | fiwix* )
+ | fiwix* | astral* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff --git gcc-clean/fixincludes/mkfixinc.sh gcc-workdir/fixincludes/mkfixinc.sh
index df90720..aebfb82 100755
--- gcc-clean/fixincludes/mkfixinc.sh
+++ gcc-workdir/fixincludes/mkfixinc.sh
@@ -11,6 +11,8 @@ target=fixinc.sh
# Check for special fix rules for particular targets
case $machine in
+ *-astral* | \
+ *-*-astral* | \
i?86-*-cygwin* | \
i?86-*-mingw32* | \
x86_64-*-mingw32* | \
diff --git gcc-workdir/gcc/config/astral.h gcc-workdir/gcc/config/astral.h
new file mode 100644
index 0000000..1768e2c
--- /dev/null
+++ gcc-workdir/gcc/config/astral.h
@@ -0,0 +1,24 @@
+#undef TARGET_ASTRAL
+#define TARGET_ASTRAL 1
+
+#undef LIB_SPEC
+#define LIB_SPEC "-lc"
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{shared:-shared} %{static:-static} %{!shared: %{!static: %{rdynamic:-export-dynamic}}} %{!dynamic-linker:-dynamic-linker /usr/lib/ld.so}"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared:crt1.o%s} crti.o%s %{shared:crtbeginS.o%s;:crtbegin.o%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+ do { \
+ builtin_define ("__astral__"); \
+ builtin_define ("__unix__"); \
+ builtin_assert ("system=astral"); \
+ builtin_assert ("system=unix"); \
+ builtin_assert ("system=posix"); \
+ } while(0);
diff --git gcc-clean/gcc/config.gcc gcc-workdir/gcc/config.gcc
index a3566f5..93b4acc 100644
--- gcc-clean/gcc/config.gcc
+++ gcc-workdir/gcc/config.gcc
@@ -825,6 +825,14 @@ case ${target} in
rust_target_objs="${rust_target_objs} dragonfly-rust.o"
target_has_targetrustm=yes
;;
+*-*-astral*)
+ extra_options="$extra_options gnu-user.opt"
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ use_gcc_stdint=provide
+ thread_file='posix'
+ ;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
@@ -1189,6 +1197,9 @@ case ${target} in
esac
case ${target} in
+x86_64-*-astral*)
+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h glibc-stdint.h i386/i386elf.h i386/x86-64.h gnu-user.h astral.h"
+ ;;
aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
tm_file="${tm_file} elfos.h newlib-stdint.h"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-elf-raw.h"
diff --git gcc-clean/libatomic/configure.tgt gcc-workdir/libatomic/configure.tgt
index 4237f28..6adebf9 100644
--- gcc-clean/libatomic/configure.tgt
+++ gcc-workdir/libatomic/configure.tgt
@@ -150,6 +150,7 @@ case "${target}" in
*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
| *-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* \
+ | *-*-astral* \
| *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
| *-*-darwin* | *-*-aix* | *-*-cygwin*)
# POSIX system. The OS is supported.
diff --git gcc-clean/libgcc/config.host gcc-workdir/libgcc/config.host
index ee10e99..411a213 100644
--- gcc-clean/libgcc/config.host
+++ gcc-workdir/libgcc/config.host
@@ -784,6 +784,10 @@ i[34567]86-*-openbsd*)
;;
x86_64-*-openbsd*)
;;
+x86_64-*-astral*)
+ extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
+ ;;
i[34567]86-*-linux*)
extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
diff --git gcc-clean/libgcc/libgcov.h gcc-workdir/libgcc/libgcov.h
index 9d83a27..5315570 100644
--- gcc-clean/libgcc/libgcov.h
+++ gcc-workdir/libgcc/libgcov.h
@@ -25,6 +25,8 @@
#ifndef GCC_LIBGCOV_H
#define GCC_LIBGCOV_H
+#include <stdint.h>
+
/* work around the poisoned malloc/calloc in system.h. */
#ifndef xmalloc
#define xmalloc malloc
diff --git gcc-workdir/libgomp/config/astral/affinity.c gcc-workdir/libgomp/config/astral/affinity.c
new file mode 100644
index 0000000..8a321ec
--- /dev/null
+++ gcc-workdir/libgomp/config/astral/affinity.c
@@ -0,0 +1,2 @@
+/* Astral does not currently expose thread affinity controls. */
+#include "../../affinity.c"
diff --git gcc-workdir/libgomp/config/astral/allocator.c gcc-workdir/libgomp/config/astral/allocator.c
new file mode 100644
index 0000000..b9bbf8a
--- /dev/null
+++ gcc-workdir/libgomp/config/astral/allocator.c
@@ -0,0 +1,2 @@
+/* Astral does not currently support pinned OpenMP allocations. */
+#include "../../allocator.c"
diff --git gcc-workdir/libgomp/config/astral/futex.h gcc-workdir/libgomp/config/astral/futex.h
new file mode 100644
index 0000000..6ccd55e
--- /dev/null
+++ gcc-workdir/libgomp/config/astral/futex.h
@@ -0,0 +1,43 @@
+/* Provide target-specific access to the Astral futex system call. */
+
+#ifndef __MLIBC_ABI_ONLY
+# define __MLIBC_ABI_ONLY 1
+# define GOMP_UNDEF_MLIBC_ABI_ONLY 1
+#endif
+#include <astral/syscall.h>
+#ifdef GOMP_UNDEF_MLIBC_ABI_ONLY
+# undef GOMP_UNDEF_MLIBC_ABI_ONLY
+# undef __MLIBC_ABI_ONLY
+#endif
+
+static inline void
+astral_futex (int *addr, int op, int val)
+{
+ long ret __attribute__((unused));
+ register long error __asm ("rdx") = val;
+ register void *timeout __asm ("r10") = NULL;
+
+ __asm volatile ("syscall"
+ : "=a" (ret), "+d" (error)
+ : "0" ((long) SYSCALL_FUTEX), "D" (addr),
+ "S" ((long) (op & ~FUTEX_PRIVATE_FLAG)), "r" (timeout)
+ : "r11", "rcx", "memory");
+}
+
+static inline void
+futex_wait (int *addr, int val)
+{
+ astral_futex (addr, gomp_futex_wait, val);
+}
+
+static inline void
+futex_wake (int *addr, int count)
+{
+ astral_futex (addr, gomp_futex_wake, count);
+}
+
+static inline void
+cpu_relax (void)
+{
+ __builtin_ia32_pause ();
+}
diff --git gcc-workdir/libgomp/config/astral/lock.c gcc-workdir/libgomp/config/astral/lock.c
new file mode 100644
index 0000000..e97a658
--- /dev/null
+++ gcc-workdir/libgomp/config/astral/lock.c
@@ -0,0 +1,113 @@
+/* Astral implementation of the public OpenMP locking primitives. */
+
+#include <string.h>
+#include <unistd.h>
+#include "wait.h"
+
+/* Reuse the generic implementation in terms of gomp_mutex_t. */
+#include "../../lock.c"
+
+#ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
+strong_alias (gomp_init_lock_30, gomp_init_lock_25)
+strong_alias (gomp_destroy_lock_30, gomp_destroy_lock_25)
+strong_alias (gomp_set_lock_30, gomp_set_lock_25)
+strong_alias (gomp_unset_lock_30, gomp_unset_lock_25)
+strong_alias (gomp_test_lock_30, gomp_test_lock_25)
+
+static __thread int tid_cache;
+
+static inline int
+gomp_tid (void)
+{
+ int tid = tid_cache;
+ if (__builtin_expect (tid == 0, 0))
+ tid_cache = tid = gettid ();
+ return tid;
+}
+
+void
+gomp_init_nest_lock_25 (omp_nest_lock_25_t *lock)
+{
+ memset (lock, 0, sizeof (*lock));
+}
+
+void
+gomp_destroy_nest_lock_25 (omp_nest_lock_25_t *lock)
+{
+}
+
+void
+gomp_set_nest_lock_25 (omp_nest_lock_25_t *lock)
+{
+ int otid, tid = gomp_tid ();
+
+ while (1)
+ {
+ otid = 0;
+ if (__atomic_compare_exchange_n (&lock->owner, &otid, tid, false,
+ MEMMODEL_ACQUIRE, MEMMODEL_RELAXED))
+ {
+ lock->count = 1;
+ return;
+ }
+ if (otid == tid)
+ {
+ lock->count++;
+ return;
+ }
+ do_wait (&lock->owner, otid);
+ }
+}
+
+void
+gomp_unset_nest_lock_25 (omp_nest_lock_25_t *lock)
+{
+ if (--lock->count == 0)
+ {
+ __atomic_store_n (&lock->owner, 0, MEMMODEL_RELEASE);
+ futex_wake (&lock->owner, 1);
+ }
+}
+
+int
+gomp_test_nest_lock_25 (omp_nest_lock_25_t *lock)
+{
+ int otid, tid = gomp_tid ();
+
+ otid = 0;
+ if (__atomic_compare_exchange_n (&lock->owner, &otid, tid, false,
+ MEMMODEL_ACQUIRE, MEMMODEL_RELAXED))
+ {
+ lock->count = 1;
+ return 1;
+ }
+ if (otid == tid)
+ return ++lock->count;
+ return 0;
+}
+
+omp_lock_symver (omp_init_lock)
+omp_lock_symver (omp_destroy_lock)
+omp_lock_symver (omp_set_lock)
+omp_lock_symver (omp_unset_lock)
+omp_lock_symver (omp_test_lock)
+omp_lock_symver (omp_init_nest_lock)
+omp_lock_symver (omp_destroy_nest_lock)
+omp_lock_symver (omp_set_nest_lock)
+omp_lock_symver (omp_unset_nest_lock)
+omp_lock_symver (omp_test_nest_lock)
+
+#else
+
+ialias (omp_init_lock)
+ialias (omp_init_nest_lock)
+ialias (omp_destroy_lock)
+ialias (omp_destroy_nest_lock)
+ialias (omp_set_lock)
+ialias (omp_set_nest_lock)
+ialias (omp_unset_lock)
+ialias (omp_unset_nest_lock)
+ialias (omp_test_lock)
+ialias (omp_test_nest_lock)
+
+#endif
diff --git gcc-workdir/libgomp/config/astral/proc.c gcc-workdir/libgomp/config/astral/proc.c
new file mode 100644
index 0000000..a98e4f9
--- /dev/null
+++ gcc-workdir/libgomp/config/astral/proc.c
@@ -0,0 +1,2 @@
+/* Use the generic processor-count implementation with Astral sysconf. */
+#include "../posix/proc.c"
diff --git gcc-clean/libgomp/configure.tgt gcc-workdir/libgomp/configure.tgt
index 46af75f..112fe67 100644
--- gcc-clean/libgomp/configure.tgt
+++ gcc-workdir/libgomp/configure.tgt
@@ -129,6 +129,10 @@ fi
# Other system configury
case "${target}" in
+ x86_64-*-astral*)
+ config_path="astral linux/x86 linux posix"
+ ;;
+
*-*-hpux*)
config_path="hpux posix"
case "${target}" in
diff --git gcc-clean/libstdc++-v3/configure.ac gcc-workdir/libstdc++-v3/configure.ac
index a6525a9..6c8c322 100644
--- gcc-clean/libstdc++-v3/configure.ac
+++ gcc-workdir/libstdc++-v3/configure.ac
@@ -134,7 +134,7 @@ fi
# Use glibcxx_compiler_pic_flag to designate a compile-time flags for
# creating position-independent objects. This varies with the target
# hardware and operating system, but is often: -DPIC -fPIC.
-if test "$enable_shared" = yes; then
+if test "$enable_shared" = yes || test "${with_pic+set}" = set; then
glibcxx_lt_pic_flag="-prefer-pic"
glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX"
glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED"
diff --git gcc-clean/libstdc++-v3/crossconfig.m4 gcc-workdir/libstdc++-v3/crossconfig.m4
index b3269cb..a5d4014 100644
--- gcc-clean/libstdc++-v3/crossconfig.m4
+++ gcc-workdir/libstdc++-v3/crossconfig.m4
@@ -8,7 +8,12 @@ case "${host}" in
arm*-*-symbianelf*)
# This is a freestanding configuration; there is nothing to do here.
;;
-
+ *-astral*)
+ GLIBCXX_CHECK_COMPILER_FEATURES
+ GLIBCXX_CHECK_LINKER_FEATURES
+ GLIBCXX_CHECK_MATH_SUPPORT
+ GLIBCXX_CHECK_STDLIB_SUPPORT
+ ;;
avr*-*-*)
AC_DEFINE(HAVE_ACOSF)
AC_DEFINE(HAVE_ASINF)