2014-06-18 18:00:06

by Boaz Harrosh

[permalink] [raw]
Subject: 9da0763 "kbuild: Use relative path ..." Broke my IDE

Hi Sir Michal

Below patch broke my stupid yet useful IDE tool. I use kdevelop.

kdevelop now gets confused on warnings and errors because it now comes out
as (for example):
../fs/ext4/fsync.c:63:3: error: implicit declaration of function ‘iputddd’ [-Werror=implicit-function-declaration]

>From what I understand kdevelop picks up the "[make] cd ..." outputs from make and
will interpret those for finding gcc files output. But Linux Makefile will suppress
these messages and kdevelop as no way to interpret the "../xxxx"

I do not know what other IDEs do, but this one here is not smart enough.

Could we please define a new input to Makefile that will revert to
old behavior. like:
KBUILD_FULL_PATH

let me cook up a patch tomorrow (getting late here)
Thanks
Boaz

The patch that broke it
----
>From 9da0763bdd82572be243fcf5161734f11568960f Mon Sep 17 00:00:00 2001
From: Michal Marek <[email protected]>
Date: Fri, 25 Apr 2014 23:25:18 +0200
Subject: [PATCH] kbuild: Use relative path when building in a subdir of the
source tree

When doing make O=<subdir>, use '..' to refer to the source tree. This
allows for more readable compiler messages, and, more importantly, it
sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.

Acked-by: Sam Ravnborg <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
---
Makefile | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 3e134ec..f4702c1 100644
--- a/Makefile
+++ b/Makefile
@@ -149,7 +149,17 @@ else
_all: modules
endif

-srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),.)
+ifeq ($(KBUILD_SRC),)
+ # building in the source tree
+ srctree := .
+else
+ ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
+ # building in a subdirectory of the source tree
+ srctree := ..
+ else
+ srctree := $(KBUILD_SRC)
+ endif
+endif
objtree := .
src := $(srctree)
obj := $(objtree)
--
1.9.3


2014-06-18 19:56:57

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: 9da0763 "kbuild: Use relative path ..." Broke my IDE

On Wed, Jun 18, 2014 at 11:00 AM, Boaz Harrosh <[email protected]> wrote:
> Hi Sir Michal
>
> Below patch broke my stupid yet useful IDE tool. I use kdevelop.
>
> kdevelop now gets confused on warnings and errors because it now comes out
> as (for example):
> ../fs/ext4/fsync.c:63:3: error: implicit declaration of function ‘iputddd’ [-Werror=implicit-function-declaration]
>
> From what I understand kdevelop picks up the "[make] cd ..." outputs from make and
> will interpret those for finding gcc files output. But Linux Makefile will suppress
> these messages and kdevelop as no way to interpret the "../xxxx"
>
> I do not know what other IDEs do, but this one here is not smart enough.
>
> Could we please define a new input to Makefile that will revert to
> old behavior. like:
> KBUILD_FULL_PATH
>
> let me cook up a patch tomorrow (getting late here)
> Thanks
> Boaz
>
> The patch that broke it

Boaz, thanks for the bisect.
reverting it also helps to solve 'make deb-pkg' problem I reported in
the other thread.

> ----
> From 9da0763bdd82572be243fcf5161734f11568960f Mon Sep 17 00:00:00 2001
> From: Michal Marek <[email protected]>
> Date: Fri, 25 Apr 2014 23:25:18 +0200
> Subject: [PATCH] kbuild: Use relative path when building in a subdir of the
> source tree
>
> When doing make O=<subdir>, use '..' to refer to the source tree. This
> allows for more readable compiler messages, and, more importantly, it
> sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.
>
> Acked-by: Sam Ravnborg <[email protected]>
> Signed-off-by: Michal Marek <[email protected]>
> ---
> Makefile | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 3e134ec..f4702c1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -149,7 +149,17 @@ else
> _all: modules
> endif
>
> -srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),.)
> +ifeq ($(KBUILD_SRC),)
> + # building in the source tree
> + srctree := .
> +else
> + ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
> + # building in a subdirectory of the source tree
> + srctree := ..
> + else
> + srctree := $(KBUILD_SRC)
> + endif
> +endif
> objtree := .
> src := $(srctree)
> obj := $(objtree)
> --
> 1.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-06-19 10:13:04

by Boaz Harrosh

[permalink] [raw]
Subject: kbuild: support of new KBUILD_FULL_PATH


The commit:

commit 9da0763bdd82572be243fcf5161734f11568960f
Author: Michal Marek <[email protected]>
Date: Fri Apr 25 23:25:18 2014 +0200

