gcc: fixes for cross building gcc-ada

Also add a patch to fix gcc-ada for *-musl (not yet complete).

Signed-off-by: Jürgen Buchmüller <pullmoll@t-online.de>
This commit is contained in:
Jürgen Buchmüller 2018-10-31 11:26:55 +01:00
parent ed84f26e73
commit 99958cf158
No known key found for this signature in database
GPG key ID: 6764EC32352D0647
4 changed files with 221 additions and 21 deletions

View file

@ -0,0 +1,28 @@
--- gcc/ada/link.c
+++ gcc/ada/link.c
@@ -105,9 +105,9 @@
#elif defined (__FreeBSD__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";
@@ -127,9 +127,9 @@
#elif defined (linux) || defined(__GLIBC__)
const char *__gnat_object_file_option = "-Wl,@";
-const char *__gnat_run_path_option = "-Wl,-rpath,";
-char __gnat_shared_libgnat_default = STATIC;
-char __gnat_shared_libgcc_default = STATIC;
+const char *__gnat_run_path_option = "";
+char __gnat_shared_libgnat_default = SHARED;
+char __gnat_shared_libgcc_default = SHARED;
int __gnat_link_max = 8192;
unsigned char __gnat_objlist_file_supported = 1;
const char *__gnat_object_library_extension = ".a";

View file

@ -0,0 +1,181 @@
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 3b0aea9..ee0bb69 100644
--- gcc/ada/adaint.c
+++ gcc/ada/adaint.c
@@ -76,6 +76,11 @@
#include <sys/param.h>
#include <sys/pstat.h>
#endif
+
+#if defined (linux)
+#define _GNU_SOURCE 1
+#include <sched.h>
+#endif
#ifdef __PikeOS__
#define __BSD_VISIBLE 1
@@ -3255,7 +3260,6 @@ __gnat_lwp_self (void)
#endif
#if defined (__linux__)
-#include <sched.h>
/* glibc versions earlier than 2.7 do not define the routines to handle
dynamically allocated CPU sets. For these targets, we use the static
@@ -3265,7 +3269,7 @@ __gnat_lwp_self (void)
/* Dynamic cpu sets */
-cpu_set_t *
+void *
__gnat_cpu_alloc (size_t count)
{
return CPU_ALLOC (count);
@@ -3278,33 +3282,33 @@ __gnat_cpu_alloc_size (size_t count)
}
void
-__gnat_cpu_free (cpu_set_t *set)
+__gnat_cpu_free (void *set)
{
- CPU_FREE (set);
+ CPU_FREE ((cpu_set_t *) set);
}
void
-__gnat_cpu_zero (size_t count, cpu_set_t *set)
+__gnat_cpu_zero (size_t count, void *set)
{
- CPU_ZERO_S (count, set);
+ CPU_ZERO_S (count, (cpu_set_t *) set);
}
void
-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set)
+__gnat_cpu_set (int cpu, size_t count, void *set)
{
/* Ada handles CPU numbers starting from 1, while C identifies the first
CPU by a 0, so we need to adjust. */
- CPU_SET_S (cpu - 1, count, set);
+ CPU_SET_S (cpu - 1, count, (cpu_set_t *) set);
}
#else /* !CPU_ALLOC */
/* Static cpu sets */
-cpu_set_t *
+void *
__gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED)
{
- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t));
+ return xmalloc (sizeof (cpu_set_t));
}
size_t
@@ -3314,23 +3318,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED)
}
void
-__gnat_cpu_free (cpu_set_t *set)
+__gnat_cpu_free (void *set)
{
free (set);
}
void
-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
+__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set)
{
- CPU_ZERO (set);
+ CPU_ZERO ((cpu_set_t *) set);
}
void
-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
+__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set)
{
/* Ada handles CPU numbers starting from 1, while C identifies the first
CPU by a 0, so we need to adjust. */
- CPU_SET (cpu - 1, set);
+ CPU_SET (cpu - 1, (cpu_set_t *) set);
}
#endif /* !CPU_ALLOC */
#endif /* __linux__ */
diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h
index 0d12f7e..a063b47 100644
--- gcc/ada/adaint.h
+++ gcc/ada/adaint.h
@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void);
/* Routines for interface to required CPU set primitives */
-#include <sched.h>
-
-extern cpu_set_t *__gnat_cpu_alloc (size_t);
+extern void * __gnat_cpu_alloc (size_t);
extern size_t __gnat_cpu_alloc_size (size_t);
-extern void __gnat_cpu_free (cpu_set_t *);
-extern void __gnat_cpu_zero (size_t, cpu_set_t *);
-extern void __gnat_cpu_set (int, size_t, cpu_set_t *);
+extern void __gnat_cpu_free (void *);
+extern void __gnat_cpu_zero (size_t, void *);
+extern void __gnat_cpu_set (int, size_t, void *);
#endif
#if defined (_WIN32)
diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c
index 7025f57..207b50d 100644
--- gcc/ada/terminals.c
+++ gcc/ada/terminals.c
@@ -1108,13 +1108,6 @@ __gnat_setup_winsize (void *desc, int rows, int columns)
#include <stdio.h>
#include <stdlib.h>
-/* On some system termio is either absent or including it will disable termios
- (HP-UX) */
-#if !defined (__hpux__) && !defined (BSD) && !defined (__APPLE__) \
- && !defined (__rtems__) && !defined (__QNXNTO__)
-# include <termio.h>
-#endif
-
#include <sys/ioctl.h>
#include <termios.h>
#include <fcntl.h>
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index ebb955e..08cfbee 100644
--- gcc/ada/gcc-interface/Makefile.in
+++ gcc/ada/gcc-interface/Makefile.in
@@ -1574,7 +1574,7 @@ ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),)
endif
# ARM linux, GNU eabi
-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
+ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),)
LIBGNAT_TARGET_PAIRS = \
a-intnam.ads<libgnarl/a-intnam__linux.ads \
s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c
index 207b50d..bd3a02c 100644
--- gcc/ada/terminals.c
+++ gcc/ada/terminals.c
@@ -1152,7 +1152,7 @@ __gnat_setup_winsize (void *desc, int rows, int columns)
#if defined (__APPLE__) || defined (BSD)
#define USE_OPENPTY
#elif defined (__linux__)
-#define USE_GETPT
+#define USE_POSIX_OPENPT
#elif defined (__sun__)
#define USE_CLONE_DEVICE "/dev/ptmx"
#elif defined (_AIX)
@@ -1201,8 +1201,8 @@ allocate_pty_desc (pty_desc **desc) {
int master_fd = -1;
char *slave_name = NULL;
-#ifdef USE_GETPT
- master_fd = getpt ();
+#ifdef USE_POSIX_OPENPT
+ master_fd = posix_openpt(O_RDWR | O_NOCTTY);
#elif defined (USE_OPENPTY)
status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL);
#elif defined (USE_CLONE_DEVICE)

