Use clang in VS build? #31456

issue maflcko openend this issue on December 10, 2024
  1. maflcko commented at 11:04 am on December 10, 2024: member

    MSVC has many issues, for example:

    Thus, it could make sense to evaluate whether to switch the build docs to clang (possibly with libc++), see https://learn.microsoft.com/en-us/cpp/build/clang-support-msbuild

  2. maflcko added the label Brainstorming on Dec 10, 2024
  3. maflcko added the label Windows on Dec 10, 2024
  4. maflcko added the label Build system on Dec 10, 2024
  5. willcl-ark commented at 4:16 pm on December 10, 2024: member
    Would this open us up to ARM Windows builds as requested in #31388 ?
  6. ryanofsky commented at 4:59 pm on December 10, 2024: contributor

    MSVC has many issues, for example:

    Another one:

    • Non-compilant pre-processor: 5db1958e60aef9d3604448c21e1f397e561480ee from #29256. Though it looks like we could work around this with /Zc:preprocessor

    Am agnostic on this issue though. I could imagine benefits to compiler diversity like ensuring is more portable, or finding bugs missed by other compilers, or allowing more developer tools to be used. But those things might not apply here.

  7. TheCharlatan commented at 9:16 am on December 11, 2024: contributor
    Also #31158?
  8. maflcko commented at 11:07 am on December 11, 2024: member

    I could imagine benefits to compiler diversity like ensuring is more portable, or finding bugs missed by other compilers, or allowing more developer tools to be used.

    Good point. I guess the only portability issues or bugs were found by using the msSTL, so using clang+msSTL should be fine. If there are real bugs found by msvc (or tools that only work with msvc), it would be good to list them in this brainstorming issue. Otherwise, the reasoning seems recursive, to write portable code to support msvc, for the only reason that msvc can be supported.

  9. hebasto commented at 12:41 pm on December 12, 2024: member

    FWIW, to build with Clang locally, one should install the following VS components: photo_2024-12-12_12-38-17

    and pass -T ClangCL to cmake at the configuration step.

    However, besides multiple warnings, the build fails:

    0lld-link : error : duplicate symbol: public: static class uint256 const uint256::ZERO [C:\Users\hebasto\bitcoin\build-static\src\test\test_bitcoin.vcxproj]
    1  >>> defined at C:\Users\hebasto\bitcoin\build-static\src\bitcoin_consensus.dir\Debug\uint256.obj
    2  >>> defined at bitcoin_consensus.lib(uint256.obj)
    
  10. hebasto commented at 9:52 am on December 13, 2024: member
  11. hebasto commented at 10:59 am on December 16, 2024: member
    Please consider #31507.
  12. hebasto commented at 11:33 am on December 16, 2024: member

    Also #31158?

    I just tested building bitcoin-chainstate.exe and bitcoinkernel.dll with clang-cl.

    Unfortunately, the fix from #31158 is still necessary.


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-12-21 12:12 UTC

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