From patchwork Wed Oct 21 21:21:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 534089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 78F9A14016A for ; Thu, 22 Oct 2015 08:21:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=rbDUEo7n; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E52D932938; Wed, 21 Oct 2015 21:21:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Efr56VpC+mmV; Wed, 21 Oct 2015 21:21:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 9550F26EAB; Wed, 21 Oct 2015 21:21:16 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id D94F81BFA9F for ; Wed, 21 Oct 2015 21:21:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id CFC462DF46 for ; Wed, 21 Oct 2015 21:21:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Nc5gWA9b-Ifj for ; Wed, 21 Oct 2015 21:21:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) by silver.osuosl.org (Postfix) with ESMTPS id C72762D052 for ; Wed, 21 Oct 2015 21:21:13 +0000 (UTC) Received: by wicll6 with SMTP id ll6so92976909wic.1 for ; Wed, 21 Oct 2015 14:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=JyOJZixNQQws4XPJwjVKwLBNNqnaFRDZdvqoS0358EU=; b=rbDUEo7nkHHdF53Zs2FOl864rocI3FyQTf9j1JtNjYG9YLiC3snooNnse7pQzoek8I TBNhD1tUdUCbclm1KCxaLOtccYD/2B5V6YcQzKJiWS5xhSvv7xoK65JZUFJUDTa5iOw4 RifVFn4DwqwQYXSZThGRcC/S72fcl1LAtZa7UShwcV08GZGkHeq7ASLKDDO03qZFGD11 misUYMACmTjss0JcWFGHE1y4a+cbIq/4TTpcu26pjzEX3iynHVcjIITYd0TkZQrqOvYY pT2QGelsRZPFgONNnsW2DcDz/6BJ1p/LbLbTo8Nl1spSxxfcKO1gL1vUHy1mHrbOzHDs 597w== X-Received: by 10.180.8.68 with SMTP id p4mr37164539wia.16.1445462472271; Wed, 21 Oct 2015 14:21:12 -0700 (PDT) Received: from gourin.bzh.lan (ns304657.ip-46-105-103.eu. [46.105.103.66]) by smtp.gmail.com with ESMTPSA id ry1sm12745480wjb.24.2015.10.21.14.21.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Oct 2015 14:21:10 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@buildroot.org Date: Wed, 21 Oct 2015 23:21:07 +0200 Message-Id: <1445462467-26873-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 1.9.1 Cc: "Yann E. MORIN" Subject: [Buildroot] [PATCH] toochain/wrapper: fix potential bug in foreach loop X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" In Makefile, the comma ',' is used to separate the arguments passed to functions, so we should not be allowed to use straight commas in strings we want to expand. For the toolchain wrapper, we need to transform a list: -mfoo -mbar -mbuz into something acceptable for a C array assignment: "-mfoo", "-mbar", "-mbuz", So, we use a $(foreach ...) loop for that. However, we do have a straight comma in there. It does not cause any issue in practice, since $(foreach) is a make builtin function that accepts three and only three parameters. However, this is not sane. Change the straight comma to the usual $(comma) expansion, like we sould do for a call to any other function. At the same time, make the code a bit easier to read, by first creating the transformed list, and then creating the define. Signed-off-by: "Yann E. MORIN" Cc: Arnout Vandecappelle Acked-by: Arnout Vandecappelle (Essensium/Mind) Tested-by: Arnout Vandecappelle (Essensium/Mind) --- toolchain/toolchain-wrapper.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk index eba2b38..af39071 100644 --- a/toolchain/toolchain-wrapper.mk +++ b/toolchain/toolchain-wrapper.mk @@ -14,7 +14,9 @@ TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"' # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a # separate argument when used in execv() by the toolchain wrapper. -TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)",)' +TOOLCHAIN_WRAPPER_OPTS = \ + $(foreach f,$(call qstrip,$(BR2_TARGET_OPTIMIZATION)),"$(f)"$(comma)) +TOOLCHAIN_WRAPPER_ARGS += -DBR_ADDITIONAL_CFLAGS='$(TOOLCHAIN_WRAPPER_OPTS)' ifeq ($(BR2_CCACHE),y) TOOLCHAIN_WRAPPER_ARGS += -DBR_CCACHE