Re: --with-llvm on 32-bit platforms?

Dmitry Mityugov <d.mityugov@postgrespro.ru>

From: Dmitry Mityugov <d.mityugov@postgrespro.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers@postgresql.org
Date: 2025-09-15T20:08:28Z
Lists: pgsql-hackers
Tom Lane писал(а) 2025-09-15 22:16:
> Dmitry Mityugov <d.mityugov@postgrespro.ru> writes:
>> Peter Eisentraut wrote 2025-09-15 09:36:
>>> It seems plausible that this is related to commit 2a600a93c7b "Make
>>> type Datum be 8 bytes wide everywhere.".  I don't have any more
>>> insights than that.
> 
>> Thanks for the hint. I did git bisect, and [ Peter's right ]
> 
> Interesting.  You have at no point shown any details about what
> these failures look like.  However, I wonder if it could be
> something about broken alignment expectations.  The recent
> commit 09036dc71 fixed one thing that we'd managed not to notice
> in earlier testing, and I can't avoid the suspicion that there's
> more.

I did mention that `make check` fails if I enable --with-llvm flag on 
32-bit Linux platforms, for both GCC and Clang, at the very first 
message in this thread. Sorry if this got lost in quoting and 
formatting.

Thank you for pointing me to the commit, I'll check it.

What's interesting is that when I add the following (quick and dirty) 
assertion to DatumGetPointer on 32-bit Linux platforms,

DatumGetPointer(Datum X)
{
         Assert((X & 0xFFFFFFFF00000000) == 0);
         return (Pointer) (uintptr_t) X;
}

I get a failure in Postgres executable early on startup. If I am 
correct, this means that there are places in the code that assume that 
PointerGetDatum(DatumGetPointer(X)) == X, and this is not true if the 
pointer size is smaller than the Datum size. Hopefully I am not correct 
on this, but this might mean that the problem is broader than just 
enabling --with-llvm.

Thank you for your valuable time,



Commits

  1. jit: Fix type used for Datum values in LLVM IR.

  2. Avoid faulty alignment of Datums in build_sorted_items().

  3. Make type Datum be 8 bytes wide everywhere.