bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
@ 2019-09-05 17:59 Andrii Nakryiko
  2019-09-05 23:59 ` Yonghong Song
  2019-09-06  3:53 ` yamada.masahiro
  0 siblings, 2 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2019-09-05 17:59 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel
  Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko, Stephen Rothwell,
	Masahiro Yamada

${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
BASH. Use shift and ${@} instead to fix this issue.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 scripts/link-vmlinux.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 0d8f41db8cd6..8c59970a09dc 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -57,12 +57,16 @@ modpost_link()
 
 # Link of vmlinux
 # ${1} - output file
-# ${@:2} - optional extra .o files
+# ${2}, ${3}, ... - optional extra .o files
 vmlinux_link()
 {
 	local lds="${objtree}/${KBUILD_LDS}"
+	local output=${1}
 	local objects
 
+	# skip output file argument
+	shift
+
 	if [ "${SRCARCH}" != "um" ]; then
 		objects="--whole-archive			\
 			${KBUILD_VMLINUX_OBJS}			\
@@ -70,9 +74,10 @@ vmlinux_link()
 			--start-group				\
 			${KBUILD_VMLINUX_LIBS}			\
 			--end-group				\
-			${@:2}"
+			${@}"
 
-		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1}	\
+		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux}	\
+			-o ${output}				\
 			-T ${lds} ${objects}
 	else
 		objects="-Wl,--whole-archive			\
@@ -81,9 +86,10 @@ vmlinux_link()
 			-Wl,--start-group			\
 			${KBUILD_VMLINUX_LIBS}			\
 			-Wl,--end-group				\
-			${@:2}"
+			${@}"
 
-		${CC} ${CFLAGS_vmlinux} -o ${1}			\
+		${CC} ${CFLAGS_vmlinux}				\
+			-o ${output}				\
 			-Wl,-T,${lds}				\
 			${objects}				\
 			-lutil -lrt -lpthread
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
  2019-09-05 17:59 [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@} Andrii Nakryiko
@ 2019-09-05 23:59 ` Yonghong Song
  2019-09-06  9:11   ` Andrii Nakryiko
  2019-09-06  3:53 ` yamada.masahiro
  1 sibling, 1 reply; 5+ messages in thread
From: Yonghong Song @ 2019-09-05 23:59 UTC (permalink / raw)
  To: Andrii Nakryiko, bpf, netdev, Alexei Starovoitov, daniel
  Cc: andrii.nakryiko, Kernel Team, Stephen Rothwell, Masahiro Yamada



On 9/5/19 10:59 AM, Andrii Nakryiko wrote:
> ${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
> BASH. Use shift and ${@} instead to fix this issue.
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Tested with bash/sh/csh, all works.
Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   scripts/link-vmlinux.sh | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 0d8f41db8cd6..8c59970a09dc 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -57,12 +57,16 @@ modpost_link()
>   
>   # Link of vmlinux
>   # ${1} - output file
> -# ${@:2} - optional extra .o files
> +# ${2}, ${3}, ... - optional extra .o files
>   vmlinux_link()
>   {
>   	local lds="${objtree}/${KBUILD_LDS}"
> +	local output=${1}
>   	local objects
>   
> +	# skip output file argument
> +	shift
> +
>   	if [ "${SRCARCH}" != "um" ]; then
>   		objects="--whole-archive			\
>   			${KBUILD_VMLINUX_OBJS}			\
> @@ -70,9 +74,10 @@ vmlinux_link()
>   			--start-group				\
>   			${KBUILD_VMLINUX_LIBS}			\
>   			--end-group				\
> -			${@:2}"
> +			${@}"
>   
> -		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1}	\
> +		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux}	\
> +			-o ${output}				\
>   			-T ${lds} ${objects}
>   	else
>   		objects="-Wl,--whole-archive			\
> @@ -81,9 +86,10 @@ vmlinux_link()
>   			-Wl,--start-group			\
>   			${KBUILD_VMLINUX_LIBS}			\
>   			-Wl,--end-group				\
> -			${@:2}"
> +			${@}"
>   
> -		${CC} ${CFLAGS_vmlinux} -o ${1}			\
> +		${CC} ${CFLAGS_vmlinux}				\
> +			-o ${output}				\
>   			-Wl,-T,${lds}				\
>   			${objects}				\
>   			-lutil -lrt -lpthread
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
  2019-09-05 17:59 [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@} Andrii Nakryiko
  2019-09-05 23:59 ` Yonghong Song
@ 2019-09-06  3:53 ` yamada.masahiro
  2019-09-06 17:03   ` Alexei Starovoitov
  1 sibling, 1 reply; 5+ messages in thread
From: yamada.masahiro @ 2019-09-06  3:53 UTC (permalink / raw)
  To: andriin, bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, sfr



