Skip to content

Commit e8f03f2

Browse files
efriedma-quictstellar
authored andcommitted
Force GHashCell to be 8-byte-aligned.
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 (cherry picked from commit 13fc178)
1 parent 09fba23 commit e8f03f2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lld/COFF/DebugTypes.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,11 @@ struct GHashTable {
902902

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

907911
public:
908912
GHashCell() = default;

0 commit comments

Comments
 (0)