tags: honor COMPILED_SOURCE with apart output directory
diff mbox

Message ID 1476736079-11963-1-git-send-email-robert.jarzmik@free.fr
State New
Headers show

Commit Message

Robert Jarzmik Oct. 17, 2016, 8:27 p.m. UTC
When the kernel is compiled with an "O=" argument, the object files are
not necessarily in the source tree, and more probably in another tree.

In this situation, the current used check doesn't work, and
COMPILED_SOURCE tags is broken with O= builds.

This patch fixes it by looking for object files both in source tree and
potential destination tree.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 scripts/tags.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Robert Jarzmik Dec. 6, 2016, 11:54 a.m. UTC | #1
Robert Jarzmik <robert.jarzmik@free.fr> writes:

> When the kernel is compiled with an "O=" argument, the object files are
> not necessarily in the source tree, and more probably in another tree.
>
> In this situation, the current used check doesn't work, and
> COMPILED_SOURCE tags is broken with O= builds.
>
> This patch fixes it by looking for object files both in source tree and
> potential destination tree.
>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Hi Marek, ping about this patch ?

Cheers.

--
Robert

PS: The patch content top-posted
> ---
>  scripts/tags.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/tags.sh b/scripts/tags.sh
> index b3775a9604ea..c0220fa05617 100755
> --- a/scripts/tags.sh
> +++ b/scripts/tags.sh
> @@ -106,7 +106,9 @@ all_compiled_sources()
>  		case "$i" in
>  			*.[cS])
>  				j=${i/\.[cS]/\.o}
> -				if [ -e $j ]; then
> +				k=${i/"$tree"/"$O"\/}
> +				k=${k/\.[cS]/\.o}
> +				if [ -e $j -o -e "$k" ]; then
>  					echo $i
>  				fi
>  				;;
--
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 Dec. 11, 2016, 9:20 p.m. UTC | #2
Dne 6.12.2016 v 12:54 Robert Jarzmik napsal(a):
> Robert Jarzmik <robert.jarzmik@free.fr> writes:
> 
>> When the kernel is compiled with an "O=" argument, the object files are
>> not necessarily in the source tree, and more probably in another tree.
>>
>> In this situation, the current used check doesn't work, and
>> COMPILED_SOURCE tags is broken with O= builds.
>>
>> This patch fixes it by looking for object files both in source tree and
>> potential destination tree.
>>
>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> 
> Hi Marek, ping about this patch ?

Sorry, I missed the patch.

>> --- a/scripts/tags.sh
>> +++ b/scripts/tags.sh
>> @@ -106,7 +106,9 @@ all_compiled_sources()
>>  		case "$i" in
>>  			*.[cS])
>>  				j=${i/\.[cS]/\.o}
>> -				if [ -e $j ]; then
>> +				k=${i/"$tree"/"$O"\/}
>> +				k=${k/\.[cS]/\.o}
>> +				if [ -e $j -o -e "$k" ]; then