kbuild: Use relative path when building in a subdir of the source tree

When doing make O=<subdir>, use '..' to refer to the source tree. This
allows for more readable compiler messages, and, more importantly, it
sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.

Acked-by: Sam Ravnborg <[email protected]>
Signed-off-by: Michal Marek <[email protected]>

Broke IDEs and other tools which analyze the make output.
Introduce a new KBUILD_FULL_PATH switch to Makefile that will revert
to the old output if KBUILD_FULL_PATH=1 is specified.
The default is KBUILD_FULL_PATH=0

Is there a document I need to edit for this new parameter?

Signed-off-by: Boaz Harrosh <[email protected]>
---
Makefile | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 97b2861..778732a 100644
--- a/Makefile
+++ b/Makefile
@@ -149,11 +149,17 @@ else
_all: modules
endif

+# put KBUILD_FULL_PATH=1 if relative path to sources breaks your system
+ifneq ($(KBUILD_FULL_PATH), 1)
+ KBUILD_FULL_PATH=""
+endif
+
ifeq ($(KBUILD_SRC),)
# building in the source tree
srctree := .
else
- ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
+ # if KBUILD_FULL_PATH is not empty then condition will fail
+ ifeq ($(KBUILD_FULL_PATH)$(KBUILD_SRC)/,$(dir $(CURDIR)))
# building in a subdirectory of the source tree
srctree := ..
else
--
1.9.3

2014-06-19 10:41:45

by Michal Marek

[permalink] [raw]
Subject: Re: kbuild: support of new KBUILD_FULL_PATH

On 2014-06-19 12:12, Boaz Harrosh wrote:
>
> The commit:
>
> commit 9da0763bdd82572be243fcf5161734f11568960f
> Author: Michal Marek <[email protected]>
> Date: Fri Apr 25 23:25:18 2014 +0200
>
> kbuild: Use relative path when building in a subdir of the source tree
>
> When doing make O=<subdir>, use '..' to refer to the source tree. This
> allows for more readable compiler messages, and, more importantly, it
> sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.
>
> Acked-by: Sam Ravnborg <[email protected]>
> Signed-off-by: Michal Marek <[email protected]>
>
> Broke IDEs and other tools which analyze the make output.
> Introduce a new KBUILD_FULL_PATH switch to Makefile that will revert
> to the old output if KBUILD_FULL_PATH=1 is specified.
> The default is KBUILD_FULL_PATH=0

Parsing make output is a use case I did not think of, so the knob seems
inevitable :-/.


> Is there a document I need to edit for this new parameter?

That would be Documentation/kbuild/kbuild.txt


> Signed-off-by: Boaz Harrosh <[email protected]>
> ---
> Makefile | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 97b2861..778732a 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -149,11 +149,17 @@ else
> _all: modules
> endif
>
> +# put KBUILD_FULL_PATH=1 if relative path to sources breaks your system
> +ifneq ($(KBUILD_FULL_PATH), 1)
> + KBUILD_FULL_PATH=""
> +endif
> +
> ifeq ($(KBUILD_SRC),)
> # building in the source tree
> srctree := .
> else
> - ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
> + # if KBUILD_FULL_PATH is not empty then condition will fail
> + ifeq ($(KBUILD_FULL_PATH)$(KBUILD_SRC)/,$(dir $(CURDIR)))

This is an ugly way to express the logic.


> # building in a subdirectory of the source tree
> srctree := ..
> else

How about generated sources like asm-offsets.s or the lexer and parser
in scripts/kconfig, does kdevelop figure out where the files live? If
not, you might need to add

-objtree := .
+ifeq ($(KBUILD_FULL_PATH),1)
+ objtree := $(CURDIR)
+else
+ objtree := .
+endif

to use the full path also for the O= directory.

Michal

2014-06-19 12:01:05

by Boaz Harrosh

[permalink] [raw]
Subject: Re: kbuild: support of new KBUILD_FULL_PATH

On 06/19/2014 01:41 PM, Michal Marek wrote:
<>
>> Is there a document I need to edit for this new parameter?
>
> That would be Documentation/kbuild/kbuild.txt
>

Will send a VER2 thanks

>
>> Signed-off-by: Boaz Harrosh <[email protected]>
>> ---
>> Makefile | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 97b2861..778732a 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -149,11 +149,17 @@ else
>> _all: modules
>> endif
>>
>> +# put KBUILD_FULL_PATH=1 if relative path to sources breaks your system
>> +ifneq ($(KBUILD_FULL_PATH), 1)
>> + KBUILD_FULL_PATH=""
>> +endif
>> +
>> ifeq ($(KBUILD_SRC),)
>> # building in the source tree
>> srctree := .
>> else
>> - ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
>> + # if KBUILD_FULL_PATH is not empty then condition will fail
>> + ifeq ($(KBUILD_FULL_PATH)$(KBUILD_SRC)/,$(dir $(CURDIR)))
>
> This is an ugly way to express the logic.
>

I kind of agree. My Makefile foo is not very strong any other way I
know would duplicate code. What would you suggest?

[ Best I can think of is:

srctree := $(KBUILD_SRC)

# if KBUILD_FULL_PATH=1 then do not use relative path
ifneq ($(KBUILD_FULL_PATH), 1)
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
# building in a subdirectory of the source tree
srctree := ..
endif
endif


Is this better?
]

>
>> # building in a subdirectory of the source tree
>> srctree := ..
>> else
>
> How about generated sources like asm-offsets.s or the lexer and parser
> in scripts/kconfig, does kdevelop figure out where the files live? If
> not, you might need to add
>
> -objtree := .
> +ifeq ($(KBUILD_FULL_PATH),1)
> + objtree := $(CURDIR)
> +else
> + objtree := .
> +endif
>
> to use the full path also for the O= directory.
>

I would not care for those at all. The important is those files that
you need to point and edit to fix stuff. The generated files I better
not edit usually. The edit is in some other place, right?

> Michal
>

I saw that this patch caused other breakage as well. Will you be
fixing those? Do you want to own this or you still need a ver2
of this patch?

Thanks
Boaz

2014-06-19 13:14:26

by Michal Marek

[permalink] [raw]
Subject: Re: kbuild: support of new KBUILD_FULL_PATH

Dne 19.6.2014 14:01, Boaz Harrosh napsal(a):
> On 06/19/2014 01:41 PM, Michal Marek wrote:
>>> Signed-off-by: Boaz Harrosh <[email protected]>
>>> - ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
>>> + # if KBUILD_FULL_PATH is not empty then condition will fail
>>> + ifeq ($(KBUILD_FULL_PATH)$(KBUILD_SRC)/,$(dir $(CURDIR)))
>>
>> This is an ugly way to express the logic.
>>
>
> I kind of agree. My Makefile foo is not very strong any other way I
> know would duplicate code. What would you suggest?
>
> [ Best I can think of is:
>
> srctree := $(KBUILD_SRC)
>
> # if KBUILD_FULL_PATH=1 then do not use relative path
> ifneq ($(KBUILD_FULL_PATH), 1)
> ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
> # building in a subdirectory of the source tree
> srctree := ..
> endif
> endif
>
>
> Is this better?

Definitely.


>> How about generated sources like asm-offsets.s or the lexer and parser
>> in scripts/kconfig, does kdevelop figure out where the files live? If
>> not, you might need to add
>>
>> -objtree := .
>> +ifeq ($(KBUILD_FULL_PATH),1)
>> + objtree := $(CURDIR)
>> +else
>> + objtree := .
>> +endif
>>
>> to use the full path also for the O= directory.
>>
>
> I would not care for those at all. The important is those files that
> you need to point and edit to fix stuff. The generated files I better
> not edit usually. The edit is in some other place, right?

Fair enough.


> I saw that this patch caused other breakage as well. Will you be
> fixing those? Do you want to own this or you still need a ver2
> of this patch?

I already sent three fixes to Linus:
https://lkml.org/lkml/2014/6/18/664. There is one more brekage that
Alexei is seeing with deb-pkg, but this needs further investigation.
Anyway, either send a v2 or tell me and I will fold the above change to
the first version of your patch.

Michal

2014-06-19 14:53:05

by Boaz Harrosh

[permalink] [raw]
Subject: [PATCH] kbuild: support of new KBUILD_FULL_PATH


The commit 9da0763bdd82572be243fcf5161734f11568960f

kbuild: Use relative path when building in a subdir of the source tree

When doing make O=<subdir>, use '..' to refer to the source tree. This
allows for more readable compiler messages, and, more importantly, it
sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.

Acked-by: Sam Ravnborg <[email protected]>
Signed-off-by: Michal Marek <[email protected]>

Broke IDEs and other tools which analyze the make output.
Introduce a new KBUILD_FULL_PATH switch to Makefile that will revert
to the old output if KBUILD_FULL_PATH=1 is specified.
The default is KBUILD_FULL_PATH=0

Signed-off-by: Boaz Harrosh <[email protected]>
---
Documentation/kbuild/kbuild.txt | 9 +++++++++
Makefile | 13 ++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 6466704..9133b47 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -77,6 +77,15 @@ Specify the output directory when building the kernel.
The output directory can also be specified using "O=...".
Setting "O=..." takes precedence over KBUILD_OUTPUT.

+KBUILD_FULL_PATH
+--------------------------------------------------
+Since Linux v3.16-rc1 the Kernel build system prefers to use
+relative paths when supplying file-paths to gcc and other
+tools. This will break IDEs and other environments that would
+parse the gcc output to find files and lines.
+Use KBUILD_FULL_PATH=1 on make command line to revert to old
+way of feeding tools with full-paths.
+
KBUILD_DEBARCH
--------------------------------------------------
For the deb-pkg target, allows overriding the normal heuristics deployed by
diff --git a/Makefile b/Makefile
index 97b2861..51fcebd 100644
--- a/Makefile
+++ b/Makefile
@@ -153,11 +153,14 @@ ifeq ($(KBUILD_SRC),)
# building in the source tree
srctree := .
else
- ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
- # building in a subdirectory of the source tree
- srctree := ..
- else
- srctree := $(KBUILD_SRC)
+ srctree := $(KBUILD_SRC)
+
+ # if KBUILD_FULL_PATH=1 then do not use relative path
+ ifneq ($(KBUILD_FULL_PATH), 1)
+ ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
+ # building in a subdirectory of the source tree
+ srctree := ..
+ endif
endif
endif
objtree := .
--
1.9.3

2014-06-19 14:59:56

by Boaz Harrosh

[permalink] [raw]
Subject: Re: [PATCH] kbuild: support of new KBUILD_FULL_PATH

On 06/19/2014 05:52 PM, Boaz Harrosh wrote:
>
> The commit 9da0763bdd82572be243fcf5161734f11568960f
>
> kbuild: Use relative path when building in a subdir of the source tree
>
> When doing make O=<subdir>, use '..' to refer to the source tree. This
> allows for more readable compiler messages, and, more importantly, it
> sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter.
>
> Acked-by: Sam Ravnborg <[email protected]>
> Signed-off-by: Michal Marek <[email protected]>
>
> Broke IDEs and other tools which analyze the make output.
> Introduce a new KBUILD_FULL_PATH switch to Makefile that will revert
> to the old output if KBUILD_FULL_PATH=1 is specified.
> The default is KBUILD_FULL_PATH=0
>
> Signed-off-by: Boaz Harrosh <[email protected]>

Thanks Sir Michal

Please feel free to check out my broken grammar and change
what you see fit.

BTW: The old system was sensitive to absolute paths so if
I compile on local machine say at:
/home/boaz/dev/lin/
but then go to a network station and do "make install" in:
/mnt/boaz/home/boaz/dev/lin/

The build would attempt to rebuild everything what I do
is cd /net/boaz/home/boaz/dev on local and remote so the
make just works. Your patch actually fixed that ;-)

