From patchwork Thu Sep 5 18:24:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yann E. MORIN" X-Patchwork-Id: 272925 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 0AD812C00E9 for ; Fri, 6 Sep 2013 04:25:01 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 57DC62F6F6; Thu, 5 Sep 2013 18:24:49 +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 hYsW8KkKCUsX; Thu, 5 Sep 2013 18:24:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 350672F82A; Thu, 5 Sep 2013 18:24:46 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id DAC6A1BF96B for ; Thu, 5 Sep 2013 18:24:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D47198CEDF for ; Thu, 5 Sep 2013 18:24:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7SWt3Dwr0oP5 for ; Thu, 5 Sep 2013 18:24:53 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by whitealder.osuosl.org (Postfix) with ESMTPS id 7685E8CEC6 for ; Thu, 5 Sep 2013 18:24:53 +0000 (UTC) Received: by mail-wi0-f176.google.com with SMTP id cb5so5291273wib.15 for ; Thu, 05 Sep 2013 11:24:52 -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=UnLLIdeptWuQCxdvbqELepvgY7SGPXyDc6JFGMZGvYs=; b=q5i8dhU+W6pVXdF6+fuez//EXbW9HpGSBPmX6dgUtPcxl9qho2a4jwqDAWtmivmgTX +Ly4t/3Z1tG8WLipY5ccnNjx6JViNhGMIsqHet2ebAdqEumeNEo7kxWrlyk0JeGE0Vpm l6MvMHV8evSIMxqyH8k3PQ+nvkkS1rNzAyk9iD8vCEL8/NrlYayxoX2/FM/NJBaGjXiT XaVaFbAbk5AnOFUAic37h9iqr/Owbi8fZiqwM14UNhAxtC0IBlXwB4aCiIEEBZ+Bd/Ur L6apzRjUGPWYyiOgqwXoViDnwjLqw6OocNXBC6VTJfrMCXTfJA1VFkMuRSeuIYY5bUmY 0rVQ== X-Received: by 10.180.208.7 with SMTP id ma7mr7331613wic.25.1378405491934; Thu, 05 Sep 2013 11:24:51 -0700 (PDT) Received: from localhost.localdomain (ks3095497.kimsufi.com. [94.23.60.27]) by mx.google.com with ESMTPSA id b11sm7534364wik.1.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Sep 2013 11:24:50 -0700 (PDT) From: "Yann E. MORIN" To: buildroot@busybox.net Date: Thu, 5 Sep 2013 20:24:25 +0200 Message-Id: <1378405466-9991-1-git-send-email-yann.morin.1998@free.fr> X-Mailer: git-send-email 1.8.1.2 Cc: Luca Ceresoli , "Yann E. MORIN" Subject: [Buildroot] [PATCH 1/2] toolchain/wrapper: add option to print one argument per line X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 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-bounces@busybox.net From: "Yann E. MORIN" In case there are many arguments passed to the tools, the command line can get very long, and difficult to parse visually. For example, the Linux kernel passes a lot of arguments to gcc (at least 45, which gives 53 with our hard-coded args). Looking at such a command line is daunting. So, add the possibility to print each argument on its own line. Also, enclose all args between single quotes, so the command line can be safely copy-pasted without special chars (spaces, $) being inrerpreted by the shell. Add blurb about toolchain-wrapper to documentation at the same time. Signed-off-by: "Yann E. MORIN" Acked-by: Luca Ceresoli Tested-by: Luca Ceresoli --- docs/manual/customize-toolchain.txt | 11 ++++++++++ .../toolchain-external/ext-toolchain-wrapper.c | 25 +++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/manual/customize-toolchain.txt b/docs/manual/customize-toolchain.txt index 811a6dc..587fccc 100644 --- a/docs/manual/customize-toolchain.txt +++ b/docs/manual/customize-toolchain.txt @@ -17,6 +17,17 @@ generate it. It also requires to set the Buildroot settings according to the toolchain ones (see xref:external-toolchain-backend[]). +When using an external toolchain, Buildroot generates a wrapper program, that +passes the appropriate options (accordingly to the configuration) to the +external toolchain programs. In case you need to debug this wrapper, you can +set the environment variable BR_DEBUG_WRAPPER to either one of: + +* +0+, empty or not set: no debug + +* +1+: trace all arguments on a single line + +* +2+: trace one argument per line + Using the internal Buildroot toolchain backend ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/toolchain/toolchain-external/ext-toolchain-wrapper.c b/toolchain/toolchain-external/ext-toolchain-wrapper.c index 565e36b..dfdfcff 100644 --- a/toolchain/toolchain-external/ext-toolchain-wrapper.c +++ b/toolchain/toolchain-external/ext-toolchain-wrapper.c @@ -74,7 +74,8 @@ int main(int argc, char **argv) char *relbasedir, *absbasedir; char *progpath = argv[0]; char *basename; - int ret, i, count = 0; + char *env_debug; + int ret, i, count = 0, debug; /* Calculate the relative paths */ basename = strrchr(progpath, '/'); @@ -157,13 +158,21 @@ int main(int argc, char **argv) /* finish with NULL termination */ *cur = NULL; - if (getenv("BR_DEBUG_WRAPPER")) { - fprintf(stderr, "Executing"); - - for (i = 0; args[i]; i++) - fprintf(stderr, " %s", args[i]); - - fprintf(stderr, "\n"); + /* Debug the wrapper to see actual arguments passed to + * the compiler: + * unset, empty, or 0: do not trace + * set to 1 : trace all arguments on a single line + * set to 2 : trace one argument per line + */ + if ((env_debug = getenv("BR_DEBUG_WRAPPER"))) { + debug = atoi(env_debug); + if (debug > 0) { + fprintf(stderr, "Toolchain wrapper executing:"); + for (i = 0; args[i]; i++) + fprintf(stderr, "%s'%s'", + (debug == 2)?"\n ":" ", args[i]); + fprintf(stderr, "\n"); + } } if (execv(path, args))