Skip to content

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

Closed

Description

@tfausak

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.

Activity

  1. Bodigrim commented on Jul 27, 2022

    @Bodigrim
    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.

  2. tfausak commented on Jul 29, 2022

    @tfausak
    Author

    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

  3. Bodigrim commented on Jul 29, 2022

    @Bodigrim
    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.

  4. Bodigrim commented on Aug 2, 2022

    @Bodigrim
    Contributor

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

  5. tfausak commented on Aug 3, 2022

    @tfausak
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions