* [RFC PATCH 3/6] kbuild: convert include and source paths
@ 2008-05-05 15:24 Peter Oberparleiter
2008-05-05 19:58 ` Sam Ravnborg
2008-05-06 4:32 ` Andrew Morton
0 siblings, 2 replies; 5+ messages in thread
From: Peter Oberparleiter @ 2008-05-05 15:24 UTC (permalink / raw)
To: linux-kernel; +Cc: ltp-list, ltp-coverage, Andrew Morton, sam
From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
Modify kbuild to convert relative include and source paths to absolute
form. Also change the module versioning mechanism to alter object file
names only after compiling.
Required by the gcov profiling infrastructure: source paths are
referenced by the compiled object files. Using relative paths or
object file names which are different from the source name would
prevent the gcov tool from finding the corresponding source files.
Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
---
Makefile | 6 +++---
scripts/Kbuild.include | 2 ++
scripts/Makefile.build | 7 +++++--
scripts/Makefile.lib | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
Index: linux-2.6.26-rc1/scripts/Makefile.build
===================================================================
--- linux-2.6.26-rc1.orig/scripts/Makefile.build
+++ linux-2.6.26-rc1/scripts/Makefile.build
@@ -167,7 +167,8 @@ $(obj)/%.symtypes : $(src)/%.c FORCE
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
ifndef CONFIG_MODVERSIONS
-cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
+cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ \
+ $(if $(filter-out /%,$<),$(objtree)/$<,$<)
else
# When module versioning is enabled the following steps are executed:
@@ -182,7 +183,9 @@ else
# replace the unresolved symbols __crc_exported_symbol with
# the actual value of the checksum generated by genksyms
-cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
+cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/$(@F) \
+ $(if $(filter-out /%,$<),$(objtree)/$<,$<) ; \
+ mv -f $(@D)/$(@F) $(@D)/.tmp_$(@F)
cmd_modversions = \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
$(CPP) -D__GENKSYMS__ $(c_flags) $< \
Index: linux-2.6.26-rc1/scripts/Makefile.lib
===================================================================
--- linux-2.6.26-rc1.orig/scripts/Makefile.lib
+++ linux-2.6.26-rc1/scripts/Makefile.lib
@@ -113,7 +113,7 @@ else
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
# and locates generated .h files
# FIXME: Replace both with specific CFLAGS* statements in the makefiles
-__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
+__c_flags = $(call addtree,-I$(obj)) $(call addtree2,-I$(obj)) $(call flags,_c_flags)
__a_flags = $(call flags,_a_flags)
__cpp_flags = $(call flags,_cpp_flags)
endif
Index: linux-2.6.26-rc1/scripts/Kbuild.include
===================================================================
--- linux-2.6.26-rc1.orig/scripts/Kbuild.include
+++ linux-2.6.26-rc1/scripts/Kbuild.include
@@ -145,6 +145,8 @@ build := -f $(if $(KBUILD_SRC),$(srctree
# Prefix -I with $(srctree) if it is not an absolute path.
addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))
+# Prefix -I with $(objtree) if it is not an absolute path.
+addtree2 = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(objtree)/%,$(1)),$(1))
# Find all -I options and call addtree
flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
Index: linux-2.6.26-rc1/Makefile
===================================================================
--- linux-2.6.26-rc1.orig/Makefile
+++ linux-2.6.26-rc1/Makefile
@@ -324,9 +324,9 @@ AFLAGS_KERNEL =
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
-LINUXINCLUDE := -Iinclude \
- $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
- -include include/linux/autoconf.h
+LINUXINCLUDE := -I$(objtree)/include -I$(srctree) -I$(objtree) \
+ $(if $(KBUILD_SRC),-I$(objtree)/include2 \
+ -I$(srctree)/include) -include include/linux/autoconf.h
KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 3/6] kbuild: convert include and source paths
2008-05-05 15:24 [RFC PATCH 3/6] kbuild: convert include and source paths Peter Oberparleiter
@ 2008-05-05 19:58 ` Sam Ravnborg
2008-05-06 17:03 ` Peter Oberparleiter
2008-05-06 4:32 ` Andrew Morton
1 sibling, 1 reply; 5+ messages in thread
From: Sam Ravnborg @ 2008-05-05 19:58 UTC (permalink / raw)
To: Peter Oberparleiter; +Cc: linux-kernel, ltp-list, ltp-coverage, Andrew Morton
On Mon, May 05, 2008 at 05:24:26PM +0200, Peter Oberparleiter wrote:
> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>
> Modify kbuild to convert relative include and source paths to absolute
> form. Also change the module versioning mechanism to alter object file
> names only after compiling.
>
> Required by the gcov profiling infrastructure: source paths are
> referenced by the compiled object files. Using relative paths or
> object file names which are different from the source name would
> prevent the gcov tool from finding the corresponding source files.
For the relative path issue do you really fix this at the right place?
I would say that teaching gcov tool from where to look would be better.
> Also change the module versioning mechanism to alter object file
> names only after compiling.
Can I get this as a separate patch please.
It may be general useful and makes sense to look at alone.
Sam
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 3/6] kbuild: convert include and source paths
2008-05-05 19:58 ` Sam Ravnborg
@ 2008-05-06 17:03 ` Peter Oberparleiter
0 siblings, 0 replies; 5+ messages in thread
From: Peter Oberparleiter @ 2008-05-06 17:03 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: ltp-list, Andrew Morton, ltp-coverage, linux-kernel
Sam Ravnborg wrote:
> On Mon, May 05, 2008 at 05:24:26PM +0200, Peter Oberparleiter wrote:
>> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>>
>> Modify kbuild to convert relative include and source paths to absolute
>> form. Also change the module versioning mechanism to alter object file
>> names only after compiling.
>>
>> Required by the gcov profiling infrastructure: source paths are
>> referenced by the compiled object files. Using relative paths or
>> object file names which are different from the source name would
>> prevent the gcov tool from finding the corresponding source files.
>
> For the relative path issue do you really fix this at the right place?
> I would say that teaching gcov tool from where to look would be better.
Actually it is gcc that would need to be changed to only include
absolute paths in compiled object files. While I haven't led that
particular discussion with gcc developers yet, I could imagine that they
would argue that such an option already exists: by specifying only
absolute paths during compilation. Also, any dependency on a future
version of gcc would, in my opinion, greatly reduce the overall
usefulness of this gcov kernel infrastructure.
Would it be acceptable to isolate these changes to kbuild by
if-statements, i.e. use absolute paths only of CONFIG_GCOV is
specified (as Jan Engelhardt suggested)?
>> Also change the module versioning mechanism to alter object file
>> names only after compiling.
> Can I get this as a separate patch please.
> It may be general useful and makes sense to look at alone.
Ok, I will do that.
Regards,
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 3/6] kbuild: convert include and source paths
2008-05-05 15:24 [RFC PATCH 3/6] kbuild: convert include and source paths Peter Oberparleiter
2008-05-05 19:58 ` Sam Ravnborg
@ 2008-05-06 4:32 ` Andrew Morton
2008-05-06 17:28 ` Peter Oberparleiter
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-05-06 4:32 UTC (permalink / raw)
To: Peter Oberparleiter; +Cc: linux-kernel, ltp-list, ltp-coverage, sam
On Mon, 05 May 2008 17:24:26 +0200 Peter Oberparleiter <peter.oberparleiter@de.ibm.com> wrote:
> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>
> Modify kbuild to convert relative include and source paths to absolute
> form. Also change the module versioning mechanism to alter object file
> names only after compiling.
>
> Required by the gcov profiling infrastructure: source paths are
> referenced by the compiled object files. Using relative paths or
> object file names which are different from the source name would
> prevent the gcov tool from finding the corresponding source files.
>
> Signed-off-by: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
> ---
> Makefile | 6 +++---
> scripts/Kbuild.include | 2 ++
> scripts/Makefile.build | 7 +++++--
> scripts/Makefile.lib | 2 +-
> 4 files changed, 11 insertions(+), 6 deletions(-)
>
> Index: linux-2.6.26-rc1/scripts/Makefile.build
> ===================================================================
> --- linux-2.6.26-rc1.orig/scripts/Makefile.build
> +++ linux-2.6.26-rc1/scripts/Makefile.build
> @@ -167,7 +167,8 @@ $(obj)/%.symtypes : $(src)/%.c FORCE
> quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
>
> ifndef CONFIG_MODVERSIONS
> -cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
> +cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ \
> + $(if $(filter-out /%,$<),$(objtree)/$<,$<)
>
> else
> # When module versioning is enabled the following steps are executed:
> @@ -182,7 +183,9 @@ else
> # replace the unresolved symbols __crc_exported_symbol with
> # the actual value of the checksum generated by genksyms
>
> -cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
> +cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/$(@F) \
> + $(if $(filter-out /%,$<),$(objtree)/$<,$<) ; \
> + mv -f $(@D)/$(@F) $(@D)/.tmp_$(@F)
> cmd_modversions = \
> if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
> $(CPP) -D__GENKSYMS__ $(c_flags) $< \
> Index: linux-2.6.26-rc1/scripts/Makefile.lib
> ===================================================================
> --- linux-2.6.26-rc1.orig/scripts/Makefile.lib
> +++ linux-2.6.26-rc1/scripts/Makefile.lib
> @@ -113,7 +113,7 @@ else
> # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
> # and locates generated .h files
> # FIXME: Replace both with specific CFLAGS* statements in the makefiles
> -__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
> +__c_flags = $(call addtree,-I$(obj)) $(call addtree2,-I$(obj)) $(call flags,_c_flags)
> __a_flags = $(call flags,_a_flags)
> __cpp_flags = $(call flags,_cpp_flags)
> endif
> Index: linux-2.6.26-rc1/scripts/Kbuild.include
> ===================================================================
> --- linux-2.6.26-rc1.orig/scripts/Kbuild.include
> +++ linux-2.6.26-rc1/scripts/Kbuild.include
> @@ -145,6 +145,8 @@ build := -f $(if $(KBUILD_SRC),$(srctree
>
> # Prefix -I with $(srctree) if it is not an absolute path.
> addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))
> +# Prefix -I with $(objtree) if it is not an absolute path.
> +addtree2 = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(objtree)/%,$(1)),$(1))
>
> # Find all -I options and call addtree
> flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
> Index: linux-2.6.26-rc1/Makefile
> ===================================================================
> --- linux-2.6.26-rc1.orig/Makefile
> +++ linux-2.6.26-rc1/Makefile
> @@ -324,9 +324,9 @@ AFLAGS_KERNEL =
>
> # Use LINUXINCLUDE when you must reference the include/ directory.
> # Needed to be compatible with the O= option
> -LINUXINCLUDE := -Iinclude \
> - $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
> - -include include/linux/autoconf.h
> +LINUXINCLUDE := -I$(objtree)/include -I$(srctree) -I$(objtree) \
> + $(if $(KBUILD_SRC),-I$(objtree)/include2 \
> + -I$(srctree)/include) -include include/linux/autoconf.h
>
> KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
>
I hope Sam understands that line-noise ;)
It doesn't appear to affect __FILE__ in any way (which is good). But I'm
unsure what it _does_ affect. The changelog implies that it will convert
"liunx/foo.h" into /usr/src/linux/include/foo.h, only it doesn't.
ho hum.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH 3/6] kbuild: convert include and source paths
2008-05-06 4:32 ` Andrew Morton
@ 2008-05-06 17:28 ` Peter Oberparleiter
0 siblings, 0 replies; 5+ messages in thread
From: Peter Oberparleiter @ 2008-05-06 17:28 UTC (permalink / raw)
To: Andrew Morton; +Cc: ltp-list, ltp-coverage, sam, linux-kernel
Andrew Morton wrote:
> On Mon, 05 May 2008 17:24:26 +0200 Peter Oberparleiter <peter.oberparleiter@de.ibm.com> wrote:
>
>> From: Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
>>
>> Modify kbuild to convert relative include and source paths to absolute
>> form. Also change the module versioning mechanism to alter object file
>> names only after compiling.
>>
>> Required by the gcov profiling infrastructure: source paths are
>> referenced by the compiled object files. Using relative paths or
>> object file names which are different from the source name would
>> prevent the gcov tool from finding the corresponding source files.
> It doesn't appear to affect __FILE__ in any way (which is good). But I'm
> unsure what it _does_ affect. The changelog implies that it will convert
> "liunx/foo.h" into /usr/src/linux/include/foo.h, only it doesn't.
>
> ho hum.
This patch should convert
gcc -Idir1 -c a.c -o a.o
to
gcc -I/path/to/dir1 -c /path/to/a.c -o a.o
As a standalone change this has no visible effect, but when gcc option
-fprofile-arcs is specified (as done in patch 5), the resulting object
files should only contain absolute paths.
Regards,
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-05-06 17:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 15:24 [RFC PATCH 3/6] kbuild: convert include and source paths Peter Oberparleiter
2008-05-05 19:58 ` Sam Ravnborg
2008-05-06 17:03 ` Peter Oberparleiter
2008-05-06 4:32 ` Andrew Morton
2008-05-06 17:28 ` Peter Oberparleiter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox