Skip to contentSkip to conversation

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

RFC PATCH In review David Howells 2 participants 2 messages Jun 8, 2023 – Jun 9, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 build: Deal with change in "make --no-print-directory" behaviour change

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.

cc Masahiro Yamada <[email protected]>
cc Nathan Chancellor <[email protected]>
cc Nick Desaulniers <[email protected]>
cc Nicolas Schier <[email protected]>
---
 Makefile |    1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 836643eaefee..7f7c75087626 100644
@@ -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
#1 lore raw
Quoted 17 lines · David Howells

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:

Quoted 9 lines

[/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 <[email protected]>
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.

Quoted 47 lines

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.

cc Masahiro Yamada <[email protected]>
cc Nathan Chancellor <[email protected]>
cc Nick Desaulniers <[email protected]>
cc Nicolas Schier <[email protected]>
---
 Makefile |    1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 836643eaefee..7f7c75087626 100644
@@ -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
Signature · 2 lines
Best Regards
Masahiro Yamada