Re: LTO aggressively optimizing out function despite explicit calls in logical decoding - Mailing list pgsql-hackers

From Andres Freund
Subject Re: LTO aggressively optimizing out function despite explicit calls in logical decoding
Date
Msg-id qic7zk26o4rujrtetiduzcloajjxkbdsxs2xmfuojq6g23wbgr@ic4oldvznli2
Whole thread Raw
In response to LTO aggressively optimizing out function despite explicit calls in logical decoding  (Arkady Skvorcov <arkashaskv@gmail.com>)
List pgsql-hackers
Hi,

On 2025-11-06 11:39:03 +0400, Arkady Skvorcov wrote:
> I'm working on a logical decoding improvement and running into a persistent
> build issue where LTO (-flto=thin) is optimizing out my LogicalWaitForWal
> function, even though there are explicit calls to it.
> 
> The situation:
> 
> Function LogicalWaitForWal() is defined in
> src/backend/replication/logical/logical.c
> 
> It's called directly from logical_read_xlog_page_cv() in the same file
> 
> logical_read_xlog_page_cv is assigned as the page_read callback via
> XL_ROUTINE in multiple places in logical.c
> 
> The function appears in the object file (nm logical.o shows it)
> 
> But it's completely absent from the final binary (nm postgres shows nothing)

Presumably what is happening is that it is inlined into the caller(s)?


> Is there a PostgreSQL-specific pattern or macro I should be using to ensure
> functions aren't optimized out when they're called via function pointers
> assigned in structs?

What problem is this actually causing for you?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Consistently use the XLogRecPtrIsInvalid() macro
Next
From: Tom Lane
Date:
Subject: Re: Reorganize GUC structs