aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/403-dlang-ibmz.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/gcc/403-dlang-ibmz.patch')
-rw-r--r--main/gcc/403-dlang-ibmz.patch137
1 files changed, 137 insertions, 0 deletions
diff --git a/main/gcc/403-dlang-ibmz.patch b/main/gcc/403-dlang-ibmz.patch
new file mode 100644
index 00000000000..f6f9a2ce0ca
--- /dev/null
+++ b/main/gcc/403-dlang-ibmz.patch
@@ -0,0 +1,137 @@
+diff -Nurp a/libphobos/libdruntime/gcc/sections/elf_shared.d b/libphobos/libdruntime/gcc/sections/elf_shared.d
+--- a/libphobos/libdruntime/gcc/sections/elf_shared.d 2020-01-01 00:00:00.000000000 +0900
++++ b/libphobos/libdruntime/gcc/sections/elf_shared.d 2020-01-01 00:00:00.000000000 +0900
+@@ -1084,7 +1084,9 @@ void[] getTLSRange(size_t mod, size_t sz) nothrow @nogc
+
+ // base offset
+ auto ti = tls_index(mod, 0);
+- version (IBMZ_Any)
++ version (CRuntime_Musl)
++ return (__tls_get_addr(&ti)-TLS_DTV_OFFSET)[0 .. sz];
++ else version (IBMZ_Any)
+ {
+ auto idx = cast(void *)__tls_get_addr_internal(&ti)
+ + cast(ulong)__builtin_thread_pointer();
+diff -Nurp a/libphobos/configure.ac b/libphobos/configure.ac
+--- a/libphobos/configure.ac 2020-01-01 00:00:00.000000000 +0900
++++ b/libphobos/configure.ac 2020-01-01 00:00:00.000000000 +0900
+@@ -140,6 +140,14 @@ case ${host} in
+ esac
+ AC_MSG_RESULT($LIBPHOBOS_SUPPORTED)
+
++AC_MSG_CHECKING([if target needs to link in swapcontext])
++AC_MSG_RESULT($LIBDRUNTIME_NEEDS_UCONTEXT)
++AS_IF([test "x$LIBDRUNTIME_NEEDS_UCONTEXT" = xyes], [
++ AC_SEARCH_LIBS([swapcontext], [c ucontext], [], [
++ AC_MSG_ERROR([[can't find library providing swapcontext]])
++ ])
++])
++
+ # Decide if it's usable.
+ case $LIBPHOBOS_SUPPORTED:$enable_libphobos in
+ *:no) use_libphobos=no ;;
+diff -Nurp a/libphobos/configure.tgt b/libphobos/configure.tgt
+--- a/libphobos/configure.tgt 2020-01-01 00:00:00.000000000 +0900
++++ b/libphobos/configure.tgt 2020-01-01 00:00:00.000000000 +0900
+@@ -22,6 +22,13 @@
+ # Disable the libphobos or libdruntime components on untested or known
+ # broken systems. More targets shall be added after testing.
+ LIBPHOBOS_SUPPORTED=no
++
++# Check if we require 'ucontext' or if we have a custom solution.
++# Most platform uses a custom assembly solution for context switches,
++# see `core.thread` and grep for `AsmExternal`.
++# Definitions are in config/ARCH/
++LIBPHOBOS_NEEDS_UCONTEXT=no
++
+ case "${target}" in
+ aarch64*-*-linux*)
+ LIBPHOBOS_SUPPORTED=yes
+@@ -37,6 +44,7 @@ case "${target}" in
+ ;;
+ s390*-linux*)
+ LIBPHOBOS_SUPPORTED=yes
++ LIBDRUNTIME_NEEDS_UCONTEXT=yes
+ ;;
+ x86_64-*-kfreebsd*-gnu | i?86-*-kfreebsd*-gnu)
+ LIBPHOBOS_SUPPORTED=yes
+diff -Nurp a/libphobos/configure b/libphobos/configure
+--- a/libphobos/configure 2020-01-01 00:00:00.000000000 +0900
++++ b/libphobos/configure 2020-01-01 00:00:00.000000000 +0900
+@@ -13955,6 +13955,76 @@ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBPHOBOS_SUPPORTED" >&5
+ $as_echo "$LIBPHOBOS_SUPPORTED" >&6; }
+
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if target needs to link in swapcontext" >&5
++$as_echo_n "checking if target needs to link in swapcontext... " >&6; }
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBDRUNTIME_NEEDS_UCONTEXT" >&5
++$as_echo "$LIBDRUNTIME_NEEDS_UCONTEXT" >&6; }
++if test "x$LIBDRUNTIME_NEEDS_UCONTEXT" = xyes; then :
++
++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing swapcontext" >&5
++$as_echo_n "checking for library containing swapcontext... " >&6; }
++if ${ac_cv_search_swapcontext+:} false; then :
++ $as_echo_n "(cached) " >&6
++else
++ ac_func_search_save_LIBS=$LIBS
++cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++
++/* Override any GCC internal prototype to avoid an error.
++ Use char because int might match the return type of a GCC
++ builtin and then its argument prototype would still apply. */
++#ifdef __cplusplus
++extern "C"
++#endif
++char swapcontext ();
++int
++main ()
++{
++return swapcontext ();
++ ;
++ return 0;
++}
++_ACEOF
++for ac_lib in '' c ucontext; do
++ if test -z "$ac_lib"; then
++ ac_res="none required"
++ else
++ ac_res=-l$ac_lib
++ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
++ fi
++ if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_search_swapcontext=$ac_res
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext
++ if ${ac_cv_search_swapcontext+:} false; then :
++ break
++fi
++done
++if ${ac_cv_search_swapcontext+:} false; then :
++
++else
++ ac_cv_search_swapcontext=no
++fi
++rm conftest.$ac_ext
++LIBS=$ac_func_search_save_LIBS
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_swapcontext" >&5
++$as_echo "$ac_cv_search_swapcontext" >&6; }
++ac_res=$ac_cv_search_swapcontext
++if test "$ac_res" != no; then :
++ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
++
++else
++
++ as_fn_error $? "can't find library providing swapcontext" "$LINENO" 5
++
++fi
++
++
++fi
++
++
+ # Decide if it's usable.
+ case $LIBPHOBOS_SUPPORTED:$enable_libphobos in
+ *:no) use_libphobos=no ;;