Debian and some other distributions install llvm-strip as llvm-strip-$major (e.g. /usr/bin/llvm-strip-9)
D54193 made it work with llvm-strip-$major but did not add a test.
The behavior was regressed by D69146.
Differential D76562
[llvm-objcopy] Improve tool selection logic to recognize llvm-strip-$major as strip MaskRay on Mar 21 2020, 11:56 PM. Authored by
Details Debian and some other distributions install llvm-strip as llvm-strip-$major (e.g. /usr/bin/llvm-strip-9) D54193 made it work with llvm-strip-$major but did not add a test.
Diff Detail
Event Timeline
Comment Actions Seems sane to me if I am understanding the string arithmetic correctly. I can confirm this fixes the Debian use case that we came across.
Comment Actions Improve tests
Comment Actions A note on how GNU objcopy/strip makes a crunched executable: binutils/not-strip.c (int is_strip = 0;) is linked into objcopy while binutils/is-strip.c (int is_strip = 1;) is linked into strip. Though it is strange that on my Debian, size(/usr/bin/x86_64-linux-gnu-objcopy) != size(/usr/bin/x86_64-linux-gnu-strip ...
Comment Actions @hans If it is not too late for LLVM 10.0.0, I hope this can be picked. If it is too late, I hope it can be included in 10.0.1 ... Debian and some other distributions will ship /usr/bin/llvm-strip-10 but not /usr/bin/llvm-strip (https://packages.debian.org/bullseye/amd64/llvm-9/filelist). Without this patch, /usr/bin/llvm-strip-10 will think it is objcopy. llvm-{objcopy,strip,install-name-tool} is a crunched executable. llvm-strip-10 a.o (implicit --strip-all) and llvm-objcopy-10 a.o (almost a no-op) are different... |
Maybe worth a test case for "[llvm-]strip" etc being in the middle of the name, i.e. something like "gnu-llvm-strip-11". Perhaps it could replace this last test case, as I don't think that one then provides additional coverage.