> -----Original Message-----
> From: Andrii Nakryiko <andriin@fb.com>
> Sent: Friday, September 06, 2019 3:00 AM
> To: bpf@vger.kernel.org; netdev@vger.kernel.org; ast@fb.com;
> daniel@iogearbox.net
> Cc: andrii.nakryiko@gmail.com; kernel-team@fb.com; Andrii Nakryiko
> <andriin@fb.com>; Stephen Rothwell <sfr@canb.auug.org.au>; Yamada,
> Masahiro/山田 真弘 <yamada.masahiro@socionext.com>
> Subject: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift
> and ${@}
> 
> ${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
> BASH. Use shift and ${@} instead to fix this issue.
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
  2019-09-05 23:59 ` Yonghong Song
@ 2019-09-06  9:11   ` Andrii Nakryiko
  0 siblings, 0 replies; 5+ messages in thread
From: Andrii Nakryiko @ 2019-09-06  9:11 UTC (permalink / raw)
  To: Yonghong Song, bpf, netdev, Alexei Starovoitov, daniel
  Cc: andrii.nakryiko, Kernel Team, Stephen Rothwell, Masahiro Yamada

On 9/6/19 12:59 AM, Yonghong Song wrote:
> 
> 
> On 9/5/19 10:59 AM, Andrii Nakryiko wrote:
>> ${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
>> BASH. Use shift and ${@} instead to fix this issue.
>>
>> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
>> Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
>> Cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> 
> Tested with bash/sh/csh, all works.

Thanks for testing, Yonghong! In my system sh is an alias to bash, so it 
still behaved like bash and didn't fail even with existing code. I 
didn't have an opportunity to install csh at that time and try it, so 
thanks a lot for confirming. I basically relied on documentation to 
verify shift and $@ is not BASH'ism.

> Acked-by: Yonghong Song <yhs@fb.com>
> 
>> ---
>>    scripts/link-vmlinux.sh | 16 +++++++++++-----
>>    1 file changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
>> index 0d8f41db8cd6..8c59970a09dc 100755
>> --- a/scripts/link-vmlinux.sh
>> +++ b/scripts/link-vmlinux.sh
>> @@ -57,12 +57,16 @@ modpost_link()
>>    
>>    # Link of vmlinux
>>    # ${1} - output file
>> -# ${@:2} - optional extra .o files
>> +# ${2}, ${3}, ... - optional extra .o files
>>    vmlinux_link()
>>    {
>>    	local lds="${objtree}/${KBUILD_LDS}"
>> +	local output=${1}
>>    	local objects
>>    
>> +	# skip output file argument
>> +	shift
>> +
>>    	if [ "${SRCARCH}" != "um" ]; then
>>    		objects="--whole-archive			\
>>    			${KBUILD_VMLINUX_OBJS}			\
>> @@ -70,9 +74,10 @@ vmlinux_link()
>>    			--start-group				\
>>    			${KBUILD_VMLINUX_LIBS}			\
>>    			--end-group				\
>> -			${@:2}"
>> +			${@}"
>>    
>> -		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux} -o ${1}	\
>> +		${LD} ${KBUILD_LDFLAGS} ${LDFLAGS_vmlinux}	\
>> +			-o ${output}				\
>>    			-T ${lds} ${objects}
>>    	else
>>    		objects="-Wl,--whole-archive			\
>> @@ -81,9 +86,10 @@ vmlinux_link()
>>    			-Wl,--start-group			\
>>    			${KBUILD_VMLINUX_LIBS}			\
>>    			-Wl,--end-group				\
>> -			${@:2}"
>> +			${@}"
>>    
>> -		${CC} ${CFLAGS_vmlinux} -o ${1}			\
>> +		${CC} ${CFLAGS_vmlinux}				\
>> +			-o ${output}				\
>>    			-Wl,-T,${lds}				\
>>    			${objects}				\
>>    			-lutil -lrt -lpthread
>>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@}
  2019-09-06  3:53 ` yamada.masahiro
@ 2019-09-06 17:03   ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2019-09-06 17:03 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Andrii Nakryiko, bpf, Network Development, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Kernel Team, Stephen Rothwell

On Fri, Sep 6, 2019 at 3:34 AM <yamada.masahiro@socionext.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Andrii Nakryiko <andriin@fb.com>
> > Sent: Friday, September 06, 2019 3:00 AM
> > To: bpf@vger.kernel.org; netdev@vger.kernel.org; ast@fb.com;
> > daniel@iogearbox.net
> > Cc: andrii.nakryiko@gmail.com; kernel-team@fb.com; Andrii Nakryiko
> > <andriin@fb.com>; Stephen Rothwell <sfr@canb.auug.org.au>; Yamada,
> > Masahiro/山田 真弘 <yamada.masahiro@socionext.com>
> > Subject: [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift
> > and ${@}
> >
> > ${@:2} is BASH-specific extension, which makes link-vmlinux.sh rely on
> > BASH. Use shift and ${@} instead to fix this issue.
> >
> > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > Fixes: 341dfcf8d78e ("btf: expose BTF info through sysfs")
> > Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> > Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied. Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-06 17:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 17:59 [PATCH bpf-next] kbuild: replace BASH-specific ${@:2} with shift and ${@} Andrii Nakryiko
2019-09-05 23:59 ` Yonghong Song
2019-09-06  9:11   ` Andrii Nakryiko
2019-09-06  3:53 ` yamada.masahiro
2019-09-06 17:03   ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).