From patchwork Sat Jun 10 16:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 105979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1631987vqr; Sat, 10 Jun 2023 09:27:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6k3hM68fwSIwauNCNS3sGXrgEEK7s0E8yDm/znuZaKUj6up3IjJQ/YoJgObSS53gsGTSVi X-Received: by 2002:a05:6402:6d0:b0:514:8eb7:d587 with SMTP id n16-20020a05640206d000b005148eb7d587mr1272134edy.17.1686414436792; Sat, 10 Jun 2023 09:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686414436; cv=none; d=google.com; s=arc-20160816; b=bUfOwDHSMfik41kVSU2b29dVsh6aO/6zXb5eaAVfCuWLa3dYIOL/K/mv6GP02rwz6h SU1Tlk6IMOGfyrsWBr3z7Nvf7cYSs8AJfTFTGB4WtkCmPsYnsrz8GoOTgOJtYuFRo0i/ Tct0pfVfn3/2R6x2YUM3vSnHZbxBVj87kveup0TO77UG7GNwIdjvlLYJN68TffQZg0f8 XyE0FCzIwCQtqMbiD7QlAn1i0k8JsvCKQV4YbRdJGbvpMtKWYgcMhTCGV0NguTyKva6d MnBeK+RiZp7ER8E9sdWqJHB2TpiThEbrub6vn+IEQ49mh8ugAHDQtrbZZm3WAmWUWh/L 2jLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=w4wIbqIe46d7M/i1YQtpWjRYY/rkkLeuknRrMcEqRVo=; b=xB7p89SiLrRnzsb6Uoj6ZzVTjbTPsbKTma/QQ5Z47HL5r26EkzpGqoDaSaKodZ3DOu wS40cLdnUaZOKccbdXtzikhB2M2NKvdkmre2pkI+SQZpeGz1hIo68I6MkOzVJDYVLtrl M0Bkk5ajbc6T2n/mRBNJRs/4vKS4IJ0q5/fEtuUUuMWpwBAPVIY9ZfSAVR7h5UpcM0ft o8HApUmiTNp/os0CV1ajX2CQ6azgosqr68sNL20ToGxJdcSmlisYEWeox7gY5J1oUddd I/iC5WHKCsgjFo+asTCuj4J1o6VQShpEGJqM/AYHwjp/ZjaTHbn7KHi6uBtVxwiT9beD 9+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H0TwLYCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020aa7df88000000b0051641f6ec34si3811900edy.452.2023.06.10.09.26.51; Sat, 10 Jun 2023 09:27:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H0TwLYCx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjFJQSG (ORCPT + 99 others); Sat, 10 Jun 2023 12:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229905AbjFJQR4 (ORCPT ); Sat, 10 Jun 2023 12:17:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B31E5421B; Sat, 10 Jun 2023 09:17:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF2A4619AC; Sat, 10 Jun 2023 16:17:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DE7C433EF; Sat, 10 Jun 2023 16:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686413841; bh=cwe7A4zfkcXQUnvweZ3lV0jtq7ys0o2b40JuaMCUZYk=; h=From:To:Cc:Subject:Date:From; b=H0TwLYCx+bx5rIb7tEOz5QGFcHy15y6S8G6ZQXDqhPCxWs8aXWCzcVrJsQI8EZIFn thw3DEr+JxdSWB0VhwMoID70sdPb3UP1h2xPfQmjyOR6x0HkBY1W2Nj2kXg9lFJ67Q 8jk0eAOmK4dxQarOrugv/bLx3/DxIk1d1+uJZEqNrIHfXrKMqPfUKoy/1GBKWz9h0E nnRxGJtj9UAn6WcHCRFjeJvfa6caQETOjsFotcsB01tweLQHzWiSq+v/9DOl7q3qjZ bOWuN9rPvLny+337PjWCGANemEm8HolcO5bP4fc12UF+ifXwOABjXgU1jY5ecrhbai OI7oj510jkN8A== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , David Howells , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH] kbuild: revive "Entering directory" for Make >= 4.4.1 Date: Sun, 11 Jun 2023 01:17:11 +0900 Message-Id: <20230610161711.1094231-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768333704131553836?= X-GMAIL-MSGID: =?utf-8?q?1768333704131553836?= With commit 9da0763bdd82 ("kbuild: Use relative path when building in a subdir of the source tree"), compiler messages in out-of-tree builds include relative paths, which are relative to the build directory, not the directory where make was started. To help IDEs/editors find the source files, Kbuild lets GNU Make print "Entering directory ..." when it changes the working directory. It has been working fine for a long time, but David reported it is broken with GNU Make 4.4.1. The behavior was changed by GNU Make commit 8f9e7722ff0f ("[SV 63537] Fix setting -w in makefiles"). Previously, setting --no-print-directory to MAKEFLAGS only affected child makes, but it is now interpreted in the current make as soon as it is set. [test code] $ cat /tmp/Makefile MAKEFLAGS += --no-print-directory all: ; : [before 8f9e7722ff0f] $ make -C /tmp make: Entering directory '/tmp' : make: Leaving directory '/tmp' [after 8f9e7722ff0f] $ make -C /tmp : This commit restores the previous behavior for GNU Make >= 4.4.1. Reported-by: David Howells Closes: https://lore.kernel.org/all/2427604.1686237298@warthog.procyon.org.uk/ Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cc3fe09c4dec..9868186deb66 100644 --- a/Makefile +++ b/Makefile @@ -191,7 +191,7 @@ endif # ifneq ($(KBUILD_OUTPUT),) ifeq ($(abs_objtree),$(CURDIR)) # Suppress "Entering directory ..." unless we are changing the work directory. -MAKEFLAGS += --no-print-directory +no-print-directory := --no-print-directory else need-sub-make := 1 endif @@ -203,6 +203,15 @@ ifneq ($(words $(subst :, ,$(abs_srctree))), 1) $(error source directory cannot contain spaces or colons) endif +ifneq ($(filter jobserver-fifo,$(.FEATURES)),) # test $(MAKE_VERSION) >= 4.4 +ifeq ($(filter 4.4,$(MAKE_VERSION)),) +# With GNU Make >= 4.4.1, a change in MAKEFLAGS takes effect as soon as it is +# set. Run __sub-make all the time so that we can pass --no-print-directory +# via the command line. +need-sub-make := 1 +endif +endif + ifneq ($(filter 3.%,$(MAKE_VERSION)),) # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x # We need to invoke sub-make to avoid implicit rules in the top Makefile. @@ -223,7 +232,8 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make # Invoke a second make in the output directory, passing relevant variables __sub-make: - $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) + $(Q)$(MAKE) $(no-print-directory) -C $(abs_objtree) \ + -f $(abs_srctree)/Makefile $(MAKECMDGOALS) endif # need-sub-make endif # sub_make_done @@ -234,6 +244,8 @@ ifeq ($(need-sub-make),) # Do not print "Entering directory ...", # but we want to display it when entering to the output directory # so that IDEs/editors are able to understand relative filenames. +# This line is needed to allow Make < 4.4.1 to skip __sub-make. +# The newer Make versions runs __sub-make before seeing this line. MAKEFLAGS += --no-print-directory ifeq ($(abs_srctree),$(abs_objtree))