From patchwork Wed Aug 15 14:27:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10566657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8ECA1390 for ; Wed, 15 Aug 2018 14:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F1929D86 for ; Wed, 15 Aug 2018 14:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D86729D89; Wed, 15 Aug 2018 14:28:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4484529D86 for ; Wed, 15 Aug 2018 14:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729433AbeHORU2 (ORCPT ); Wed, 15 Aug 2018 13:20:28 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45045 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729388AbeHORU2 (ORCPT ); Wed, 15 Aug 2018 13:20:28 -0400 Received: by mail-lj1-f193.google.com with SMTP id q127-v6so1089020ljq.11 for ; Wed, 15 Aug 2018 07:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6OYwUrioNl0zu7PVa/7o6YFOoh5jN7+LZqEy07jO1sw=; b=RoHdLxuWjTk/rNqR20+kqFPqE+YmvChPEWvIfIoh0xsfbFvs0Cv53/HL4B99ASpYXB lfRVRlTEiiE/jOPdWVRhNxer02ttnJnejDr9qRS5oZrFdZCKOJfqPnl7NRYu6ALgO1jI snbagIsjAJrr6/i2pDRkk3PPpcyPJH953OVMQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6OYwUrioNl0zu7PVa/7o6YFOoh5jN7+LZqEy07jO1sw=; b=ECUaV0DwUZOtolr74WWxIbaLqvzI+UnRqYJG1+VySjg5TJJMzDlRwA6TtWCkPfu7Yr OiuvZDp80IW8cTLYAON7R0jim3A2BYAc3p4ArHThOWhN9IOe3fM8jztlnFQ5jCBjs3Er hPV+B4JBmmOpcXAxTuMIGAH8NQIyAmbgsu8/5M0y1oZpXd06qQJhcS7katFEy+R9Z8Hq MDs2ALb5nD7tXaClG9jFmmOTnMO0A08rlZlwX2GpBvzgRWfVF5+Rb8ZC990N2I6hPR9o cYJtIHiW+ETG2kGh9bhM6g/USRdB4lmatsz8PHiWEZ+K7S6jXdFqMle2I0mN9F3DV999 zjFA== X-Gm-Message-State: AOUpUlGMCsQJrZMV0IeTGCpy1RCBRjxv8G1651j5mjLOTuIhrSsoCqF6 f//GpifKYQad6lope+j+7WXdsw== X-Google-Smtp-Source: AA+uWPwx9eqaLRvtean9XmwcRN3Qu7MNpL+hO5JjbqGcHvMwd+Q9c4kWVsz1iPSLQM+FS0wWQVgxfA== X-Received: by 2002:a2e:9941:: with SMTP id r1-v6mr17648692ljj.53.1534343284381; Wed, 15 Aug 2018 07:28:04 -0700 (PDT) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id l3-v6sm4559597lfi.36.2018.08.15.07.28.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 07:28:04 -0700 (PDT) From: Rasmus Villemoes To: Masahiro Yamada , Michal Marek Cc: linux-kbuild@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] Kbuild: teach fixdep to optionally remove the depfile Date: Wed, 15 Aug 2018 16:27:48 +0200 Message-Id: <20180815142749.18804-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180815142749.18804-1-linux@rasmusvillemoes.dk> References: <20180815142749.18804-1-linux@rasmusvillemoes.dk> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of having to spawn an 'rm' instance to remove the depfile after processing, let the fixdep program itself do that. For debugging, it's nice to not do it unconditionally. Note that the fixdep calls from Makefiles are done under 'set -e', so this also preserves the behaviour of keeping the depfile if fixdep exits prematurely. Signed-off-by: Rasmus Villemoes --- scripts/Kbuild.include | 7 +++---- scripts/basic/fixdep.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d52db4279aa5..a944510acd9d 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -274,8 +274,8 @@ ifndef CONFIG_TRIM_UNUSED_KSYMS cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ - rm -f $(depfile); \ + scripts/basic/fixdep -r $(depfile) $@ '$(make-cmd)' \ + > $(dot-target).tmp; \ mv -f $(dot-target).tmp $(dot-target).cmd; else @@ -298,9 +298,8 @@ ksym_dep_filter = \ cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ $(ksym_dep_filter) | \ - scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \ + scripts/basic/fixdep -e -r $(depfile) $@ '$(make-cmd)' \ > $(dot-target).tmp; \ - rm -f $(depfile); \ mv -f $(dot-target).tmp $(dot-target).cmd; endif diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 666041841200..7b59c185858a 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -105,8 +105,9 @@ static void usage(void) { - fprintf(stderr, "Usage: fixdep [-e] \n"); + fprintf(stderr, "Usage: fixdep [-e] [-r] \n"); fprintf(stderr, " -e insert extra dependencies given on stdin\n"); + fprintf(stderr, " -r remove after processing\n"); exit(1); } @@ -380,12 +381,14 @@ int main(int argc, char *argv[]) { const char *depfile, *target, *cmdline; int insert_extra_deps = 0; + int remove_depfile = 0; void *buf; int opt; - while ((opt = getopt(argc, argv, "e")) != -1) { + while ((opt = getopt(argc, argv, "er")) != -1) { switch (opt) { case 'e': insert_extra_deps = 1; break; + case 'r': remove_depfile = 1; break; default: usage(); } } @@ -405,5 +408,8 @@ int main(int argc, char *argv[]) parse_dep_file(buf, target, insert_extra_deps); free(buf); + if (remove_depfile) + unlink(depfile); + return 0; }