linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: use a pipe rather than process substitution
@ 2022-06-10 21:34 Alvin Šipraga
  2022-06-10 21:40 ` Alvin Šipraga
  0 siblings, 1 reply; 3+ messages in thread
From: Alvin Šipraga @ 2022-06-10 21:34 UTC (permalink / raw)
  To: Nathan Chancellor, Nick Desaulniers, Tom Rix, Masahiro Yamada
  Cc: linux-kbuild, Alvin Šipraga, linux-kernel, llvm

From: Alvin Šipraga <alsi@bang-olufsen.dk>

Bash process substitution of the form `foo < <(bar)`, as found in
scripts/check-local-export, can cause issues in chrooted environments
and with tools such as pseudo. The blamed commit started to cause build
errors for me when using the Yocto project's devshell environment;
devshell uses pseudo internally:

.../scripts/check-local-export: line 51: /dev/fd/63: No such file or directory

Replace the process substitution with a simple pipe into the while loop.
This is functionally equivalent and more portable than the former. Note
that pipefail is enabled so that the script terminates when ${NM} fails.

Link: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13288
Fixes: 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script instead of modpost")
Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
---
 scripts/check-local-export | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/scripts/check-local-export b/scripts/check-local-export
index da745e2743b7..42de6f8f2541 100755
--- a/scripts/check-local-export
+++ b/scripts/check-local-export
@@ -7,12 +7,24 @@
 # EXPORT_SYMBOL should be used for global symbols.
 
 set -e
+set -o pipefail
 
 declare -A symbol_types
 declare -a export_symbols
 
 exit_code=0
 
+# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm)
+# shows 'no symbols' diagnostic (but exits with 0). It is harmless and
+# hidden by '2>/dev/null'. However, it suppresses real error messages
+# as well. Add a hand-crafted error message here.
+#
+# Use --quiet instead of 2>/dev/null when we upgrade the minimum version
+# of binutils to 2.37, llvm to 13.0.0.
+#
+# Then, the following line will be really simple:
+#   done < <(${NM} --quiet ${1})
+(${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } ) | \
 while read value type name
 do
 	# Skip the line if the number of fields is less than 3.
@@ -37,21 +49,7 @@ do
 	if [[ ${name} == __ksymtab_* ]]; then
 		export_symbols+=(${name#__ksymtab_})
 	fi
-
-	# If there is no symbol in the object, ${NM} (both GNU nm and llvm-nm)
-	# shows 'no symbols' diagnostic (but exits with 0). It is harmless and
-	# hidden by '2>/dev/null'. However, it suppresses real error messages
-	# as well. Add a hand-crafted error message here.
-	#
-	# Use --quiet instead of 2>/dev/null when we upgrade the minimum version
-	# of binutils to 2.37, llvm to 13.0.0.
-	#
-	# Then, the following line will be really simple:
-	#   done < <(${NM} --quiet ${1})
-done < <(${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; false; } )
-
-# Catch error in the process substitution
-wait $!
+done
 
 for name in "${export_symbols[@]}"
 do
-- 
2.36.1


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

* Re: [PATCH] kbuild: use a pipe rather than process substitution
  2022-06-10 21:34 [PATCH] kbuild: use a pipe rather than process substitution Alvin Šipraga
@ 2022-06-10 21:40 ` Alvin Šipraga
  2022-06-11  8:40   ` Masahiro Yamada
  0 siblings, 1 reply; 3+ messages in thread
From: Alvin Šipraga @ 2022-06-10 21:40 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: Nathan Chancellor, Nick Desaulniers, Tom Rix, Masahiro Yamada,
	linux-kbuild, linux-kernel, llvm

On Fri, Jun 10, 2022 at 11:34:52PM +0200, Alvin Šipraga wrote:
> From: Alvin Šipraga <alsi@bang-olufsen.dk>
> 
> Bash process substitution of the form `foo < <(bar)`, as found in
> scripts/check-local-export, can cause issues in chrooted environments
> and with tools such as pseudo. The blamed commit started to cause build
> errors for me when using the Yocto project's devshell environment;
> devshell uses pseudo internally:
> 
> .../scripts/check-local-export: line 51: /dev/fd/63: No such file or directory
> 
> Replace the process substitution with a simple pipe into the while loop.
> This is functionally equivalent and more portable than the former. Note
> that pipefail is enabled so that the script terminates when ${NM} fails.
> 
> Link: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13288
> Fixes: 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script instead of modpost")
> Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>

Oops, I forgot to check the linux-kbuild list before sending this patch. I see
that a more robust patch has been posted which addresses a separate issue, but
which also solves the issue I was trying to address:

https://lore.kernel.org/linux-kbuild/20220608011100.486735-1-masahiroy@kernel.org/raw

Please ignore this. Thanks!

Kind regards,
Alvin

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

* Re: [PATCH] kbuild: use a pipe rather than process substitution
  2022-06-10 21:40 ` Alvin Šipraga
@ 2022-06-11  8:40   ` Masahiro Yamada
  0 siblings, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2022-06-11  8:40 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: Alvin Šipraga, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	linux-kbuild, linux-kernel, llvm

On Sat, Jun 11, 2022 at 6:40 AM Alvin Šipraga <ALSI@bang-olufsen.dk> wrote:
>
> On Fri, Jun 10, 2022 at 11:34:52PM +0200, Alvin Šipraga wrote:
> > From: Alvin Šipraga <alsi@bang-olufsen.dk>
> >
> > Bash process substitution of the form `foo < <(bar)`, as found in
> > scripts/check-local-export, can cause issues in chrooted environments
> > and with tools such as pseudo. The blamed commit started to cause build
> > errors for me when using the Yocto project's devshell environment;
> > devshell uses pseudo internally:
> >
> > .../scripts/check-local-export: line 51: /dev/fd/63: No such file or directory
> >
> > Replace the process substitution with a simple pipe into the while loop.
> > This is functionally equivalent and more portable than the former. Note
> > that pipefail is enabled so that the script terminates when ${NM} fails.
> >
> > Link: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13288
> > Fixes: 31cb50b5590f ("kbuild: check static EXPORT_SYMBOL* by script instead of modpost")
> > Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
>
> Oops, I forgot to check the linux-kbuild list before sending this patch. I see
> that a more robust patch has been posted which addresses a separate issue, but
> which also solves the issue I was trying to address:
>
> https://lore.kernel.org/linux-kbuild/20220608011100.486735-1-masahiroy@kernel.org/raw
>
> Please ignore this. Thanks!
>
> Kind regards,
> Alvin

No problem. I did not notice I had broken yocto builds,
and it is good to know it has been solved as well.
Thanks for the report.



-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2022-06-11  8:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 21:34 [PATCH] kbuild: use a pipe rather than process substitution Alvin Šipraga
2022-06-10 21:40 ` Alvin Šipraga
2022-06-11  8:40   ` Masahiro Yamada

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).