diff mbox

Fix compiler message generation

Message ID 20140702124016.GA26965@sepie.suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Marek July 2, 2014, 12:40 p.m. UTC
On Wed, Jul 02, 2014 at 11:56:46AM +0100, David Howells wrote:
> The following commit:
> 
> 	commit 9da0763bdd82572be243fcf5161734f11568960f
> 	Author: Michal Marek <mmarek@suse.cz>
> 	Date:   Fri Apr 25 23:25:18 2014 +0200
> 	Subject: kbuild: Use relative path when building in a subdir of the source tree
> 
> makes compiler messages relative to the *build* tree if the build tree is a
> subdirectory at the root of the source tree.
> 
> This is the wrong thing to do since the make command is issued in the *source*
> tree and so any editor or IDE that issues the make command will likely expect
> paths in warnings and errors to be relative either to the current directory at
> the time the make was issued or to the directory in which make was run.
> 
> Certainly, this is something I'm seeing with emacs.  I do:
> 
> 	LANG=C nice -19 make O=build -C /data/fs/linux-2.6-fscache -j4
> 
> And then I get error messages that look like:
> 
> 	../fs/namei.c: In function 'SYSC_linkat':
> 	../fs/namei.c:4836:57: error: expected declaration specifiers before 'x'
> 		int, newdfd, const char __user *, newname, int, flags)x
> 
> which emacs can't find the source for because it doesn't relate to anything
> emacs knows about.
> 
> As a temporary measure, fix this by substituting the full path of the source
> as make knows it.

Boaz Harrosh hit the same problem with kdevelop and posted a patch that
adds a variable to turn off relative paths:
https://lkml.org/lkml/2014/6/19/295. This has the downside that one has
to remember to set the variable.

However, VPATH builds are not that uncommon, so I guess the editors and
IDEs can actually handle them if make prints the "Entering directory
`blah/blah'" messages. We disable this in kbuild to not pollute the log,
but how about the following patch? I tried it with vim and it worked:


From 5b59dcacf358f143b9fb39d2f788142ab9ba3e00 Mon Sep 17 00:00:00 2001
From: Michal Marek <mmarek@suse.cz>
Date: Wed, 2 Jul 2014 14:28:26 +0200
Subject: [PATCH] kbuild: Print the name of the build directory

With commit 9da0763b (kbuild: Use relative path when building in a
subdir of the source tree), the compiler messages include relative
paths. These are however relative to the build directory, not the
directory where make was started. Print the "Entering directory ..."
message once, so that IDEs/editors can find the source files.

Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Howells July 2, 2014, 1:34 p.m. UTC | #1
Michal Marek <mmarek@suse.cz> wrote:

> From 5b59dcacf358f143b9fb39d2f788142ab9ba3e00 Mon Sep 17 00:00:00 2001
> From: Michal Marek <mmarek@suse.cz>
> Date: Wed, 2 Jul 2014 14:28:26 +0200
> Subject: [PATCH] kbuild: Print the name of the build directory
> 
> With commit 9da0763b (kbuild: Use relative path when building in a
> subdir of the source tree), the compiler messages include relative
> paths. These are however relative to the build directory, not the
> directory where make was started. Print the "Entering directory ..."
> message once, so that IDEs/editors can find the source files.
> 
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 97b2861..40544a0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -126,7 +126,10 @@ PHONY += $(MAKECMDGOALS) sub-make
>  $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
>  	@:
>  
> +# Fake the "Entering directory" message once, so that IDEs/editors are
> +# able to understand relative filenames.
>  sub-make: FORCE
> +	@echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
>  	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
>  	KBUILD_SRC=$(CURDIR) \
>  	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \

Works for me with emacs.

Acked-by: David Howells <dhowells@redhat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh July 16, 2014, 4:15 p.m. UTC | #2
On 07/02/2014 03:40 PM, Michal Marek wrote:
<>
>>From 5b59dcacf358f143b9fb39d2f788142ab9ba3e00 Mon Sep 17 00:00:00 2001
> From: Michal Marek <mmarek@suse.cz>
> Date: Wed, 2 Jul 2014 14:28:26 +0200
> Subject: [PATCH] kbuild: Print the name of the build directory
> 
> With commit 9da0763b (kbuild: Use relative path when building in a
> subdir of the source tree), the compiler messages include relative
> paths. These are however relative to the build directory, not the
> directory where make was started. Print the "Entering directory ..."
> message once, so that IDEs/editors can find the source files.
> 
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Makefile b/Makefile
> index 97b2861..40544a0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -126,7 +126,10 @@ PHONY += $(MAKECMDGOALS) sub-make
>  $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
>  	@:
>  
> +# Fake the "Entering directory" message once, so that IDEs/editors are
> +# able to understand relative filenames.
>  sub-make: FORCE
> +	@echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
>  	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
>  	KBUILD_SRC=$(CURDIR) \
>  	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \
> 

Sir Michal, sorry for the late response

This patch by itself works with kdevelop so I hope you did not submit my crap
KBUILD_FULL_PATH patch at all and only added this one (and I know, the fix to this
one with the -s)

For me I do not have use for KBUILD_FULL_PATH so I do not see any point for it.

Also not that I like your patches because now I can compile the same directory
from different machines with different absolute paths to the source and the
compilation will come out the same. (before changed absolute path would cause
a rebuild)

Thanks
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek July 17, 2014, 9:09 a.m. UTC | #3
On 2014-07-16 18:15, Boaz Harrosh wrote:
> This patch by itself works with kdevelop so I hope you did not submit my crap
> KBUILD_FULL_PATH patch at all and only added this one (and I know, the fix to this
> one with the -s)

Yes, I did not merge the KBUILD_FULL_PATH patch, because the approach
with the make message works out of the box.


> Also not that I like your patches because now I can compile the same directory
> from different machines with different absolute paths to the source and the
> compilation will come out the same. (before changed absolute path would cause
> a rebuild)

That's a nice side effect which I did not realize initially ;).

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh July 17, 2014, 9:46 a.m. UTC | #4
On 07/17/2014 12:09 PM, Michal Marek wrote:
> On 2014-07-16 18:15, Boaz Harrosh wrote:
>> This patch by itself works with kdevelop so I hope you did not submit my crap
>> KBUILD_FULL_PATH patch at all and only added this one (and I know, the fix to this
>> one with the -s)
> 
> Yes, I did not merge the KBUILD_FULL_PATH patch, because the approach
> with the make message works out of the box.
> 
> 
>> Also not that I like your patches because now I can compile the same directory
>> from different machines with different absolute paths to the source and the
>> compilation will come out the same. (before changed absolute path would cause
>> a rebuild)
> 

Rrrr I hope you understood that not => Note above. I *do* like your patch a lot

> That's a nice side effect which I did not realize initially ;).
> 

I guess this is everywhere that has __FILE__ in code needs to be rebuilt
So it is more in debug builds than ndebug.

> Michal
> 

Ye cool thanks, all is well
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 97b2861..40544a0 100644
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,10 @@  PHONY += $(MAKECMDGOALS) sub-make
 $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
 	@:
 
+# Fake the "Entering directory" message once, so that IDEs/editors are
+# able to understand relative filenames.
 sub-make: FORCE
+	@echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'"
 	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
 	KBUILD_SRC=$(CURDIR) \
 	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \