Hi Alex,
On 5/14/21 3:01 AM, Alex Xu (Hello71) wrote:
Hi,
I tried building wine 6.8 with mingw. All fine, just one problem, it reports error "undefined reference to `sincos'". Why, you may ask, since wine never calls sincos function? Well, it seems to be because mingw gcc 11 enables sincos optimization: [0]. But, wine uses -nodefaultlibs, intending to provide libc functions with msvcrt; however, wine msvcrt doesn't implement any sincos. So, there is a mismatch: gcc accepts mingw claim to implement sincos (ok since mingwex implements it), then generates call to sincos, then fails at link time (because msvcrt does not implement it).
After adding -fno-builtin-{sin,cos}{,f} to CFLAGS, wine compiled and ran OK.
This issue seems to be worked around for winelib builds by adding -fno-builtin, so that gcc will not generate sincos (or most other problematic functions).
I think this issue could be worked around by adding those -fno-builtin-* flags for mingw builds. However, I think the sin/cos->sincos optimization is a good one, so maybe we could instead add sincos forwarder in msvcrt (calling sin+cos separately in case sincos is not implemented in libc?).
CCed mingw-w64-public@lists.sourceforge.net due to potential relevance and felixonmars@archlinux.org due to maintaining wine and mingw-gcc on Arch. You may need to subscribe in order to reply all. I look forward to hearing your thoughts.
I think that the decision was unfortunate on GCC side, but there is little we can do. We will probably need to provide it in msvcrt importlibs. Please try the attached patch, it should help.
Thanks,
Jacek