diff mbox series

[RFC] build: Deal with change in "make --no-print-directory" behaviour change

Message ID 2427604.1686237298@warthog.procyon.org.uk (mailing list archive)
State New, archived
Headers show
Series [RFC] build: Deal with change in "make --no-print-directory" behaviour change | expand

Commit Message

David Howells June 8, 2023, 3:14 p.m. UTC
Hi Masahiro & the kbuild crew,

Here's a patch to fix a change in make behaviour in make-4.4.  It's almost
certainly the wrong solution, but it works for me for now.

Note that I tried just adding "--print-directory" to the $(MAKE) line after
the line I added, and that does seem to work - but it then prints a lot of
additional "entering directory" lines (though they all seem to be the same).

David
---
Emacs (and probably other IDEs) parse the "make: Entering directory" lines
in the build output so that they can correctly resolve relative pathnames
in messages from the compiler.  However, a change in make has broken this.
I think it might be:

        [/usr/share/doc/make/NEWS]
        ...
        Version 4.4 (31 Oct 2022)
        ...
        * WARNING: Backward-incompatibility!
          Previously if --no-print-directory was seen anywhere in the environment or
          command line it would take precedence over any --print-directory.  Now, the
          last setting of directory printing options seen will be used, so a command
          line such as "--no-print-directory -w" _will_ show directory entry/exits.

Doing a kernel build now only prints the directory passed to the "-C" flag
if present and no other directories.  This includes any build directory
indicated with "O=".  So if I do:

        make -C /my/data/linux O=build

I see:

        make: Entering directory '/my/data/linux'

and all the path in messages emitted by the compiler are prefixed with ".."
- but then doing "M-x next-error" in emacs will prompt emacs to ask where
the file is rather than jumping to it because it can't find it.

On the previous version of Fedora with make-4.3, an extra line is emitted
by make:

        make[1]: Entering directory '/my/data/linux/build'

and that was sufficient for emacs to be able to resolve paths.

Fix this by manually printing the missing line.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Masahiro Yamada <masahiroy@kernel.org>
cc: Nathan Chancellor <nathan@kernel.org>
cc: Nick Desaulniers <ndesaulniers@google.com>
cc: Nicolas Schier <nicolas@fjasle.eu>
cc: linux-kbuild@vger.kernel.org
---
 Makefile |    1 +
 1 file changed, 1 insertion(+)

Comments

Masahiro Yamada June 9, 2023, 8:03 a.m. UTC | #1
On Fri, Jun 9, 2023 at 12:15 AM David Howells <dhowells@redhat.com> wrote:
>
> Hi Masahiro & the kbuild crew,
>
> Here's a patch to fix a change in make behaviour in make-4.4.  It's almost
> certainly the wrong solution, but it works for me for now.
>
> Note that I tried just adding "--print-directory" to the $(MAKE) line after
> the line I added, and that does seem to work - but it then prints a lot of
> additional "entering directory" lines (though they all seem to be the same).
>
> David
> ---
> Emacs (and probably other IDEs) parse the "make: Entering directory" lines
> in the build output so that they can correctly resolve relative pathnames
> in messages from the compiler.  However, a change in make has broken this.
> I think it might be:
>
>         [/usr/share/doc/make/NEWS]
>         ...
>         Version 4.4 (31 Oct 2022)
>         ...
>         * WARNING: Backward-incompatibility!
>           Previously if --no-print-directory was seen anywhere in the environment or
>           command line it would take precedence over any --print-directory.  Now, the
>           last setting of directory printing options seen will be used, so a command
>           line such as "--no-print-directory -w" _will_ show directory entry/exits.

I do not think this is it.




GNU make 4.4 is OK, but 4.4.1 is weird.


git bisect points this one:


commit 8f9e7722ff0f80d9f6ae9aba350ae02c3c6db878
Author: Dmitry Goncharov <dgoncharov@users.sf.net>
Date:   Sun Dec 18 09:49:34 2022 -0500

    [SV 63537] Fix setting -w in makefiles



I will ask in the GNU Make community if this is intentional.





>
> Doing a kernel build now only prints the directory passed to the "-C" flag
> if present and no other directories.  This includes any build directory
> indicated with "O=".  So if I do:
>
>         make -C /my/data/linux O=build
>
> I see:
>
>         make: Entering directory '/my/data/linux'
>
> and all the path in messages emitted by the compiler are prefixed with ".."
> - but then doing "M-x next-error" in emacs will prompt emacs to ask where
> the file is rather than jumping to it because it can't find it.
>
> On the previous version of Fedora with make-4.3, an extra line is emitted
> by make:
>
>         make[1]: Entering directory '/my/data/linux/build'
>
> and that was sufficient for emacs to be able to resolve paths.
>
> Fix this by manually printing the missing line.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Masahiro Yamada <masahiroy@kernel.org>
> cc: Nathan Chancellor <nathan@kernel.org>
> cc: Nick Desaulniers <ndesaulniers@google.com>
> cc: Nicolas Schier <nicolas@fjasle.eu>
> cc: linux-kbuild@vger.kernel.org
> ---
>  Makefile |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/Makefile b/Makefile
> index 836643eaefee..7f7c75087626 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -223,6 +223,7 @@ $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
>
>  # Invoke a second make in the output directory, passing relevant variables
>  __sub-make:
> +       @echo "make[1]: Entering directory '$(abs_objtree)'"
>         $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
>
>  endif # need-sub-make
>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 836643eaefee..7f7c75087626 100644
--- a/Makefile
+++ b/Makefile
@@ -223,6 +223,7 @@  $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
 
 # Invoke a second make in the output directory, passing relevant variables
 __sub-make:
+	@echo "make[1]: Entering directory '$(abs_objtree)'"
 	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
 
 endif # need-sub-make