From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#25882: gcc-wrapper doesn't handle response files Date: Tue, 07 Mar 2017 11:53:57 +0100 Message-ID: <87r329fjcq.fsf@gnu.org> References: <87o9xepe7l.fsf@gnu.org> <871suajpfh.fsf@lupo.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clClm-0003nb-Nh for bug-guix@gnu.org; Tue, 07 Mar 2017 05:55:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clCli-0002P1-M4 for bug-guix@gnu.org; Tue, 07 Mar 2017 05:55:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:45438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clCli-0002Ox-Im for bug-guix@gnu.org; Tue, 07 Mar 2017 05:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1clCli-0003C4-CW for bug-guix@gnu.org; Tue, 07 Mar 2017 05:55:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <871suajpfh.fsf@lupo.i-did-not-set--mail-host-address--so-tickle-me> (Federico Beffa's message of "Mon, 06 Mar 2017 18:16:50 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Federico Beffa Cc: 25882@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Federico Beffa skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Federico Beffa skribis: >> >>> gcc-wrapper doesn't handle compiler/linker flags passed through >>> response files. >>> >>> One package which recently started using such files is GHC (I believe >>> since 7.10.3). For this reason we currently need to patch it. >>> However, the problem is with our tool chain wrapper and not with GHC >>> itself. >>> >>> See discussion at >>> https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01981.html >> >> Given that the GHC patch is so small, I have a slight preference for >> keeping ld-wrapper unchanged and using the GHC patch. To put it >> differently, the GHC patch is smaller and less error-prone than the >> changes that would need to be made in ld-wrapper. > > I don't think that it is a good idea because any upstream change around > that code will break our package again and, going forward, we may find > other pieces of software making use of this gcc feature. The patch is > small, but the effort to find it wasn't. > > I like to fix things where the problem is, not working around it. On closer inspection, it=E2=80=99s an easy change to make. Could you test the attached patch with GHC? The way I would test it without rebuilding the world is by copying the new ld-wrapper.in to ld-wrapper2.in (and thus keeping ld-wrapper.in unchanged), and then adding it as an input to GHC (via =E2=80=98make-ld-wrapper=E2=80=99). Commit 77db91addc57faa000db05563820f57= a9ffdedfc might serve as an example. Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/gnu/packages/ld-wrapper.in b/gnu/packages/ld-wrapper.in index ebfd8332c..ff086154a 100644 --- a/gnu/packages/ld-wrapper.in +++ b/gnu/packages/ld-wrapper.in @@ -15,7 +15,7 @@ main=3D"(@ (gnu build-support ld-wrapper) ld-wrapper)" exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-= line)))" "$@" !# ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Court=C3= =A8s ;;; ;;; This file is part of GNU Guix. ;;; @@ -35,6 +35,7 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $ma= in (cdr (command-line)) (define-module (gnu build-support ld-wrapper) #:use-module (srfi srfi-1) #:use-module (ice-9 match) + #:autoload (ice-9 rdelim) (read-string) #:export (ld-wrapper)) =20 ;;; Commentary: @@ -222,9 +223,28 @@ impure library ~s~%" '() library-files)) =20 +(define (expand-arguments args) + ;; Expand ARGS such that "response file" arguments, such as "@args.txt",= are + ;; expanded. See 'expandargv' in libiberty. + (define (response-file-arguments file) + (when %debug? + (format (current-error-port) + "ld-wrapper: reading arguments from '~a'~%" file)) + (string-tokenize (call-with-input-file file read-string))) + + (fold-right (lambda (arg result) + (if (string-prefix? "@" arg) + (let ((file (string-drop arg 1))) + (append (response-file-arguments file) + result)) + (cons arg result))) + '() + args)) + (define (ld-wrapper . args) ;; Invoke the real `ld' with ARGS, augmented with `-rpath' switches. - (let* ((path (library-search-path args)) + (let* ((args (expand-arguments args)) + (path (library-search-path args)) (libs (library-files-linked args path)) (args (append args (rpath-arguments libs)))) (when %debug? --=-=-=--