GNU bug report logs - #39767
[PATCH core-updates] gnu: ld-wrapper: Preserve quoted arguments from response files.

Previous Next

Package: guix-patches;

Reported by: Marius Bakke <mbakke <at> fastmail.com>

Date: Mon, 24 Feb 2020 16:02:01 UTC

Severity: normal

Tags: patch

Done: Marius Bakke <mbakke <at> fastmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39767 in the body.
You can then email your comments to 39767 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#39767; Package guix-patches. (Mon, 24 Feb 2020 16:02:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Marius Bakke <mbakke <at> fastmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 24 Feb 2020 16:02:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: guix-patches <at> gnu.org
Subject: [PATCH core-updates] gnu: ld-wrapper: Preserve quoted arguments from
 response files.
Date: Mon, 24 Feb 2020 17:01:32 +0100
* gnu/packages/ld-wrapper.in (expand-arguments): Add TOKENIZE procedure, and
use that to parse the response file.
---
 gnu/packages/ld-wrapper.in | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

Guix,

Currently the ld-wrapper will fail inscrutably if a response file
contains double quotes.  This patch fixes that, and also preserves
whitespaces between quotes.

diff --git a/gnu/packages/ld-wrapper.in b/gnu/packages/ld-wrapper.in
index 16780c58f6..5d5756f6a3 100644
--- a/gnu/packages/ld-wrapper.in
+++ b/gnu/packages/ld-wrapper.in
@@ -16,6 +16,7 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line))
 !#
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2020 Marius Bakke <mbakke <at> fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -35,7 +36,7 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (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)
+  #:autoload   (ice-9 rdelim) (read-delimited)
   #:export (ld-wrapper))
 
 ;;; Commentary:
@@ -239,13 +240,28 @@ library outside of ~a: ~s~%"
   ;; Expand ARGS such that "response file" arguments, such as "@args.txt", are
   ;; expanded (info "(gcc) Overall Options").
   (define (response-file-arguments file)
+    (define (tokenize port)
+      ;; Return a list of all strings found in PORT.  Quote characters are removed,
+      ;; but whitespaces within quoted strings are preserved.
+      (let loop ((words '()))
+        (let* ((word (read-delimited " '\"" port 'split))
+               (token (car word))
+               (delim (cdr word)))
+          (if (eof-object? delim)
+              (reverse words)
+              (case delim
+                ((#\") (loop (cons (read-delimited "\"" port) words)))
+                ((#\') (loop (cons (read-delimited "'" port) words)))
+                ((#\ ) (if (> 0 (string-length token))
+                           (loop (cons token words))
+                           (loop words)))
+                (else (loop words)))))))
+
     (when %debug?
       (format (current-error-port)
               "ld-wrapper: attempting to read arguments from '~a'~%" file))
 
-    ;; FIXME: Options can contain whitespace if they are protected by single
-    ;; or double quotes; this is not implemented here.
-    (string-tokenize (call-with-input-file file read-string)))
+    (call-with-input-file file tokenize))
 
   (define result
     (fold-right (lambda (arg result)
-- 
2.25.0





Information forwarded to guix-patches <at> gnu.org:
bug#39767; Package guix-patches. (Mon, 24 Feb 2020 21:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 39767 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Marius Bakke <mbakke <at> fastmail.com>
Cc: 39767 <at> debbugs.gnu.org
Subject: Re: [bug#39767] [PATCH core-updates] gnu: ld-wrapper: Preserve quoted
 arguments from response files.
Date: Mon, 24 Feb 2020 22:01:57 +0100
Hi Marius!

Marius Bakke <mbakke <at> fastmail.com> skribis:

> * gnu/packages/ld-wrapper.in (expand-arguments): Add TOKENIZE procedure, and
> use that to parse the response file.

LGTM!

> Currently the ld-wrapper will fail inscrutably if a response file
> contains double quotes.  This patch fixes that, and also preserves
> whitespaces between quotes.

Out of curiosity, where did you stumble upon response files with quotes?
Was it GHC?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#39767; Package guix-patches. (Mon, 24 Feb 2020 21:15:01 GMT) Full text and rfc822 format available.

Message #11 received at 39767 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 39767 <at> debbugs.gnu.org
Subject: Re: [bug#39767] [PATCH core-updates] gnu: ld-wrapper: Preserve quoted
 arguments from response files.
Date: Mon, 24 Feb 2020 22:14:35 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Marius!
>
> Marius Bakke <mbakke <at> fastmail.com> skribis:
>
>> * gnu/packages/ld-wrapper.in (expand-arguments): Add TOKENIZE procedure, and
>> use that to parse the response file.
>
> LGTM!
>
>> Currently the ld-wrapper will fail inscrutably if a response file
>> contains double quotes.  This patch fixes that, and also preserves
>> whitespaces between quotes.
>
> Out of curiosity, where did you stumble upon response files with quotes?
> Was it GHC?

A variant of this wrapper will (hopefully!) soon show up on the 'master'
branch, required for version 80 of ungoogled-chromium.  It generates
response files where all "-lfoo" "-lbar" arguments are quoted, even
though they contain no spaces.

Thanks for the quick review, will merge it on core-updates after it hits
'master'.  :-)
[signature.asc (application/pgp-signature, inline)]

Reply sent to Marius Bakke <mbakke <at> fastmail.com>:
You have taken responsibility. (Fri, 06 Mar 2020 12:28:01 GMT) Full text and rfc822 format available.

Notification sent to Marius Bakke <mbakke <at> fastmail.com>:
bug acknowledged by developer. (Fri, 06 Mar 2020 12:28:02 GMT) Full text and rfc822 format available.

Message #16 received at 39767-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: 39767-done <at> debbugs.gnu.org
Subject: Re: [bug#39767] [PATCH core-updates] gnu: ld-wrapper: Preserve quoted
 arguments from response files.
Date: Fri, 06 Mar 2020 13:26:54 +0100
[Message part 1 (text/plain, inline)]
Marius Bakke <mbakke <at> fastmail.com> writes:

> * gnu/packages/ld-wrapper.in (expand-arguments): Add TOKENIZE procedure, and
> use that to parse the response file.

I simplified it a bit and also discarded newlines and pushed to
core-updates in feb8c5dac30294d72205ee21b3afcf1cf7a04675.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Apr 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 19 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.