An odd corner case. After setting up a x86_64-w64-mingw32 toolchain (binutils-2.28, gcc-7.1.0, mingw-w64 5.0.2) on gentoo musl, attempting to `x86_64-w64-mingw32-emerge sys-libs/zlib` results in a segfault upon invoking the resource compiler as such: `x86_64-w64-mingw32-windres --define GCC_WINDRES -o zlibrc.o win32/zlib1.rc` Testing with the bare compilers ouside of emerge is reproducable. After asking about it in irc.freenode.net/#musl we narrowed it down to iconv issues, whereupon user midipix pointed me at the following patch: http://git.midipix.org/cgit.cgi/ports/chainport/tree/binutils-2.24.51.midipix.patch Reducing this down to https://bpaste.net/show/089908e214c3 was enough to fix the issue. Applying this patch on a glibc system's mingw-w64 toolchain does not affect the compilation, and as this is a windows only tool it would not affect any non-windows system/compiler toolchain.
Original backtrace: https://bpaste.net/show/84d29f3b5921
Created attachment 10291 [details] fix taken from midipix Suggested in irc.freenode.net/#musl by user midipix, works on musl and doesn't break glibc.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=54387c7fe27848e41a51c1eccc6a24b3d6d3441f commit 54387c7fe27848e41a51c1eccc6a24b3d6d3441f Author: Marty Plummer <ntzrmtthihu777@gmail.com> Date: Mon Jul 31 10:31:18 2017 +0100 Fix compiling zlib using x86_64-musl. PR 21861 * winduni.c (codepages): Use cp1252 for codepage 0.
Hi Marty, Thanks very much for reporting this problem, and for providing such a nice simple fix. I have checked your patch in, along with the changelog entry below. Cheers Nick binutils/ChangeLog 2017-07-31 Marty Plummer <ntzrmtthihu777@gmail.com> PR 21861 * winduni.c (codepages): Use cp1252 for codepage 0.
(In reply to Nick Clifton from comment #4) > Hi Marty, > > Thanks very much for reporting this problem, and for providing such a nice > simple fix. I have checked your patch in, along with the changelog entry > below. > > Cheers > Nick > > binutils/ChangeLog > 2017-07-31 Marty Plummer <ntzrmtthihu777@gmail.com> > > PR 21861 > * winduni.c (codepages): Use cp1252 for codepage 0. Thank you for applying the fix. Damn, I should have sent this patch with my netz.kernel@gmail.org, I typically use that one for 'major' project contributions but I had not set up access to that email on my new musl install.
erm, netz.kernel@gmail.com wtf were my fingers doing :/
The binutils-2_29-branch branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=64aa1246572306b72dc479b46d13ff749b0c3236 commit 64aa1246572306b72dc479b46d13ff749b0c3236 Author: Nick Clifton <nickc@redhat.com> Date: Tue Sep 5 15:32:04 2017 +0100 Import patches from mainline to fix minor binutils bugs: PR 21861 * winduni.c (codepages): Use cp1252 for codepage 0. PR 21813 * rddbg.c (read_symbol_stabs_debugging_info): Check for an empty string whilst concatenating symbol names. PR 21909 * prdbg.c (pr_int_type): Increase size of local string buffer. (pr_float_type): Likewise. (pr_bool_type): Likewise. PR 21820 * readelf.c (dump_section_as_strings): Do not fail if the section was empty. (dump_section_as_bytes): Likewise. PR 21990 * readelf.c (process_version_sections <SHT_GNU_verneed>): Check for invalid vn_next field before adding to idx. Use unsigned long for index vars. Move index checks. <SHT_GNU_verdef>: Likewise for vd_next. PR 21994 * readelf.c (process_version_sections <SHT_GNU_verdef>): Check vd_aux and vda_next for sanity. Delete "end". Correct overflow checks. (process_version_sections <SHT_GNU_verneed>): Correct overflow check. Don't report invalid vna_next on overflow. Do report invalid vna_next on size less than aux info.