Re: Build with LTO / -flto on macOS

Wolfgang Walther <walther@technowledgy.de>

From: walther@technowledgy.de
To: Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>
Date: 2024-06-03T17:11:14Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Make building with LTO work on macOS

  2. Require memory barrier support.

  3. Require compiler barrier support.

  4. autoconf: Move export_dynamic determination to configure

Wolfgang Walther:
> Peter:
>> I don't think we explicitly offer LTO builds as part of the make build 
>> system, so anyone trying this would do it sort of self-service, by 
>> passing additional options to configure or make.  In which case they 
>> might as well pass the -export_dynamic option along in the same way?
> 
> The challenge is that it defeats the purpose of LTO to pass this along 
> to everything, e.g. via CFLAGS. The Makefiles set this in LDFLAGS_EX_BE 
> only, so it only affects the backend binary. This is not at all obvious 
> and took me quite a while to figure out why LTO silently didn't strip 
> symbols from other binaries. It does work to explicitly set 
> LDFLAGS_EX_BE, though.

Oh, and more importantly: LDFLAGS_EX_BE is not available on all back 
branches. It was only introduced in v16 in preparation for meson. So up 
to v15, I would have to patch src/makesfiles/Makefile.darwin to set 
export_dynamic.

So back-patching a change like this would certainly help to get LTO 
across versions seamlessly - which is what I am trying to achieve while 
packaging all versions in nixpkgs / NixOS.

Best,

Wolfgang