summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarino <marino@pkgsrc.org>2011-10-05 18:11:55 +0000
committermarino <marino@pkgsrc.org>2011-10-05 18:11:55 +0000
commit098008a5a356c86745f39531ae772d3b0c0d9b88 (patch)
treea6a7c738ce5ee04b5adb70a6e23b873e6615bc1e
parenta687bf707dd58ee5decdc805500c9b8c06c4202f (diff)
downloadpkgsrc-098008a5a356c86745f39531ae772d3b0c0d9b88.tar.gz
Add x86-Solaris and symbolic traceback support
This changeset addresses several things: 1) Adds support for x86-Solaris (Namely OpenIndiana) 2) Properly implements run-time symbolic traceback support 3) Arranges makefile so patches can be handled in a standard fashion 4) Properly implements MAKE_JOBS which reduces build times by 66%+ on the quad-core test machine (30 minutes down to < 10 minutes)
-rw-r--r--lang/gnat-aux/Makefile64
-rw-r--r--lang/gnat-aux/distinfo8
-rw-r--r--lang/gnat-aux/patches/patch-aa287
-rw-r--r--lang/gnat-aux/patches/patch-ab155
-rw-r--r--lang/gnat-aux/patches/patch-ac111
5 files changed, 599 insertions, 26 deletions
diff --git a/lang/gnat-aux/Makefile b/lang/gnat-aux/Makefile
index c032ce4e12f..1289d464e70 100644
--- a/lang/gnat-aux/Makefile
+++ b/lang/gnat-aux/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.5 2011/07/18 09:27:25 drochner Exp $
+# $NetBSD: Makefile,v 1.6 2011/10/05 18:11:55 marino Exp $
#
DISTNAME= gnat-aux-${SNAPSHOT}
+PKGREVISION= 1
CATEGORIES= lang
MASTER_SITES= http://downloads.dragonlace.net/src/ \
http://dragonlace.mirrors.ada.cx/src/
@@ -32,7 +33,8 @@ BUILD_DEPENDS+= autoconf>=2.6:../../devel/autoconf
ONLY_FOR_PLATFORM= DragonFly-*-* \
NetBSD-[5-9]*-i386 \
- NetBSD-[5-9]*-x86_64
+ NetBSD-[5-9]*-x86_64 \
+ SunOS-5.*-i386
BLD_TARGET= ${MACHINE_ARCH}-aux-${LOWER_OPSYS}${OS_VERSION}
THREAD_MODEL= posix
@@ -81,33 +83,44 @@ LINK_HEADER= /usr/include/link_elf.h
.endif
+.if ${OPSYS} == "SunOS"
+.if ${MACHINE_ARCH} == "i386"
+ OS_LABEL4VERS= [Solaris]
+ BOOTSTRAP_TRIPLET= i386-bootstrap-solaris5.11/4.6.1
+.endif
+SOL_OSV= `expr substr ${OS_VERSION} 3 2`
+BLD_TARGET= ${MACHINE_ARCH}-aux-${LOWER_OPSYS}2.${SOL_OSV}
+BOOTSTRAP_COMPILER= gnat-bootstrap.${MACHINE_ARCH}.solaris.tar.bz2
+.endif
+
+
# Let's build this without bash
CONFIG_SHELL= ${TOOLS_PATH.sh}
# define some important directories and files
-WRKSRC= ${WRKDIR}/build
-GCC_WRKSRC= ${WRKDIR}/gcc-${GCC_BRANCH}-${SNAPSHOT}
+BUILDDIR= ${WRKDIR}/build
+WRKSRC= ${WRKDIR}/gcc-${GCC_BRANCH}-${SNAPSHOT}
PKG_PREFIX= ${PREFIX}
-CONFIGURE_SCRIPT= ${GCC_WRKSRC}/configure
+CFG_SCRIPT= ${WRKSRC}/configure
BOOTSTRAP_PREFIX= ${WRKDIR}/bootstrap
MAN7= fsf-funding.7 gfdl.7 gpl.7
SMAN1= share/man/man1
SMAN7= share/man/man7
LPATH= lib/gcc/${BLD_TARGET}/${GCC_BRANCH}.${GCC_POINT}
LEPATH= libexec/gcc/${BLD_TARGET}/${GCC_BRANCH}.${GCC_POINT}
-REVFILE= ${GCC_WRKSRC}/gcc/REVISION
+REVFILE= ${WRKSRC}/gcc/REVISION
BASELIB= ${LOCALBASE}/lib
# testing if gnatgcc, gnatlink, gnatbind and gnatmake are in standard location
# exists function will NOT expand any variable, so it has to be hard-coded
-.if exists(/usr/pkg/bin/gnatgcc)
-.if exists(/usr/pkg/bin/gnatbind)
-.if exists(/usr/pkg/bin/gnatlink)
-.if exists(/usr/pkg/bin/gnatmake)
+.if exists(/usr/pkg/bin/gnatgcc) || exists(/opt/ipp/pkg/bin/gnatgcc)
+.if exists(/usr/pkg/bin/gnatbind) || exists(/opt/ipp/pkg/bin/gnatbind)
+.if exists(/usr/pkg/bin/gnatlink) || exists(/opt/ipp/pkg/bin/gnatlink)
+.if exists(/usr/pkg/bin/gnatmake) || exists(/opt/ipp/pkg/bin/gnatmake)
FULL_GNATGCC=${PREFIX}/bin/gnatgcc
.endif #gnatmake
.endif #gnatlink
@@ -129,7 +142,8 @@ FULL_PATH=${BOOTSTRAP_PREFIX}/bin:/sbin:/bin:/usr/sbin:/usr/bin:${PREFIX}/sbin:$
# gnat-bootstrap.i386.dragonfly.tar.bz2 \
# gnat-bootstrap.x86_64.dragonfly.tar.bz2 \
# gnat-bootstrap.i386.netbsd.tar.bz2 \
-# gnat-bootstrap.x86_64.netbsd.tar.bz2
+# gnat-bootstrap.x86_64.netbsd.tar.bz2 \
+# gnat-bootstrap.i386.solaris.tar.bz2
# establish ada-aware compiler for use
@@ -137,7 +151,7 @@ MY_CONFIGURE_ENV= CC=${FULL_GNATGCC}
MY_CONFIGURE_ENV+= PATH=${FULL_PATH}
MY_CONFIGURE_ENV+= CONFIG_SHELL=${CONFIG_SHELL}
MY_MAKE_ENV= PATH=${FULL_PATH}
-MY_MAKE_ENV+= LD_LIBRARY_PATH=${WRKSRC}/gcc
+MY_MAKE_ENV+= LD_LIBRARY_PATH=${BUILDDIR}/gcc
# The standard configuration options
@@ -241,17 +255,17 @@ do-configure:
${SETENV} CC=${FULL_GNATGCC}
#reset timestamps
- cd ${GCC_WRKSRC}; contrib/gcc_update --touch
- ${RM} -f ${GCC_WRKSRC}/gcc/*/*.info*
- ${TOUCH} ${GCC_WRKSRC}/gcc/cstamp-h.in
+ cd ${WRKSRC}; contrib/gcc_update --touch
+ ${RM} -f ${WRKSRC}/gcc/*/*.info*
+ ${TOUCH} ${WRKSRC}/gcc/cstamp-h.in
- ${MKDIR} ${WRKSRC}
- cd ${WRKSRC} && ${SETENV} ${MY_CONFIGURE_ENV} ${CONFIG_SHELL} \
- ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
+ ${MKDIR} ${BUILDDIR}
+ cd ${BUILDDIR} && ${SETENV} ${MY_CONFIGURE_ENV} \
+ ${CFG_SCRIPT} ${CONFIGURE_ARGS}
do-build:
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} all ${MAKE_ARGS}
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -j${MAKE_JOBS:U1:Q} all
do-test: build
@@ -259,24 +273,24 @@ do-test: build
.if (${OPSYS} == "NetBSD") && (${MACHINE_ARCH} == "x86_64")
#NetBSD has an exremely small default stacksize of 2MB, which is insufficient
#for the gnat.dg testsuite (entry_queues test on AMD64 specifically)
- cd ${WRKSRC} && \
+ cd ${BUILDDIR} && \
${ULIMIT_CMD_stacksize} && \
${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
.else
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-ada
.endif
.endif
.if !empty(PKG_OPTIONS:Mtestcxx)
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c++
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-target-libstdc++-v3
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c++
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-target-libstdc++-v3
.endif
.if !empty(PKG_OPTIONS:Mtestgcc)
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} -sk check-c
.endif
do-install:
- cd ${WRKSRC} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} install-strip \
+ cd ${BUILDDIR} && ${SETENV} ${MY_MAKE_ENV} ${GMAKE} install-strip \
DESTDIR=${DESTDIR}
diff --git a/lang/gnat-aux/distinfo b/lang/gnat-aux/distinfo
index d49a66275d0..bbd8f48a25b 100644
--- a/lang/gnat-aux/distinfo
+++ b/lang/gnat-aux/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.4 2011/07/18 09:27:25 drochner Exp $
+$NetBSD: distinfo,v 1.5 2011/10/05 18:11:55 marino Exp $
SHA1 (gnat-aux-20110627.tar.bz2) = 598d2c21c3bbd1e2cada2ca98331107af3deb608
RMD160 (gnat-aux-20110627.tar.bz2) = 84b05832457568fef9355279214caeacca9c74ba
@@ -15,3 +15,9 @@ Size (gnat-bootstrap.x86_64.dragonfly.tar.bz2) = 31380342 bytes
SHA1 (gnat-bootstrap.x86_64.netbsd.tar.bz2) = 84f0e9179998daa643046a5d139321c4130ea84d
RMD160 (gnat-bootstrap.x86_64.netbsd.tar.bz2) = 0b2943349536c323a62b56dc05ff1fedd6d7e17a
Size (gnat-bootstrap.x86_64.netbsd.tar.bz2) = 30572187 bytes
+SHA1 (gnat-bootstrap.i386.solaris.tar.bz2) = 4962657bfc894a20ad3102c1f6fe8e566b47cb51
+RMD160 (gnat-bootstrap.i386.solaris.tar.bz2) = ae72e76d0aba94451d99b9a70a3c049c9258cc82
+Size (gnat-bootstrap.i386.solaris.tar.bz2) = 43247034 bytes
+SHA1 (patch-aa) = 8a6199bb91fa1051db7af154e6995c116da71e63
+SHA1 (patch-ab) = 76cff68f5f697ed5aacd41d06bbb4d9a805e9d91
+SHA1 (patch-ac) = f8a73fc95b9119ae75b64a5578b94be6dbccb837
diff --git a/lang/gnat-aux/patches/patch-aa b/lang/gnat-aux/patches/patch-aa
new file mode 100644
index 00000000000..611e582a9e0
--- /dev/null
+++ b/lang/gnat-aux/patches/patch-aa
@@ -0,0 +1,287 @@
+$NetBSD: patch-aa,v 1.1 2011/10/05 18:11:55 marino Exp $
+
+--- gcc/ada/adaint.c.orig 2011-07-15 08:08:10.000000000 +0200
++++ gcc/ada/adaint.c 2011-10-03 00:43:37.392616438 +0200
+@@ -1201,6 +1201,47 @@
+ free (pname);
+ }
+
++#elif defined (__ANDROID__)
++
++ /*
++ * ext2 /ext3/ext4/fat16/fat32 have no path limits
++ * /data/local/tmp normally requires rooted devices, if it even exists
++ * /sdcard is the standard location for external storage. Nativeactivity
++ * manifest needs to authorize its use, otherwise it might not have the
++ * proper permissions.
++ */
++
++ int testfd;
++ char *datadir = getenv ("ANDROID_DATA");
++
++ if (datadir == NULL)
++ strcpy (tmp_filename, "/data/local/tmp/gnat-XXXXXX");
++ else
++ sprintf (tmp_filename, "%s/local/tmp/gnat-XXXXXX", datadir);
++
++ testfd = mkstemp (tmp_filename);
++ if (testfd != -1)
++ {
++ close (testfd);
++ return;
++ }
++
++ char *sdcard = getenv ("EXTERNAL_STORAGE");
++
++ if (sdcard == NULL)
++ strcpy (tmp_filename, "/sdcard/gnat-XXXXXX");
++ else
++ sprintf (tmp_filename, "%s/gnat-XXXXXX", sdcard);
++
++ testfd = mkstemp (tmp_filename);
++ if (testfd != -1)
++ {
++ close (testfd);
++ return;
++ }
++
++ tmpnam (tmp_filename);
++
+ #elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \
+ || defined (__DragonFly__) \
+ || defined (__OpenBSD__) || defined(__GLIBC__)
+@@ -3433,26 +3474,214 @@
+ }
+ #endif
+
+-#if defined (IS_CROSS) \
+- || (! ((defined (sparc) || defined (i386)) && defined (sun) \
+- && defined (__SVR4)) \
+- && ! (defined (linux) && (defined (i386) || defined (__x86_64__))) \
+- && ! (defined (linux) && defined (__ia64__)) \
+- && ! (defined (linux) && defined (powerpc)) \
+- && ! defined (__FreeBSD__) \
+- && ! defined (__DragonFly__) \
+- && ! defined (__Lynx__) \
+- && ! defined (__hpux__) \
+- && ! defined (__APPLE__) \
+- && ! defined (_AIX) \
+- && ! (defined (__alpha__) && defined (__osf__)) \
+- && ! defined (VMS) \
+- && ! defined (__MINGW32__) \
+- && ! (defined (__mips) && defined (__sgi)))
+-
+-/* Dummy function to satisfy g-trasym.o. See the preprocessor conditional
+- just above for a list of native platforms that provide a non-dummy
+- version of this procedure in libaddr2line.a. */
++/* run-time symbolic traceback support */
++#if defined (__DragonFly__) \
++ || defined (__FreeBSD__) \
++ || defined (__OpenBSD__) \
++ || defined (__NetBSD__) \
++ || (defined (__sun__) && defined (__i386__) && defined (__SVR4))
++
++/* The above platforms use the external program /usr/bin/addr2line */
++#define EXTERNAL_SYMTRACE
++
++#elif defined (VMS) \
++ || defined (_AIX) \
++ || defined (__Lynx__) \
++ || defined (__hpux__) \
++ || defined (__APPLE__) \
++ || defined (__MINGW32__) \
++ || (defined (__mips) && defined (__sgi)) \
++ || (defined (__alpha__) && defined (__osf__)) \
++ || (defined (linux) && defined (i386)) \
++ || (defined (linux) && defined (powerpc)) \
++ || (defined (linux) && defined (__ia64__)) \
++ || (defined (linux) && defined (__x86_64__)) \
++ || (defined (__SVR4) && defined (__sun__) && defined (sparc))
++
++/* The above platforms use the system library libaddr2line.a */
++#define NATIVE_SYMTRACE
++#endif
++
++#if defined (EXTERNAL_SYMTRACE) && !defined (IS_CROSS)
++
++/*
++ Copyright (C) 1999 by Juergen Pfeifer <juergen.pfeifer@gmx.net>
++ Ada for Linux Team (ALT)
++ Heavily modified by John Marino <http://www.dragonlace.net>
++
++ Permission is hereby granted, free of charge, to any person obtaining a
++ copy of this software and associated documentation files (the
++ "Software"), to deal in the Software without restriction, including
++ without limitation the rights to use, copy, modify, merge, publish,
++ distribute, distribute with modifications, sublicense, and/or sell
++ copies of the Software, and to permit persons to whom the Software is
++ furnished to do so, subject to the following conditions:
++
++ The above copyright notice and this permission notice shall be included
++ in all copies or substantial portions of the Software.
++
++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++ IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
++ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
++ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
++ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++
++ Except as contained in this notice, the name(s) of the above copyright
++ holders shall not be used in advertising or otherwise to promote the
++ sale, use or other dealings in this Software without prior written
++ authorization.
++*/
++
++#include <sys/types.h>
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include <signal.h>
++
++#define CLOSE_SENDPIPE close(sendpipe[0]); close(sendpipe[1])
++#define CLOSE_READPIPE close(readpipe[0]); close(readpipe[1])
++#define DUP2CLOSE(oldfd, newfd) dup2(oldfd, newfd); close(oldfd);
++#define RESTSIG sigaction(SIGPIPE,&oact,NULL)
++
++#define MAX_LINE 1024
++#define PARENT_READ readpipe[0]
++#define CHILD_WRITE readpipe[1]
++#define CHILD_READ sendpipe[0]
++#define PARENT_WRITE sendpipe[1]
++
++#if defined(__sun__)
++#define ADDR2LINE_PROG "/usr/gnu/bin/addr2line"
++#else
++#define ADDR2LINE_PROG "/usr/bin/addr2line"
++#endif
++
++void
++convert_addresses (const char *file_name,
++ void *addrs,
++ int n_addr,
++ void *buf,
++ int *len)
++{
++ int max_len = *len;
++ pid_t childpid;
++
++ struct sigaction act, oact;
++
++ int sendpipe[2] = {-1,-1}, /* parent -> child */
++ readpipe[2] = {-1,-1}; /* parent <- child */
++
++ *len = 0;
++ act.sa_handler = SIG_IGN;
++ sigemptyset(&act.sa_mask);
++ act.sa_flags = 0;
++ if (sigaction(SIGPIPE,&act,&oact) < 0)
++ return;
++
++ if (pipe(sendpipe) < 0) { RESTSIG; return; }
++ if (pipe(readpipe) < 0) { CLOSE_SENDPIPE; RESTSIG; return; }
++ if ((childpid = fork()) < 0) {
++ CLOSE_READPIPE;
++ CLOSE_SENDPIPE;
++ RESTSIG;
++ return;
++ }
++
++ if (childpid == 0) { /* child process */
++ close(PARENT_WRITE);
++ close(PARENT_READ);
++ if ((CHILD_READ != STDIN_FILENO) && (CHILD_WRITE != STDOUT_FILENO)) {
++ if ((CHILD_READ == STDOUT_FILENO) && (CHILD_WRITE == STDIN_FILENO)) {
++ const int temp_fd = dup(CHILD_WRITE);
++ close (CHILD_WRITE);
++ DUP2CLOSE (CHILD_READ, STDIN_FILENO);
++ DUP2CLOSE (temp_fd, STDOUT_FILENO);
++ }
++ else if ((CHILD_READ == STDIN_FILENO) && (CHILD_WRITE > 1)) {
++ DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
++ }
++ else if ((CHILD_READ > 1) && (CHILD_WRITE == STDOUT_FILENO)) {
++ DUP2CLOSE (CHILD_READ, STDIN_FILENO);
++ }
++ else if ((CHILD_READ > 1) && (CHILD_WRITE == STDIN_FILENO)) {
++ DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
++ DUP2CLOSE (CHILD_READ, STDIN_FILENO);
++ }
++ else {
++ /* CHILD_READ >= 1 and CHILD_WRITE > 1 */
++ DUP2CLOSE (CHILD_READ, STDIN_FILENO);
++ DUP2CLOSE (CHILD_WRITE, STDOUT_FILENO);
++ }
++ }
++ /* As pointed out by Florian Weimer to JP, it is a security threat to call
++ the script with a user defined environment and using the path. That
++ would be Trojans pleasure. Therefore the absolute path to addr2line
++ and an empty environment is used. That should be safe.
++ */
++ char *const argv[] = { "addr2line",
++ "-e", file_name,
++ "--demangle=gnat",
++ "--functions",
++ "--basenames",
++ NULL };
++ char *const envp[] = { NULL };
++ if (execve(ADDR2LINE_PROG, argv, envp) < 0) {
++ close (CHILD_WRITE);
++ close (CHILD_READ);
++ RESTSIG;
++ exit (1);
++ }
++ }
++
++ /* Below this line is parent process */
++ int i, n;
++ char hex[16];
++ char line[MAX_LINE + 1];
++ char *p;
++ char *s = buf;
++ long *trace_address = addrs;
++
++ close(CHILD_WRITE);
++ close(CHILD_READ);
++
++ for(i=0; i < n_addr; i++) {
++ snprintf(hex,sizeof(hex),"%#lx\n",*trace_address);
++ write(PARENT_WRITE,hex,strlen(hex));
++ n = read(PARENT_READ,line,MAX_LINE);
++ if (n<=0)
++ break;
++
++ line[n]=0;
++ /* We have approx. 16 additional chars for "%#lx in " clause.
++ We use this info to prevent a buffer overrun. */
++ if (n + 16 + (*len) > max_len)
++ break;
++
++ p = strchr(line,'\n');
++ if (p) {
++ if (*(p+1)) {
++ *p = 0;
++ *len += snprintf(s, (max_len - (*len)), "%#lx in %s at %s",
++ *trace_address, line, p+1);
++ }
++ else {
++ *len += snprintf(s, (max_len - (*len)), "%#lx at %s",
++ *trace_address, line);
++ }
++ s = buf + (*len);
++ }
++ trace_address += 1;
++ }
++ close (PARENT_WRITE);
++ close (PARENT_READ);
++ RESTSIG;
++}
++
++#elif defined (IS_CROSS) || !defined (NATIVE_SYMTRACE)
++
++/* run-time symbolic traceback support
++ Dummy function to satisfy g-trasym.o. */
+
+ void
+ convert_addresses (const char *file_name ATTRIBUTE_UNUSED,
diff --git a/lang/gnat-aux/patches/patch-ab b/lang/gnat-aux/patches/patch-ab
new file mode 100644
index 00000000000..4bf98ca12db
--- /dev/null
+++ b/lang/gnat-aux/patches/patch-ab
@@ -0,0 +1,155 @@
+$NetBSD: patch-ab,v 1.1 2011/10/05 18:11:55 marino Exp $
+
+--- /dev/null 2011-09-08 20:00:00.000000000 -0500
++++ gcc/ada/g-trasym-bsd.adb 2011-09-08 18:27:45.000000000 -0500
+@@ -0,0 +1,150 @@
++------------------------------------------------------------------------------
++-- --
++-- GNAT RUN-TIME COMPONENTS --
++-- --
++-- G N A T . T R A C E B A C K . S Y M B O L I C --
++-- --
++-- B o d y --
++-- --
++-- Copyright (C) 1999-2009, AdaCore --
++-- --
++-- GNAT is free software; you can redistribute it and/or modify it under --
++-- terms of the GNU General Public License as published by the Free Soft- --
++-- ware Foundation; either version 2, or (at your option) any later ver- --
++-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
++-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
++-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
++-- for more details. You should have received a copy of the GNU General --
++-- Public License distributed with GNAT; see file COPYING. If not, write --
++-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
++-- Boston, MA 02110-1301, USA. --
++-- --
++-- As a special exception, if other files instantiate generics from this --
++-- unit, or you link this unit with other files to produce an executable, --
++-- this unit does not by itself cause the resulting executable to be --
++-- covered by the GNU General Public License. This exception does not --
++-- however invalidate any other reasons why the executable file might be --
++-- covered by the GNU Public License. --
++-- --
++-- GNAT was originally developed by the GNAT team at New York University. --
++-- Extensive contributions were provided by Ada Core Technologies Inc. --
++-- --
++------------------------------------------------------------------------------
++
++-- Run-time symbolic traceback support
++-- This file is based on the work by Juergen Pfiefer which is still used
++-- today to provide symbolic traceback support for gnu/kFreeBSD.
++-- Incorporated in GNAT-AUX by John Marino <http://www.dragonlace.net>
++
++with System.Soft_Links;
++with Ada.Exceptions.Traceback; use Ada.Exceptions.Traceback;
++
++package body GNAT.Traceback.Symbolic is
++
++ package TSL renames System.Soft_Links;
++
++ -- To perform the raw addresses to symbolic form translation we rely on a
++ -- libaddr2line symbolizer which examines debug info from a provided
++ -- executable file name, and an absolute path is needed to ensure the file
++ -- is always found. This is "__gnat_locate_exec_on_path (gnat_argv [0])"
++ -- for our executable file, a fairly heavy operation so we cache the
++ -- result.
++
++ Exename : System.Address;
++ -- Pointer to the name of the executable file to be used on all
++ -- invocations of the libaddr2line symbolization service.
++
++ Exename_Resolved : Boolean := False;
++ -- Flag to indicate whether we have performed the executable file name
++ -- resolution already. Relying on a not null Exename for this purpose
++ -- would be potentially inefficient as this is what we will get if the
++ -- resolution attempt fails.
++
++ ------------------------
++ -- Symbolic_Traceback --
++ ------------------------
++
++ function Symbolic_Traceback (Traceback : Tracebacks_Array) return String is
++
++ procedure convert_addresses
++ (filename : System.Address;
++ addrs : System.Address;
++ n_addrs : Integer;
++ buf : System.Address;
++ len : System.Address);
++ pragma Import (C, convert_addresses, "convert_addresses");
++ -- This is the procedure version of the Ada-aware addr2line. It places
++ -- in BUF a string representing the symbolic translation of the N_ADDRS
++ -- raw addresses provided in ADDRS, looked up in debug information from
++ -- FILENAME. LEN points to an integer which contains the size of the
++ -- BUF buffer at input and the result length at output.
++ --
++ -- Note that this procedure is *not* thread-safe.
++
++ type Argv_Array is array (0 .. 0) of System.Address;
++ gnat_argv : access Argv_Array;
++ pragma Import (C, gnat_argv, "gnat_argv");
++
++ function locate_exec_on_path
++ (c_exename : System.Address) return System.Address;
++ pragma Import (C, locate_exec_on_path, "__gnat_locate_exec_on_path");
++
++ B_Size : constant Integer := 256 * Traceback'Length;
++ Len : Integer := B_Size;
++ Res : String (1 .. B_Size);
++
++ use type System.Address;
++
++ begin
++ -- The symbolic translation of an empty set of addresses is an empty
++ -- string.
++
++ if Traceback'Length = 0 then
++ return "";
++ end if;
++
++ -- If our input set of raw addresses is not empty, resort to the
++ -- libaddr2line service to symbolize it all.
++
++ -- Compute, cache and provide the absolute path to our executable file
++ -- name as the binary file where the relevant debug information is to be
++ -- found. If the executable file name resolution fails, we have no
++ -- sensible basis to invoke the symbolizer at all.
++
++ -- Protect all this against concurrent accesses explicitly, as the
++ -- underlying services are potentially thread unsafe.
++
++ TSL.Lock_Task.all;
++
++ if not Exename_Resolved then
++ Exename := locate_exec_on_path (gnat_argv (0));
++ Exename_Resolved := True;
++ end if;
++
++ if Exename /= System.Null_Address then
++ Len := Res'Length;
++ convert_addresses
++ (Exename, Traceback'Address, Traceback'Length,
++ Res (1)'Address, Len'Address);
++ end if;
++
++ TSL.Unlock_Task.all;
++
++ -- Return what the addr2line symbolizer has produced if we have called
++ -- it (the executable name resolution succeeded), or an empty string
++ -- otherwise.
++
++ if Exename /= System.Null_Address then
++ return Res (1 .. Len);
++ else
++ return "";
++ end if;
++
++ end Symbolic_Traceback;
++
++ function Symbolic_Traceback (E : Exception_Occurrence) return String is
++ begin
++ return Symbolic_Traceback (Tracebacks (E));
++ end Symbolic_Traceback;
++
++end GNAT.Traceback.Symbolic;
diff --git a/lang/gnat-aux/patches/patch-ac b/lang/gnat-aux/patches/patch-ac
new file mode 100644
index 00000000000..af4f83d3ef4
--- /dev/null
+++ b/lang/gnat-aux/patches/patch-ac
@@ -0,0 +1,111 @@
+$NetBSD
+
+--- gcc/ada/gcc-interface/Makefile.in.orig 2011-07-15 08:07:01.000000000 +0200
++++ gcc/ada/gcc-interface/Makefile.in 2011-10-03 07:29:02.918353281 +0200
+@@ -1011,6 +1011,7 @@
+ a-numaux.adb<a-numaux-x86.adb \
+ a-numaux.ads<a-numaux-x86.ads \
+ a-intnam.ads<a-intnam-solaris.ads \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-solaris.adb \
+ s-osinte.adb<s-osinte-solaris.adb \
+@@ -1184,6 +1185,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-freebsd.adb \
+@@ -1219,6 +1221,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-freebsd.adb \
+@@ -1253,6 +1256,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-dragonfly.adb \
+@@ -1288,6 +1292,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-dragonfly.adb \
+@@ -1322,6 +1327,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-openbsd.adb \
+@@ -1357,6 +1363,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-bsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-openbsd.adb \
+@@ -1391,6 +1398,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-netbsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-netbsd.adb \
+@@ -1435,6 +1443,7 @@
+ a-numaux.ads<a-numaux-x86.ads \
+ g-bytswa.adb<g-bytswa-x86.adb \
+ g-socthi.adb<g-socthi-netbsd.adb \
++ g-trasym.adb<g-trasym-bsd.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-osinte.adb<s-osinte-netbsd.adb \
+@@ -1472,11 +1481,13 @@
+ ifeq ($(strip $(filter-out arm% android eabi,$(targ))),)
+ LIBGNAT_TARGET_PAIRS = \
+ a-intnam.ads<a-intnam-linux.ads \
++ g-trasym.ads<g-trasym-unimplemented.ads \
++ g-trasym.adb<g-trasym-unimplemented.adb \
+ s-inmaop.adb<s-inmaop-posix.adb \
+ s-intman.adb<s-intman-posix.adb \
+ s-linux.ads<s-linux.ads \
+ s-osinte.adb<s-osinte-posix.adb \
+- s-osinte.ads<s-osinte-linux.ads \
++ s-osinte.ads<s-osinte-android.ads \
+ s-osprim.adb<s-osprim-posix.adb \
+ s-taprop.adb<s-taprop-linux.adb \
+ s-tasinf.ads<s-tasinf-linux.ads \
+@@ -1496,12 +1507,14 @@
+ mlib-tgt-specific.adb<mlib-tgt-specific-linux.adb \
+ indepsw.adb<indepsw-gnu.adb
+
+- EXTRA_GNATRTL_TASKING_OBJS=s-linux.o
++ EXTRA_LIBGNAT_SRCS+= signal_android.c
++ EXTRA_LIBGNAT_OBJS+= signal_android.o
++ EXTRA_GNATRTL_TASKING_OBJS= s-linux.o
+ EH_MECHANISM=
+- THREADSLIB = -lpthread
+- GNATLIB_SHARED = gnatlib-shared-dual
+- GMEM_LIB = gmemlib
+- LIBRARY_VERSION := $(LIB_VERSION)
++ THREADSLIB=
++ GNATLIB_SHARED= gnatlib-shared-dual
++ GMEM_LIB= gmemlib
++ LIBRARY_VERSION:= $(LIB_VERSION)
+ endif
+
+