[PATCH] Fix build failure on macOS 26.2 SDK due to missing nl_langinfo_l declaration

Started by Jianghua Yang6 months ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t53545
psql -h localhost -U postgres

Built from patchset v1 (message #1), September 20, 2026 at 02:03 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t53545_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t53545_1 && git checkout t53545_1

Patchset v1 (message #1) is on t53545_1

Jump to latest
#1Jianghua Yang
yjhjstz@gmail.com

Hi,

Building PostgreSQL against the macOS 26.2 SDK (Xcode 26 beta) fails
with the following error:

src/port/chklocale.c:326:8: error: call to undeclared function
'nl_langinfo_l'; ISO C99 and later do not support implicit function
declarations [-Wimplicit-function-declaration]
sys = nl_langinfo_l(CODESET, loc);

== Root Cause ==

macOS 26.2 SDK changed the structure of <langinfo.h>. In previous
SDK versions, nl_langinfo_l() was declared unconditionally. In the
new SDK, it is only exposed when _USE_EXTENDED_LOCALES_ is defined,
guarded behind a conditional include of <xlocale/_langinfo.h>:

/* macOS 26.2 SDK: langinfo.h */
#include <_langinfo.h> /* nl_langinfo() only */

#ifdef _USE_EXTENDED_LOCALES_
#include <xlocale/_langinfo.h> /* nl_langinfo_l() */
#endif

PostgreSQL's chklocale.c only includes <langinfo.h> directly, so
nl_langinfo_l() is no longer visible on macOS 26.2.

== Fix ==

Include <xlocale.h> explicitly on Apple platforms. This header
declares nl_langinfo_l() unconditionally and is the standard way
to access locale-specific extensions on macOS.

Tested on macOS 26.2 (darwin 25.3) with Apple Clang 17.

Patch attached.

Regards,
Jianghua Yang

Attachments:

t53545_1
0001-Fix-build-failure-on-macOS-26.2-SDK-due-to-missing-n.patchapplication/octet-stream; name=0001-Fix-build-failure-on-macOS-26.2-SDK-due-to-missing-n.patchDownload+3-1
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jianghua Yang (#1)
Re: [PATCH] Fix build failure on macOS 26.2 SDK due to missing nl_langinfo_l declaration

Jianghua Yang <yjhjstz@gmail.com> writes:

Include <xlocale.h> explicitly on Apple platforms. This header
declares nl_langinfo_l() unconditionally and is the standard way
to access locale-specific extensions on macOS.

What version are you testing? v18 and HEAD already unconditionally
include <xlocale.h> in our c.h (around line 80 in HEAD), and older
branches don't use nl_langinfo_l().

See also [1]/messages/by-id/1026321.1765562828@sss.pgh.pa.us.

regards, tom lane

[1]: /messages/by-id/1026321.1765562828@sss.pgh.pa.us