Skip to content

Commit

Permalink
Force GHashCell to be 8-byte-aligned.
Browse files Browse the repository at this point in the history
Otherwise, with recent versions of libstdc++, clang can't tell that the
atomic operations are properly aligned, and generates calls to
libatomic.  (Actually, because of the use of reinterpret_cast, it wasn't
guaranteed to be aligned, but I think it ended up being aligned in
practice.)

Fixes #54790 , the part where
LLVM failed to build.

Differential Revision: https://reviews.llvm.org/D123872
  • Loading branch information
efriedma-quic committed Apr 18, 2022
1 parent daa6d7b commit 13fc178
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lld/COFF/DebugTypes.cpp
Expand Up @@ -902,7 +902,11 @@ struct GHashTable {

/// A ghash table cell for deduplicating types from TpiSources.
class GHashCell {
uint64_t data = 0;
// Force "data" to be 64-bit aligned; otherwise, some versions of clang
// will generate calls to libatomic when using some versions of libstdc++
// on 32-bit targets. (Also, in theory, there could be a target where
// new[] doesn't always return an 8-byte-aligned allocation.)
alignas(sizeof(uint64_t)) uint64_t data = 0;

public:
GHashCell() = default;
Expand Down

0 comments on commit 13fc178

Please sign in to comment.