View file

@ -1,13 +0,0 @@
--- gcc/ada/terminals.c 2018-01-11 09:55:25.000000000 +0100
+++ gcc/ada/terminals.c 2018-10-29 12:53:43.278136221 +0100
@@ -1110,8 +1110,8 @@
/* On some system termio is either absent or including it will disable termios
(HP-UX) */
-#if !defined (__hpux__) && !defined (BSD) && !defined (__APPLE__) \
- && !defined (__rtems__) && !defined (__QNXNTO__)
+#if defined (__GLIBC__) && !defined (__hpux__) && !defined (BSD) \
+ && !defined (__APPLE__) && !defined (__rtems__) && !defined (__QNXNTO__)
# include <termio.h>
#endif

View file

@ -64,7 +64,13 @@ if [ "$build_option_gnatboot" ]; then
;;
esac
fi
if [ -n "$CHROOT_READY" ]; then
subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
subpackages+=" gcc-ada libada-devel libada"
fi
if [ "$CHROOT_READY" ]; then
subpackages+=" gcc-fortran libgfortran-devel libgfortran"
if [ -z "$CROSS_BUILD" ]; then
subpackages+=" gcc-objc gcc-objc++ libobjc-devel libobjc"
@ -77,11 +83,6 @@ if [ -n "$CHROOT_READY" ]; then
fi
fi
subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
subpackages+=" gcc-ada libada-devel libada"
fi
case "$XBPS_TARGET_MACHINE" in
i686) _triplet="i686-pc-linux-gnu";;
i686-musl) _triplet="i686-linux-musl";;
@ -118,9 +119,12 @@ case "$XBPS_TARGET_MACHINE" in
x86_64*|i686) subpackages+=" libitm libitm-devel libmpx libmpx-devel";;
*) subpackages+=" libitm libitm-devel";;
esac
if [ -n "$CROSS_BUILD" ]; then
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cross-${_triplet}"
export GFORTRAN_FOR_TARGET=" ${_triplet}-gfortran"
if [ "$build_option_ada" ]; then
hostmakedepends+=" gcc-ada libada-devel"
fi
fi
post_extract() {
@ -176,7 +180,7 @@ do_configure() {
_langs="c,c++,lto"
fi
if [ -n "$CROSS_BUILD" ]; then
if [ "$CROSS_BUILD" ]; then
export CC_FOR_TARGET="$CC"
export GCC_FOR_TARGET="$CC"
export CXX_FOR_TARGET="$CXX"