From patchwork Fri Oct 21 10:39:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 120982 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 15CBB1007D2 for ; Fri, 21 Oct 2011 21:40:09 +1100 (EST) Received: (qmail 32653 invoked by alias); 21 Oct 2011 10:40:07 -0000 Received: (qmail 32637 invoked by uid 22791); 21 Oct 2011 10:40:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Oct 2011 10:39:50 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 87D3BCB0376; Fri, 21 Oct 2011 12:39:49 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c53RpUUxhOTb; Fri, 21 Oct 2011 12:39:39 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id DADE4CB01BA; Fri, 21 Oct 2011 12:39:39 +0200 (CEST) From: Tristan Gingold Subject: [Patch] Add support of AIX response files in collect2 Date: Fri, 21 Oct 2011 12:39:38 +0200 Message-Id: Cc: David Edelsohn To: GCC Patches Mime-Version: 1.0 (Apple Message framework v1244.3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, the AIX linker supports response files with the '-fFILE' command line option. With this patch, collect2 reads the content of the response files and listed object files are handled. Therefore these files are not forgotten by the collect2 machinery. Although AIX ld supports glob(3) patterns, this isn't handled by this patch because glob() isn't available on all hosts, isn't present in libiberty and its use is not common. To be considered for the future. I haven't added a testcase for this because I think this is not possible with only one file. But hints are welcome. Reduced bootstrap on rs6000-aix Ok for trunk ? Tristan. 2011-10-21 Tristan Gingold * collect2.c (main): Add support of -f (response file) on AIX. diff --git a/gcc/collect2.c b/gcc/collect2.c index cf39693..fd747b5 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -1091,6 +1091,7 @@ main (int argc, char **argv) const char **ld2; char **object_lst; const char **object; + int object_nbr = argc; int first_file; int num_c_args; char **old_argv; @@ -1440,6 +1441,57 @@ main (int argc, char **argv) "configuration"); #endif } +#ifdef TARGET_AIX_VERSION + else + { + /* File containing a list of input files to process. */ + + FILE *stream; + char buf[MAXPATHLEN + 2]; + /* Number of additionnal object files. */ + int add_nbr = 0; + /* Maximum of additionnal object files before vector + expansion. */ + int add_max = 0; + const char *list_filename = arg + 2; + + /* Accept -fFILENAME and -f FILENAME. */ + if (*list_filename == '\0' && argv[1]) + { + ++argv; + list_filename = *argv; + *ld1++ = *ld2++ = *argv; + } + + stream = fopen (list_filename, "r"); + if (stream == NULL) + fatal_error ("can't open %s: %m", list_filename); + + while (fgets (buf, sizeof buf, stream) != NULL) + { + /* Remove end of line. */ + int len = strlen (buf); + if (len >= 1 && buf[len - 1] =='\n') + buf[len - 1] = '\0'; + + /* Put on object vector. + Note: we only expanse vector here, so we must keep + extra space for remaining arguments. */ + if (add_nbr >= add_max) + { + int pos = object - (const char **)object_lst; + add_max = (add_max == 0) ? 16 : add_max * 2; + object_lst = XRESIZEVEC(char *, object_lst, + object_nbr + add_max); + object = (const char **)object_lst + pos; + object_nbr += add_max; + } + *object++ = xstrdup(buf); + add_nbr++; + } + fclose (stream); + } +#endif break; case 'l':