Making all in src make[1]: Entering directory '/var/tmp/portage/dev-util/patchelf-0.15.0/work/patchelf-0.15.0/src' x86_64-gentoo-linux-musl-g++ -DPACKAGE_NAME=\"patchelf\" -DPACKAGE_TARNAME=\"patchelf\" -DPACKAGE_VERSION=\"0.15.0\" -DPACKAGE_STRING=\"patchelf\ 0.15.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"patchelf\" -DVERSION=\"0.15.0\" -I. -Wall -std=c++17 -D_FILE_OFFSET_BITS=64 -pipe -march=native -fno-diagnostics-color -O2 -D_GLIBCXX_ASSERTIONS -c -o patchelf.o patchelf.cc patchelf.cc: In member function 'void ElfFile<Elf_Ehdr, Elf_Phdr, Elf_Shdr, Elf_Addr, Elf_Off, Elf_Dyn, Elf_Sym, Elf_Verneed, Elf_Versym>::rewriteHeaders(Elf_Addr)': patchelf.cc:999:33: error: 'DT_MIPS_XHASH' was not declared in this scope; did you mean 'DT_MIPS_FLAGS'? 999 | } else if (d_tag == DT_MIPS_XHASH) { | ^~~~~~~~~~~~~ ------------------------------------------------------------------- This is an unstable amd64 chroot image at a tinderbox (==build bot) name: 17.0_musl_hardened-j4-20220723-104412 ------------------------------------------------------------------- gcc-config -l: [1] x86_64-gentoo-linux-musl-12.1.1 * clang/llvm (if any): clang version 14.0.6 Target: x86_64-gentoo-linux-musl Thread model: posix InstalledDir: /usr/lib/llvm/14/bin /usr/lib/llvm/14 14.0.6 Python 3.10.5 Available Rust versions: [1] rust-1.62.1 * The following VMs are available for generation-2: *) Eclipse Temurin JDK 17.0.3_p7 [openjdk-bin-17] Available Java Virtual Machines: [1] openjdk-bin-17 system-vm php cli: HEAD of ::gentoo commit 9d500c5c8ee8d1989e6db8829ef928471bf57448 Author: Repository mirror & CI <repomirrorci@gentoo.org> Date: Sun Jul 24 23:31:43 2022 +0000 2022-07-24 23:31:42 UTC emerge -qpvO dev-util/patchelf [ebuild N ] dev-util/patchelf-0.15.0
Created attachment 794180 [details] emerge-info.txt
Created attachment 794183 [details] dev-util:patchelf-0.15.0:20220725-002453.log
Created attachment 794186 [details] emerge-history.txt
Created attachment 794189 [details] environment
Created attachment 794192 [details] etc.portage.tar.bz2
Created attachment 794195 [details] logs.tar.bz2
Created attachment 794198 [details] temp.tar.bz2
tinderbox_musl has reproduced this issue with version 0.17.0 - Updating summary.
reproduced with dev-util/patchelf-0.17.2 Why does ebuild deletes elf.h where DT_MIPS_XHASH is defined?
(In reply to Darkii from comment #9) > reproduced with dev-util/patchelf-0.17.2 > > Why does ebuild deletes elf.h where DT_MIPS_XHASH is defined? That's not necessarily the cause of the error, as it would be odd if it just didn't-include-it-if-it-doesn't-exist (although it's possible w/ e.g. _has_include). Anyway, you got me curious, and it dates back to.. ``` commit f18acb2c34480ef41a70c60fda80dcf21e5397b0 Author: Justin Lecher <jlec@gentoo.org> Date: Mon Feb 4 15:59:31 2013 +0000 dev-util/patchelf: Use system header, thanks fedora; respect CC, CFLAGS an LDFLAGS in test binaries (Portage version: 2.2.0_alpha161/cvs/Linux x86_64, signed Manifest commit with key 70EB7916) ``` but it's possible that musl's elf.h, as opposed to glibc's, lacks DT_MIPS_XHASH. I dunno if DT_MIPS_XHASH is a standard thing or not. I assume no.
tinderbox_musl has reproduced this issue with version 0.17.2 - Updating summary.
Looking at the musl elf.h it does not define DT_MIPS_XHASH. The patch at https://github.com/tgbugs/dockerfiles/blob/d4de50f82493189212287f131059dd7640cdd8d4/source.org?plain=1#L1849-L1863 is sufficient to resolve the issue without apparent side effects. I'm sure there is probably a better/more correct solution in patchelf.cc involving a #define or something, but for now this might be sufficient.
(In reply to Tom Gillespie from comment #12) > Looking at the musl elf.h it does not define DT_MIPS_XHASH. The patch at > https://github.com/tgbugs/dockerfiles/blob/ > d4de50f82493189212287f131059dd7640cdd8d4/source.org?plain=1#L1849-L1863 is > sufficient to resolve the issue without apparent side effects. I'm sure > there is probably a better/more correct solution in patchelf.cc involving a > #define or something, but for now this might be sufficient. We'd want a patch which we can apply unconditionally. Anyway, it should be fine to guard it with #ifdef __GLIBC__ given it's purely a glibc construct (modified hash type).
Created attachment 855328 [details, diff] glibc-dt-mips-xhash.patch Something like this maybe?
lgtm there is a problem in that if you build on musl (not cross compiling), you won't be able to use it to modify a MIPS glibc-linked binary, but I feel like that's a pretty niche issue, especially given it doesn't build at all on musl anyway, and the nature of this tool is kind of brittle anyway -- so I think this is ok.
Also see https://github.com/NixOS/patchelf/pull/471
Is there a reason for removing src/elf.h in https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/patchelf/patchelf-0.17.2.ebuild#n17 ? Otherwise changing the ebuild to use bundled elf.h for musl libc would also work. ``` diff --git a/dev-util/patchelf/patchelf-0.17.2.ebuild b/dev-util/patchelf/patchelf-0.17.2.ebuild index ef24854c86..b35af485c9 100644 --- a/dev-util/patchelf/patchelf-0.17.2.ebuild +++ b/dev-util/patchelf/patchelf-0.17.2.ebuild @@ -14,7 +14,7 @@ LICENSE="GPL-3" src_prepare() { default - rm src/elf.h || die + use elibc_musl || rm src/elf.h || die sed -i \ -e 's:-Werror::g' \ ```
(In reply to hugegameartgd from comment #17) > Is there a reason for removing src/elf.h in > https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/patchelf/patchelf-0. > 17.2.ebuild#n17 ? > Otherwise changing the ebuild to use bundled elf.h for musl libc would also > work. Have you read the above? I address that..
(In reply to Sam James from comment #10) > (In reply to Darkii from comment #9) > > reproduced with dev-util/patchelf-0.17.2 > > > > Why does ebuild deletes elf.h where DT_MIPS_XHASH is defined? > > That's not necessarily the cause of the error, as it would be odd if it just > didn't-include-it-if-it-doesn't-exist (although it's possible w/ e.g. > _has_include). > I guess the file should be bundled for glibc compatibility on musl systems as it fixes compilation, does void linux and other musl related projects unbundle the elf.h header file?
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3baf1a6f70fba59102f8e1eeb46cb8291e4b9a8a commit 3baf1a6f70fba59102f8e1eeb46cb8291e4b9a8a Author: LinuxUserGD <hugegameartgd@gmail.com> AuthorDate: 2023-04-15 16:29:53 +0000 Commit: James Le Cuirot <chewi@gentoo.org> CommitDate: 2023-04-27 07:45:53 +0000 Add define for DT_MIPS_XHASH Closes: https://bugs.gentoo.org/860888 Signed-off-by: LinuxUserGD <hugegameartgd@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/30604 Signed-off-by: James Le Cuirot <chewi@gentoo.org> dev-util/patchelf/files/patchelf-glibc-dt-mips-xhash.patch | 9 +++++++++ dev-util/patchelf/patchelf-0.18.0.ebuild | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-)