Bug 29218 - libiberty cannot find __imp___acrt_iob_func for x86_64-w64-mingw32 cross toolchain for canadian compilation
Summary: libiberty cannot find __imp___acrt_iob_func for x86_64-w64-mingw32 cross tool...
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2022-06-01 17:10 UTC by cqwrteur
Modified: 2022-06-01 23:13 UTC (History)
2 users (show)

See Also:
Host: x86_64-w64-mingw32
Target: i586-msdosdjgp
Build: x86_64-linux-gnu
Last reconfirmed:

config file (6.06 KB, text/x-log)
2022-06-01 17:13 UTC, cqwrteur

Note You need to log in before you can comment on or make changes to this bug.
Description cqwrteur 2022-06-01 17:10:17 UTC
/usr/local/lib/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../libiberty/libiberty.a(xmalloc.o): in function `fprintf':
/home/cqwrteur/toolchains/native/x86_64-w64-mingw32/x86_64-w64-mingw32/include/stdio.h:361: undefined reference to `__mingw_vfprintf'
/usr/local/lib/gcc/x86_64-pc-linux-gnu/13.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../libiberty/libiberty.a(xmalloc.o): in function `xmalloc_failed':
/home/cqwrteur/toolchains_build/build/x86_64-w64-mingw32/i586-msdosdjgpp/binutils-gdb/libiberty/../../../../../binutils-gdb/libiberty/xmalloc.c:134: undefined reference to `__imp___acrt_iob_func'
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:2488: doc/chew.stamp] Error 1
make[3]: Leaving directory '/home/cqwrteur/toolchains_build/build/x86_64-w64-mingw32/i586-msdosdjgpp/binutils-gdb/bfd'
make[2]: *** [Makefile:1939: info-recursive] Error 1
make[2]: Leaving directory '/home/cqwrteur/toolchains_build/build/x86_64-w64-mingw32/i586-msdosdjgpp/binutils-gdb/bfd'
make[1]: *** [Makefile:3071: all-bfd] Error 2
make[1]: *** Waiting for unfinished jobs....
Comment 1 cqwrteur 2022-06-01 17:13:23 UTC
Created attachment 14128 [details]
config file
Comment 2 cqwrteur 2022-06-01 17:46:22 UTC

I believe it breaks because of this commitment. It makes the binary compiled with the build compiler instead of the host compiler.

It completely breaks Canadian compilation.
Comment 3 cqwrteur 2022-06-01 17:48:04 UTC
BTW. The xmalloc thing should be just __builtin_trap(). No more debugging information and recovery thank you.
Comment 4 cqwrteur 2022-06-01 17:49:06 UTC
void* xmalloc(size_t sz) noexcept
    void* ptr = malloc(sz);
    return ptr;

Thank you. Since stdio on mingw-w64 bloats binary size.
Comment 5 cqwrteur 2022-06-01 17:53:11 UTC

well it looks like this does not fix Canadian compilation.
Comment 6 Alan Modra 2022-06-01 23:13:10 UTC
I can build the canadian cross you describe, using
~/src/binutils-gdb/configure \
--target=i586-msdosdjgpp --host=x86_64-w64-mingw32 --build=x86_64-linux-gnu \
--disable-gdb --disable-gdbserver --disable-sim --disable-readline \
--disable-libdecnumber --disable-libbacktrace --disable-gprofng --disable-nls

$ file bfd/doc/chew
bfd/doc/chew: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=e68ec21e6eb9b489db730e2731ec73932e74c9b0, for GNU/Linux 3.2.0, not stripped
$ file gas/as-new.exe 
gas/as-new.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows

And yes, I also see a fail to link bfd/doc/chew if I use source checked out at commit 739f9506642.