Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp298480imm; Wed, 18 Jul 2018 02:17:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdXE2avHmHMAzPBTR0PIsS+E1GHQC9NcQOrvs/uFsWfy8qm+j96ZvhWd8TbknYBLyfgJgqv X-Received: by 2002:a62:9683:: with SMTP id s3-v6mr4368245pfk.191.1531905436314; Wed, 18 Jul 2018 02:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531905436; cv=none; d=google.com; s=arc-20160816; b=Ua9hnGMCCNIjazxPuc4IxVcQ6FTwfx1mzYJoK9numyRqPf58W1mSYrjgfldpBY8ZBO pWP/Rm0KQQ/ZXbCFENYOsCCVGoM6Z/Md4yCe+k7aSkqmKgGOJTsYd/bAwJJNLfFZSWcJ mk6eger+GZFf6sgJOvhIbwALuM4NIrRDclCFYFvfJaWOAwAaOaHoM9nOgc2hfdUu9kBF Bta1dKA98NtxLNndLa6JpoBCMvGl6yFcNNObv057ADtVSUy9hhIcDVCyGTGUY5T1T9HZ HklNBmVz8m7oHKNBWZkR9AGUkzINj9CmfbxrVv6zZzgH9iNMjZWysz7grHQGSTY2daI7 Y0yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=DMj9rHzJmhwV7x6PIt5iQz9l1pFnH3mEuJvgJCvH5Oc=; b=vlgwyFZ6emrlxSE/XcY2ad08YWS2bJqJS9IBAg1hMAPqqMIIy8dafFaeA/AMzfPAhj 2UQqQNP/AFVmH/osWbnJHJCUIAdifDCDsBYPVU2rUtvZ+jdnqtYdLBVor9Bpv8c41xvu IdM2N+06Tbf3EtY+bDvTQF+DgWn/FvQpJP9UdkontKp46ca02YlGpS2V1sRbt+PYT4y3 F8kCd4Fm9aY9S/a4NOLnmJRLIOpxcT0Lvy89X57t1bY1dv3p4DdJMLxvirolbCyf5zWs drhiC373/2sbljMuDgTJTXV3SoNyCnP5+FOw2TcCcB3FQWEoiOxjFaeCQPCqb3MLHh31 QjcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gouders.net header.s=gnet header.b=LWTdsita; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si2812265plk.49.2018.07.18.02.17.01; Wed, 18 Jul 2018 02:17:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gouders.net header.s=gnet header.b=LWTdsita; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730749AbeGRJxT (ORCPT + 99 others); Wed, 18 Jul 2018 05:53:19 -0400 Received: from services.gouders.net ([141.101.32.176]:33092 "EHLO services.gouders.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730598AbeGRJxT (ORCPT ); Wed, 18 Jul 2018 05:53:19 -0400 Received: from lena.gouders.net ([193.175.198.193]) (authenticated bits=0) by services.gouders.net (8.14.8/8.14.8) with ESMTP id w6I9DuD7028581 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 18 Jul 2018 11:14:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gouders.net; s=gnet; t=1531905247; bh=Ttig7I4bBJY7gQ+/MLdt4XgYmszpqezZ2QsOmkEC3UU=; h=From:To:Cc:Subject:Date; b=LWTdsitapnQ9qUkw6IhTbQ/YZa+DcUs7dJSLL5Ce13Z3k8dVXuv+hP9dhQSfevtoX Dv7tWF1xQdX7M7NBg1OJ01m2hycSBRf3Z/17ENRExqMBwI7pBefjIPPN8HMBgRPAoV Jg08S+PAcD/hR6x19MiwLDiuz+B5k+cYlsQm1YYo= From: Dirk Gouders To: Masahiro Yamada , Jonathan Corbet Cc: Dirk Gouders , linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild: if_changed: document single use per target limitation Date: Wed, 18 Jul 2018 11:13:36 +0200 Message-Id: <20180718091336.4540-1-dirk@gouders.net> X-Mailer: git-send-email 2.16.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Users of if_changed could easily feel invited to use it to divide a recipe into parts like: a: prereq FORCE $(call if_changed,do_a) $(call if_changed,do_b) But this is problematic, because if_changed should not be used more than once per target: in the above example, if_changed stores the command-line of the given command in .a.cmd and when a is up-to-date with respect to prereq, the file .a.cmd contains the command-line for the last command executed, i.e. do_b. When the recipe is then executed again, without any change of prerequisites, the command-line check for do_a will fail, do_a will be executed and stored in .a.cmd. The next check, however, will still see the old content (the file isn't re-read) and if_changed will skip do_b, because the command-line test will not recognize a change. On the next execution of the recipe the roles will flip: do_a is OK but do_b not and it will be executed. And so on... Signed-off-by: Dirk Gouders --- Documentation/kbuild/makefiles.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 048fc39a6b91..01fae5a01ce7 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -1105,6 +1105,12 @@ When kbuild executes, the following steps are followed (roughly): target: source(s) FORCE #WRONG!# $(call if_changed, ld/objcopy/gzip/...) + Note: if_changed should not be used more than once per target. + It stores the executed command in a corresponding .cmd + file and multiple calls would result in overwrites and + unwanted results when the target is up to date and only the + tests on changed commands trigger execution of commands. + ld Link target. Often, LDFLAGS_$@ is used to set specific options to ld. -- 2.16.1