depends: For mingw cross compile use -gcc-posix to prevent library conflict #31013

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2024-10-mingw-posix-gcc changing 1 files +3 −0
  1. laanwj commented at 5:49 pm on October 1, 2024: member

    CMake parses some paths from the spec of the C compiler, assuming it will be the linker, resulting in the link to end up with -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32 on debian bookworm if both -win32 and -posix variants are installed, and -win32 is the default alternative.

    This results in the wrong C++ library being linked, missing std::threads::hardware_concurrency and other threading functions.

    To fix this, use the -posix variant of gcc as well when available. This fixes a regression compared to autotools, where this scenario worked.

  2. depends: For mingw cross compile use -gcc-posix to prevent library conflict
    CMake parses some paths from the spec of the C compiler, assuming it
    will be the linker, resulting in the link to end up with
    `-L/usr/lib/gcc/x86_64-w64-mingw32/12-win32` on debian bookworm if both
    -win32 and -posix variants are installed, and -win32 is the default
    alternative.
    
    This results in the wrong C++ library being linked, missing
    std::threads::hardware_concurrency and other threading functions.
    
    To fix this, use the -posix variant of gcc as well when available. This
    fixes a regression compared to autotools, where this scenario worked.
    ae56b3230b
  3. laanwj added the label Windows on Oct 1, 2024
  4. laanwj added the label Build system on Oct 1, 2024
  5. DrahtBot commented at 5:49 pm on October 1, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK theuni, hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  6. hebasto commented at 6:50 pm on October 1, 2024: member

    Here is a related upstream issue: https://gitlab.kitware.com/cmake/cmake/-/issues/25670.

    The regression is behavior is caused by setting CMAKE_TRY_COMPILE_TARGET_TYPE globally:https://github.com/bitcoin/bitcoin/blob/fc642c33ef28829eda0119a0fe39fd9bc4b84051/cmake/module/CheckSourceCompilesAndLinks.cmake#L9-L10

  7. laanwj commented at 7:24 pm on October 1, 2024: member
    Yes, that seems similar! It would work perfectly fine without adding any -L spec, the linker knows where to find its libraries, no need to add the implicit link directories explicitly at all, but it does and it breaks.
  8. theuni approved
  9. theuni commented at 5:39 pm on October 2, 2024: member

    utACK ae56b3230b287eef5a5657d3089abebffde51484.

    Annoying upstream bug aside, this seems reasonable enough to me.

  10. hebasto commented at 7:36 pm on October 2, 2024: member

    It looks reasonable to be explicit about every aspect of a toolchain.

    However, I’m wondering why the bug appears on Debian Bookworm, but not on Ubuntu 24.04? I’ve cross-checked CMake versions and can confirm they are not the cause.

  11. hebasto approved
  12. hebasto commented at 8:08 pm on October 2, 2024: member

    ACK ae56b3230b287eef5a5657d3089abebffde51484. I’ve tested on both Debian Bookworm and Ubuntu 24.04 with the g++-mingw-w64-x86-64 package installed. The resulting CMake internal configuration appears more accurate. For instance, on Ubuntu 24.04, for the bitcoin-tx target, the diff in build/src/CMakeFiles/bitcoin-tx.dir/linkLibs.rsp looks as follows:

    0-  -L"/usr/lib/gcc/x86_64-w64-mingw32/13-win32"  libbitcoin_common.a util/libbitcoin_util.a univalue/libunivalue.a -liphlpapi libbitcoin_consensus.a crypto/libbitcoin_crypto.a crypto/libbitcoin_crypto_sse41.a crypto/libbitcoin_crypto_avx2.a crypto/libbitcoin_crypto_x86_shani.a secp256k1/src/libsecp256k1.a -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 
    1+ libbitcoin_common.a util/libbitcoin_util.a univalue/libunivalue.a -liphlpapi libbitcoin_consensus.a crypto/libbitcoin_crypto.a crypto/libbitcoin_crypto_sse41.a crypto/libbitcoin_crypto_avx2.a crypto/libbitcoin_crypto_x86_shani.a secp256k1/src/libsecp256k1.a -lws2_32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 
    
  13. maflcko added the label DrahtBot Guix build requested on Oct 7, 2024
  14. DrahtBot commented at 2:57 am on October 8, 2024: contributor

    Guix builds (on x86_64) [untrusted test-only build, possibly unsafe, not for production use]

    File commit 62e4516722115c2d5aeb6c197abc73ca7c078b23(master) commit 6f29621c09e45661abf02f6f4a610e0285f9050d(master and this pull)
    SHA256SUMS.part f2d49fb72517ef0c... 7f2b287cc30a69c8...
    *-aarch64-linux-gnu-debug.tar.gz d37cbe26a25f7540... 439f3e5bf57b5320...
    *-aarch64-linux-gnu.tar.gz 42b4d4db0c531caf... d93344ad7aa9df0c...
    *-arm-linux-gnueabihf-debug.tar.gz 63eddcf3cfdb6c32... 23738e0f6be3d04c...
    *-arm-linux-gnueabihf.tar.gz fd2eb3904357b5f4... fe4967c1ccd40706...
    *-arm64-apple-darwin-unsigned.tar.gz 71a08c8f938313cf... 4ebb391123bca8ee...
    *-arm64-apple-darwin-unsigned.zip ed11994d8f055418... 189a308a76bed38d...
    *-arm64-apple-darwin.tar.gz 0c11a002f4f3030c... 9d3d85c06609fee3...
    *-powerpc64-linux-gnu-debug.tar.gz a76483c3abcddcc1... dca81c8c0d2016bd...
    *-powerpc64-linux-gnu.tar.gz 335ec17b370a19d5... 11d2714fe4c3b339...
    *-riscv64-linux-gnu-debug.tar.gz 8494e354e088382e... e016b6adda7cbcd0...
    *-riscv64-linux-gnu.tar.gz 457df2421685bdda... 5ec72bfa456b585c...
    *-x86_64-apple-darwin-unsigned.tar.gz 3cedc5861a78c8a5... 4fb72933e7ab52bb...
    *-x86_64-apple-darwin-unsigned.zip 19b332dccbc792b4... 139ab4844824faf2...
    *-x86_64-apple-darwin.tar.gz 54c6788eb266f818... 3e178cee339db915...
    *-x86_64-linux-gnu-debug.tar.gz a761c3712ed00392... 55bdb323a72babed...
    *-x86_64-linux-gnu.tar.gz fceda20d8f50b5ab... 9d8037be72e1a2f0...
    *.tar.gz 38978a4be1a7c7eb... 3d7f416fd69a809c...
    guix_build.log b4092f80775416ae... f5c2428f183bb778...
    guix_build.log.diff bb5f9db91a37811e...
  15. DrahtBot removed the label DrahtBot Guix build requested on Oct 8, 2024
  16. fanquake merged this on Oct 8, 2024
  17. fanquake closed this on Oct 8, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-08 16:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me