Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#76537 - [linux] Build tools not stripped

Attached to Project: Arch Linux
Opened by Aviana Cruz (AvianaCruz) - Saturday, 12 November 2022, 13:49 GMT
Last edited by Toolybird (Toolybird) - Thursday, 17 November 2022, 07:30 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Jan Alexander Steffens (heftig)
David Runge (dvzrv)
Levente Polyak (anthraxx)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
The `file` command crashes with the output of `bad system call` when it is executed in `PKGBUILD`. Therefore `file -bi "$file"`(https://github.com/archlinux/svntogit-packages/blob/c1fde05a84a517d4728971b22004cf84c0fc0491/trunk/PKGBUILD#L156) does't get anything useful and nothing there is stripped.
Any usage of `file` in `PKGBUILD` should be considered to be replaced by 'file -S'. I think it is also a good idea to check every `PKGBUILD` to ensure there will be no more mistakes like this since `file` is often used with pipes and it fails silently.
I also noticed that `file -z $file_to_be_checked` crashes but 'file -S -z $file_to_be_checked' not, if the file is zstd compressed.

Additional info:
https://bugs.archlinux.org/task/58626
This task depends upon

Closed by  Toolybird (Toolybird)
Thursday, 17 November 2022, 07:30 GMT
Reason for closing:  Fixed
Additional comments about closing:  linux 6.0.9.arch1-1
Comment by Toolybird (Toolybird) - Monday, 14 November 2022, 21:34 GMT
Hmmm, the use of `file -bi ..' in the kernel PKGBUILD goes back a long way, so I'm pretty sure it *used* to work at some stage. You're right that it doesn't work now as can be trivially tested and also evidenced by the unstripped binaries "objtool" and "resolve_btfids" shipped in our "linux-headers" pkg.

I instinctively thought bash errexit would catch this...but it doesn't. For example:

Stripping build tools...
+ local file
+ read -rd '' file
++ find /build/linux/pkg/linux-headers/usr/lib/modules/6.0.8-arch1-1/build -type f -perm -u+x '!' -name vmlinux -print0
+ case "$(file -bi "$file")" in
++ file -bi /build/linux/pkg/linux-headers/usr/lib/modules/6.0.8-arch1-1/build/tools/objtool/objtool
+++ error_function package_linux-headers
+++ (( ! BASH_SUBSHELL ))
+++ exit 4

Loading...