From patchwork Mon Feb 24 16:01:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marius Bakke X-Patchwork-Id: 20407 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 07CC827BBE4; Mon, 24 Feb 2020 16:02:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 663BB27BBEA for ; Mon, 24 Feb 2020 16:02:21 +0000 (GMT) Received: from localhost ([::1]:38446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GBY-0001Te-VK for patchwork@mira.cbaines.net; Mon, 24 Feb 2020 11:02:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37175) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GBN-0001S7-7P for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6GBH-0003DI-Oo for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:47981) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6GBF-0003Cy-Pj for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j6GBF-0006JS-O3 for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#39767] [PATCH core-updates] gnu: ld-wrapper: Preserve quoted arguments from response files. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 24 Feb 2020 16:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39767 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 39767@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.158256010424231 (code B ref -1); Mon, 24 Feb 2020 16:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Feb 2020 16:01:44 +0000 Received: from localhost ([127.0.0.1]:53954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j6GAy-0006Il-4z for submit@debbugs.gnu.org; Mon, 24 Feb 2020 11:01:44 -0500 Received: from lists.gnu.org ([209.51.188.17]:50847) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j6GAv-0006Ic-J5 for submit@debbugs.gnu.org; Mon, 24 Feb 2020 11:01:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37126) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GAt-0001H6-SP for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6GAs-00033u-As for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:39 -0500 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:43725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6GAr-00033M-UN for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:38 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 6141C3CB for ; Mon, 24 Feb 2020 11:01:35 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 24 Feb 2020 11:01:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= from:to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=fm2; bh=YL3tIACJDixHz8jOd6Khi+ghDX PipGZux09x/Fj4bck=; b=fAq9/wY6uFzsRtET2TheYqYFo/u+BSNFqcg1yFD2NP mfnw1KOw1dPFfdgMgffulPzyFFBOPjLRxXEUend3OJE6cl8hSJVYP2NjVRXgOkzk +yHir80Xf5WZFnT8tOetZqul5uqAEUfdfw4N8/RMiPimWHLX/iI0CIL3HPoAsISZ DichDf5TcklVkXpOrFF0nayE0gGgQmyKuTahIchLd94vSb63NQhIf5GH4dpNFJN8 UFSapA4r5vjrXxiIsZyKe4gbKPcdF5T1LTPtjQ8M2wAiGwoysYT61J6Mn1EoWoCE r6BPXpPdxBdMmN/WYOuhhHBElocP5LpV07GLBk6eF+6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=YL3tIA CJDixHz8jOd6Khi+ghDXPipGZux09x/Fj4bck=; b=1suMZUWMBRmL/D+2fwMA6m OS/qc/WaD7ON0JGx7vmP79Lbt2ikY0PNdVmfqgQRxysPtQNbWvR/VoTkG7999U6I 0dxBTdydf8cZCy9sW16m+O5qJDjgYcSJ3HS6OAJ1JZ5GY7MQoVQL+qkj88UkbmNe 5zrVAvSfA5BCxbbA/jCBDcHFG0e8horeofqhaJnMq0Mqbo8SP16fFWNm9p2fPJsY gFCSFm+nszVc7z+FEk0aPHpzeIN3Wb9fz132IebA83EN5B5p6ZYGe+jYY4ESET7/ hwpCgkqv7bSTR7V2b83WITCTrOMf7JOUxtFK8C86Nm+1UgDYuy+bh0MYX9MbWong == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrledtgdekgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffogggtgfesthekredtre dtjeenucfhrhhomhepofgrrhhiuhhsuceurghkkhgvuceomhgsrghkkhgvsehfrghsthhm rghilhdrtghomheqnecukfhppeekgedrvddtvddrieekrdejheenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmsggrkhhkvgesfhgrshhtmhgr ihhlrdgtohhm X-ME-Proxy: Received: from localhost (ti0006q161-2604.bb.online.no [84.202.68.75]) by mail.messagingengine.com (Postfix) with ESMTPA id 87FA13060D1A for ; Mon, 24 Feb 2020 11:01:34 -0500 (EST) From: Marius Bakke Date: Mon, 24 Feb 2020 17:01:32 +0100 Message-Id: <20200224160132.21037-1-mbakke@fastmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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 +;;; Copyright © 2020 Marius Bakke ;;; ;;; 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)