Thanks
Boaz

> ---
> Documentation/kbuild/kbuild.txt | 9 +++++++++
> Makefile | 13 ++++++++-----
> 2 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
> index 6466704..9133b47 100644
> --- a/Documentation/kbuild/kbuild.txt
> +++ b/Documentation/kbuild/kbuild.txt
> @@ -77,6 +77,15 @@ Specify the output directory when building the kernel.
> The output directory can also be specified using "O=...".
> Setting "O=..." takes precedence over KBUILD_OUTPUT.
>
> +KBUILD_FULL_PATH
> +--------------------------------------------------
> +Since Linux v3.16-rc1 the Kernel build system prefers to use
> +relative paths when supplying file-paths to gcc and other
> +tools. This will break IDEs and other environments that would
> +parse the gcc output to find files and lines.
> +Use KBUILD_FULL_PATH=1 on make command line to revert to old
> +way of feeding tools with full-paths.
> +
> KBUILD_DEBARCH
> --------------------------------------------------
> For the deb-pkg target, allows overriding the normal heuristics deployed by
> diff --git a/Makefile b/Makefile
> index 97b2861..51fcebd 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -153,11 +153,14 @@ ifeq ($(KBUILD_SRC),)
> # building in the source tree
> srctree := .
> else
> - ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
> - # building in a subdirectory of the source tree
> - srctree := ..
> - else
> - srctree := $(KBUILD_SRC)
> + srctree := $(KBUILD_SRC)
> +
> + # if KBUILD_FULL_PATH=1 then do not use relative path
> + ifneq ($(KBUILD_FULL_PATH), 1)
> + ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
> + # building in a subdirectory of the source tree
> + srctree := ..
> + endif
> endif
> endif
> objtree := .
>