Re: Centralised architecture detection

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: Thomas Munro <thomas.munro@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Andres Freund <andres@anarazel.de>, Lukas Fittl <lukas@fittl.com>, John Naylor <johncnaylorls@gmail.com>, Bryan Green <dbryan.green@gmail.com>
Date: 2026-06-03T19:24:22Z
Lists: pgsql-hackers
=?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= <ilmari@ilmari.org> writes:
> Thomas Munro <thomas.munro@gmail.com> writes:
>> Instead of repeating compilers' architecture macros throughout the tree
>> and sometimes getting it wrong, let's detect them in one central place,
>> and define our own macros of the form:
>> 
>> PG_ARCH_{ARM,LOONGARCH,MIPS,PPC,RISCV,S390,SPARC,X86}
>> PG_ARCH_{ARM,LOONGARCH,MIPS,PPC,RISCV,S390,SPARC,X86}_{32,64}

Nathan Bossart reminded me of this thread after I'd independently
rediscovered the same thing [1].  I agree with standardizing on
just one spelling of these CPU-type macros.  But I wonder why we
should invent our own instead of standardizing on gcc's spellings
(that is, __x86_64__ etc).  The amount of code churn required for
this patch would drop drastically if we did it that way.  And I
suspect it would be less likely that we'd need to fixup future patch
submissions than if we have a homegrown standard.

			regards, tom lane

[1] https://www.postgresql.org/message-id/flat/3035145.1780503430%40sss.pgh.pa.us



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix CPU-identification macros for RISC-V.

  2. Clean up inconsistencies in CPU-identification macros.