refactor: Add missing explicit instantiations of function templates #37007

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:261129-module-local changing 1 files +8 −0
  1. hebasto commented at 10:18 AM on November 29, 2026: member

    The SignatureHash and SignatureHashSchnorr function templates are defined in interpreter.cpp but are also used from other translation units, which have relied on implicit instantiations being emitted in that file. The standard does not guarantee that.

    This PR adds the missing explicit instantiations. It fixes linker errors (see the nightly builds with libstdc++ and libc++) when building with Clang 24, where module-local optimizer hints are now enabled by default. The change was introduced in https://github.com/llvm/llvm-project/pull/238529.

    A successful build of this branch with Clang 24 is available here: https://github.com/hebasto/bitcoin-core-nightly/pull/496.

    As a workaround, Clang's previous behavior can be restored with the -fno-module-local-hints flag.

  2. DrahtBot added the label Refactoring on Nov 29, 2026
  3. DrahtBot commented at 10:18 AM on November 29, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. in src/script/interpreter.cpp:1579 in 25b3e96c12
    1574 | @@ -1575,6 +1575,10 @@ bool SignatureHashSchnorr(uint256& hash_out, ScriptExecutionData& execdata, cons
    1575 |      return true;
    1576 |  }
    1577 |  
    1578 | +// explicit instantiation
    1579 | +template bool SignatureHashSchnorr<CTransaction>(uint256& hash_out, ScriptExecutionData& execdata, const CTransaction& tx_to, uint32_t in_pos, uint8_t hash_type, SigVersion sigversion, const PrecomputedTransactionData& cache, MissingDataBehavior mdb);
    


    maflcko commented at 4:13 PM on November 29, 2026:

    please omit all the arg names completely. IIUC this is the normal C++ pattern and also done so in addrman.cpp


    hebasto commented at 4:18 PM on November 29, 2026:

    Sure. Reworked.

  5. maflcko commented at 4:13 PM on November 29, 2026: member

    lgtm

  6. refactor: Add missing explicit instantiations of function templates
    `SignatureHash` and `SignatureHashSchnorr` are defined in
    `interpreter.cpp` but are also used from other translation units,
    which have relied on implicit instantiations being emitted there.
    The standard does not guarantee that.
    
    This fixes linker errors when building with Clang 24, where module-local
    optimizer hints are now enabled by default.
    See https://github.com/llvm/llvm-project/pull/238529.
    7ec6081eca
  7. hebasto force-pushed on Nov 29, 2026

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: 2026-11-30 03:50 UTC

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