Please use the KBUILD_OUTPUT variable and not O. Also, the $tree prefix
should only match at the beginning of the filename (so use something
like ${i#$tree}). Last, but not least, the .[cS] -> .o substitution only
needs to be done once. The k variable can use the value of j instead of i.

Thanks,
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
Robert Jarzmik Dec. 12, 2016, 5:13 p.m. UTC | #3
Michal Marek <mmarek@suse.com> writes:

> Dne 6.12.2016 v 12:54 Robert Jarzmik napsal(a):
>> Robert Jarzmik <robert.jarzmik@free.fr> writes:
>> 
>>> When the kernel is compiled with an "O=" argument, the object files are
>>> not necessarily in the source tree, and more probably in another tree.
>>>
>>> In this situation, the current used check doesn't work, and
>>> COMPILED_SOURCE tags is broken with O= builds.
>>>
>>> This patch fixes it by looking for object files both in source tree and
>>> potential destination tree.
>>>
>>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>> 
>> Hi Marek, ping about this patch ?
>
> Sorry, I missed the patch.
>
>>> --- a/scripts/tags.sh
>>> +++ b/scripts/tags.sh
>>> @@ -106,7 +106,9 @@ all_compiled_sources()
>>>  		case "$i" in
>>>  			*.[cS])
>>>  				j=${i/\.[cS]/\.o}
>>> -				if [ -e $j ]; then
>>> +				k=${i/"$tree"/"$O"\/}
>>> +				k=${k/\.[cS]/\.o}
>>> +				if [ -e $j -o -e "$k" ]; then
>
> Please use the KBUILD_OUTPUT variable and not O.
Well, I can't as far as I know. I tried, see below ...

Explanation :
 - if I add just below the line "j=${i/\.[cS]/\.o}" the following :
	k="$O/${j#$tree}"
        echo "tree=$tree; O=$O; KBUILD_OUTPUT=$KBUILD_OUTPUT; i=$i, j=$j, k=$k"
 - and I launch:
	make O=out cscope COMPILED_SOURCE=1
 
I get these kind of lines :
tree=../; O=/home/rj/mio_linux/kernel/out; KBUILD_OUTPUT=;
i=../kernel/sched/core.c, j=../kernel/sched/core.o, k=../kernel/sched/core.o

From here I understand that :
 - $KBUILD_OUTPUT is not usable

> should only match at the beginning of the filename (so use something
> like ${i#$tree}).
Ok, I can use then : k="$O/${j#$tree}". The subtle part is when O is empty, in
which case this returns /xxxx, which doesn't look nice, while the former
expression returned either a substituted path or the source path.

> Last, but not least, the .[cS] -> .o substitution only
> needs to be done once. The k variable can use the value of j instead of i.
Yeah, definitely.

Cheers.
Michal Marek Dec. 12, 2016, 8:41 p.m. UTC | #4
Dne 12.12.2016 v 18:13 Robert Jarzmik napsal(a):
> Michal Marek <mmarek@suse.com> writes:
>> Please use the KBUILD_OUTPUT variable and not O.
> Well, I can't as far as I know. I tried, see below ...
> 
> Explanation :
>  - if I add just below the line "j=${i/\.[cS]/\.o}" the following :
> 	k="$O/${j#$tree}"
>         echo "tree=$tree; O=$O; KBUILD_OUTPUT=$KBUILD_OUTPUT; i=$i, j=$j, k=$k"
>  - and I launch:
> 	make O=out cscope COMPILED_SOURCE=1
>  
> I get these kind of lines :
> tree=../; O=/home/rj/mio_linux/kernel/out; KBUILD_OUTPUT=;
> i=../kernel/sched/core.c, j=../kernel/sched/core.o, k=../kernel/sched/core.o
> 
> From here I understand that :
>  - $KBUILD_OUTPUT is not usable

Hm, you are right, we never export $KBUILD_OUTPUT anywhere. But, we
actualy chdir into the build tree before doing anything. So you can
assume that if $KBUILD_SRC != "", the build tree is ".".


>> should only match at the beginning of the filename (so use something
>> like ${i#$tree}).
> Ok, I can use then : k="$O/${j#$tree}". The subtle part is when O is empty, in
> which case this returns /xxxx, which doesn't look nice, while the former
> expression returned either a substituted path or the source path.

... so you can simply strip the leading $tree here and obtain the path
in the build directory.

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

Patch
diff mbox

diff --git a/scripts/tags.sh b/scripts/tags.sh
index b3775a9604ea..c0220fa05617 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -106,7 +106,9 @@  all_compiled_sources()
 		case "$i" in
 			*.[cS])
 				j=${i/\.[cS]/\.o}
-				if [ -e $j ]; then
+				k=${i/"$tree"/"$O"\/}
+				k=${k/\.[cS]/\.o}
+				if [ -e $j -o -e "$k" ]; then
 					echo $i
 				fi
 				;;