Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't link against text-2.0.1 on Windows? #461

Closed
tfausak opened this issue Jul 27, 2022 · 5 comments
Closed

Can't link against text-2.0.1 on Windows? #461

tfausak opened this issue Jul 27, 2022 · 5 comments

Comments

@tfausak
Copy link

tfausak commented Jul 27, 2022

I recently had a build fail for a confusing reason: https://github.com/tfausak/monadoc/runs/7532083433?check_suite_focus=true#step:15:277

Linking D:\\a\\monadoc\\monadoc\\dist-newstyle\\build\\x86_64-windows\\ghc-9.2.3\\monadoc-0.2022.7.27\\x\\monadoc\\opt\\build\\monadoc\\monadoc.exe ...
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000000.o:(.idata$2+0x0): multiple definition of `_head_libstdc___6_dll'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d000000.o):(.idata$2+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000001.o:(.idata$5+0x0): multiple definition of `__imp__ZTVN10__cxxabiv117__class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006226.o):(.idata$5+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000001.o:(.idata$6+0x0): multiple definition of `__nm__ZTVN10__cxxabiv117__class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006226.o):(.idata$6+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000002.o:(.idata$5+0x0): multiple definition of `__imp__ZTVN10__cxxabiv120__si_class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006231.o):(.idata$5+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000002.o:(.idata$6+0x0): multiple definition of `__nm__ZTVN10__cxxabiv120__si_class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006231.o):(.idata$6+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000003.o:(.idata$7+0x0): multiple definition of `libstdc___6_dll_iname'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006587.o):(.idata$7+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000000.o:(.idata$2+0x0): multiple definition of `_head_libstdc___6_dll'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d000000.o):(.idata$2+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000001.o:(.idata$5+0x0): multiple definition of `__imp__ZTVN10__cxxabiv117__class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006226.o):(.idata$5+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000001.o:(.idata$6+0x0): multiple definition of `__nm__ZTVN10__cxxabiv117__class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006226.o):(.idata$6+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000002.o:(.idata$5+0x0): multiple definition of `__imp__ZTVN10__cxxabiv120__si_class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006231.o):(.idata$5+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000002.o:(.idata$6+0x0): multiple definition of `__nm__ZTVN10__cxxabiv120__si_class_type_infoE'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006231.o):(.idata$6+0x0): first defined here
C://tools//ghc-9.2.3//mingw//bin/ld.exe: d000003.o:(.idata$7+0x0): multiple definition of `libstdc___6_dll_iname'; C://tools//ghc-9.2.3//mingw//bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/libstdc++.dll.a(d006587.o):(.idata$7+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)
cabal.exe: Failed to build exe:monadoc from monadoc-0.2022.7.27.
Failed to build test:monadoc-test-suite from monadoc-0.2022.7.27.

I'm not certain that this was caused by text-2.0.1. Compared to the last successful build, that's one of the few things that changed. Here's a diff of the freeze file from the last successful build with that failing build:

102c102
<              any.http-client ==0.7.11,
---
>              any.http-client ==0.7.12,
176c176
<              any.text ==2.0,
---
>              any.text ==2.0.1,
228c228
< index-state: hackage.haskell.org 2022-07-26T09:56:38Z
---
> index-state: hackage.haskell.org 2022-07-27T01:07:47Z

The changes in http-client-0.7.12 don't seem like they could cause this. However I'd be happy to be proven wrong and pointed elsewhere!

If this is indeed caused by upgrading from text-2.0 to text-2.0.1, then I think it's related to #453.

@Bodigrim
Copy link
Contributor

This is likely because of text, but I cannot reproduce neither locally nor on CI.

As a short term solution you can disable -simdutf flag.

Is the solution reproducible with GHC 9.4-rc1? If it does, please forward this issue to GHC developers.

@tfausak
Copy link
Author

tfausak commented Jul 29, 2022

Unfortunately I don't have a Windows machine to test with. But I can confirm that setting --flags=-simdutf for the text package fixed my problem: https://github.com/tfausak/monadoc/runs/7577924604?check_suite_focus=true#step:10:183

@Bodigrim
Copy link
Contributor

OK, I managed to reproduce with GHC 9.2.4. The problem is that monadoc depends both on text and double-conversion. The latter requires

  if os(windows)
    if arch(x86_64)
      extra-libraries: stdc++-6 gcc_s_seh-1

text-2.0 requires stdc++-6 as well:

text/text.cabal

Lines 93 to 95 in 9075b05

if os(windows)
if arch(x86_64)
extra-libraries: stdc++-6 gcc_s_seh-1

However, text-2.0.1 is more relaxed and does not ask for specific version of stdc++:

text/text.cabal

Lines 93 to 104 in fdb06ff

if impl(ghc >= 9.4)
build-depends: system-cxx-std-lib == 1.0
elif os(darwin) || os(freebsd)
extra-libraries: c++
elif os(openbsd)
extra-libraries: c++ c++abi pthread
elif os(windows)
-- GHC's Windows toolchain is based on clang/libc++ in GHC 9.4 and later
if impl(ghc < 9.3)
extra-libraries: stdc++
else
extra-libraries: c++ c++abi

But under the hood stdc++ and stdc++-6 are the same library, so GHC linker gets confused. This technically qualifies as a GHC bug, but a low-priority one, because GHC 9.4 comes with a virtual package system-cxx-std-lib to provide a portable solution for packages depending on C++ runtime.

double-conversion would have to adopt to system-cxx-std-lib anyway, so it can switch from stdc++-6 to stdc++ for older GHCs at the same time. CC @Haskell-mouse. In the meantime -simdutf will do.

@Bodigrim
Copy link
Contributor

Bodigrim commented Aug 2, 2022

Closing as there is nothing we can fix on text side, but feel free to forward this bug to GHC devs.

@Bodigrim Bodigrim closed this as completed Aug 2, 2022
@tfausak
Copy link
Author

tfausak commented Aug 3, 2022

Thanks for investigating! I think this issue is already solved by https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8086, so I won't open another issue against GHC.

Haskell-mouse pushed a commit to haskell/double-conversion that referenced this issue Aug 20, 2022
For GHC 8.6.5 and newer double conversion
is linked with `stdc++` instead of `stdc++-6`.

Related links:
haskell/text#461 (comment)
#13
Haskell-mouse pushed a commit to haskell/double-conversion that referenced this issue Aug 20, 2022
For GHC 8.6.5 and newer double conversion
is linked with `stdc++` instead of `stdc++-6`.

Related links:
haskell/text#461 (comment)
#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants