[lld] 20b2d32 - [lld-macho] Work around odr-use of const non-inline static data member to fix -O0 build after D128298

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 17:59:29 PDT 2022


Could you add definitions for these static constexpr instead of
working around with casts? - chances are someone else will trip over
this/easily introduce an ODR-use in the future. They should have
definitions.

On Tue, Jun 21, 2022 at 7:22 PM Fangrui Song via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Fangrui Song
> Date: 2022-06-21T19:22:28-07:00
> New Revision: 20b2d3260d4a1878ca2a37cee6ee335a21a12d0f
>
> URL: https://github.com/llvm/llvm-project/commit/20b2d3260d4a1878ca2a37cee6ee335a21a12d0f
> DIFF: https://github.com/llvm/llvm-project/commit/20b2d3260d4a1878ca2a37cee6ee335a21a12d0f.diff
>
> LOG: [lld-macho] Work around odr-use of const non-inline static data member to fix -O0 build after D128298
>
> ```
> ld.lld: error: undefined symbol: lld::macho::CodeSignatureSection::blockSize
> >>> referenced by SyntheticSections.cpp:1253 (/home/maskray/llvm/lld/MachO/SyntheticSections.cpp:1253)
> >>>               tools/lld/MachO/CMakeFiles/lldMachO.dir/SyntheticSections.cpp.o:(lld::macho::CodeSignatureSection::writeHashes(unsigned char*) const::$_7::operator()(unsigned long) const)
> ```
>
> Added:
>
>
> Modified:
>     lld/MachO/SyntheticSections.cpp
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
> index 4d7256e847fa..dabe158d97f5 100644
> --- a/lld/MachO/SyntheticSections.cpp
> +++ b/lld/MachO/SyntheticSections.cpp
> @@ -1250,7 +1250,8 @@ void CodeSignatureSection::writeHashes(uint8_t *buf) const {
>    uint8_t *hashes = buf + fileOff + allHeadersSize;
>    parallelFor(0, getBlockCount(), [&](size_t i) {
>      sha256(buf + i * blockSize,
> -           std::min(static_cast<size_t>(fileOff - i * blockSize), blockSize),
> +           std::min(static_cast<size_t>(fileOff - i * blockSize),
> +                    static_cast<size_t>(blockSize)),
>             hashes + i * hashSize);
>    });
>  #if defined(__APPLE__)
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list