mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 22:13:39 +00:00
compiler: fix incorrect unsafe.Alignof on some 32-bit architectures
This should fix https://github.com/tinygo-org/tinygo/issues/2643
This commit is contained in:
@@ -234,10 +234,15 @@ func Sizes(machine llvm.TargetMachine) types.Sizes {
|
||||
panic("unknown pointer size")
|
||||
}
|
||||
|
||||
// Construct a complex128 type because that's likely the type with the
|
||||
// biggest alignment on most/all ABIs.
|
||||
ctx := llvm.NewContext()
|
||||
defer ctx.Dispose()
|
||||
complex128Type := ctx.StructType([]llvm.Type{ctx.DoubleType(), ctx.DoubleType()}, false)
|
||||
return &stdSizes{
|
||||
IntSize: int64(intWidth / 8),
|
||||
PtrSize: int64(targetData.PointerSize()),
|
||||
MaxAlign: int64(targetData.PrefTypeAlignment(targetData.IntPtrType())),
|
||||
MaxAlign: int64(targetData.ABITypeAlignment(complex128Type)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user