Subject: Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

From: Peter Eisentraut <[email-masked]>
Date: Wed, 4 Feb 2026 15:54:35 +0100

On 29.01.26 07:35, Zhang Mingli wrote:
> I'm building the master branch (commit 740a1494f4bf) on macOS (Intel 
> Core i7) and encountered the following warnings during the make process:
> 
> 
> 
> /Applications/Xcode.app/Contents/Developer/Toolchains/ 
> XcodeDefault.xctoolchain/usr/bin/ranlib: file: 
> libpgport.a(pg_popcount_aarch64.o) has no symbols
> /Applications/Xcode.app/Contents/Developer/Toolchains/ 
> XcodeDefault.xctoolchain/usr/bin/ranlib: file: 
> libpgport_shlib.a(pg_popcount_aarch64_shlib.o) has no symbols
> /Applications/Xcode.app/Contents/Developer/Toolchains/ 
> XcodeDefault.xctoolchain/usr/bin/ranlib: file: 
> libpgport_srv.a(pg_popcount_aarch64_srv.o) has no symbols
> 
> 
> The build completes successfully and the compiled binaries appear to 
> function correctly.
> These warnings appear to be related to the recent AArch64 (pg_popcount) 
> optimization commits (possibly 79e232ca013c and fbe327e5b465d). It seems 
> that on my Intel-based macOS system, the build process is generating 
> empty or placeholder object files for the AArch64-specific implementations.
> While there is no functional impact in my environment, I'm reporting 
> this to ensure it's noted, as other macOS/Intel users might encounter 
> the same warnings during their build.

Probably not worth fixing, since this is an obsolescent platform.

The opposite situation also exists: On macOS ARM, an empty 
pg_popcount_x86.c gets built, but apparently that linker doesn't warn 
about that.

---

From: Tom Lane <[email-masked]>
Date: Wed, 04 Feb 2026 10:28:53 -0500

> Probably not worth fixing, since this is an obsolescent platform.

Yeah.  My Intel Mac buildfarm animal (longfin) has been showing this
for some time, but there's no corresponding warning on its ARM Mac
brethren (sifaka/indri).  I doubt it's worth fixing just to get
rid of the warning.  Although if a fix arises organically out of the
nearby thread about popcount refactoring, that would be okay here...

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Wed, 4 Feb 2026 10:54:22 -0600

> nearby thread about popcount refactoring, that would be okay here...

Hm.  The options I see for fixing this seem to be:

* Pass -no_warning_for_no_symbols flag on this platform, but that option
might not be available in older toolchains.

* Add a random symbol to this file.  That seems like a hack.

* Add build logic to only compile this file when necessary.  I've been
trying to get rid of complexity here, so this feels like a step backwards.

IMHO none of these options seem worth the effort to fix a warning on an
obsolescent platform, so my vote is to do nothing for now.

-- 
nathan

---

From: Tom Lane <[email-masked]>
Date: Wed, 04 Feb 2026 13:27:43 -0500

> obsolescent platform, so my vote is to do nothing for now.

The idea I'd had was to simply merge pg_popcount_aarch64.c
and pg_popcount_x86.c into one file.  Since each one is basically
one giant #ifdef block conditioned on a different symbol, they'd not
interfere.  But I wouldn't propose this unless it made sense from
a code-structure viewpoint, and I'm not sure it does.  It could
make sense if there was some code that could be shared, but I'm
not seeing much.

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Wed, 4 Feb 2026 12:42:28 -0600

> make sense if there was some code that could be shared, but I'm

Yeah, even after the upcoming code simplification I'm working on, I'm not
sure that makes sense.

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Sun, 26 Apr 2026 20:54:04 -0500

Well, the latest macOS update added these warnings for aarch64:

ranlib: warning: 'libpgport_shlib.a(pg_cpu_x86.c.o)' has no symbols
ranlib: warning: 'libpgport_shlib.a(pg_popcount_x86.c.o)' has no symbols
ranlib: warning: 'libpgport_shlib.a(pg_cpu_x86.c.o)' has no symbols
ranlib: warning: 'libpgport_shlib.a(pg_popcount_x86.c.o)' has no symbols

I'm not seeing an easy way to pass -no_warning_for_no_symbols to ranlib, at
least with meson.  Hm...

-- 
nathan

---

From: Tom Lane <[email-masked]>
Date: Sun, 26 Apr 2026 22:18:33 -0400

> I'm not seeing an easy way to pass -no_warning_for_no_symbols to ranlib, at

Yeah, we aren't even calling ranlib directly, it goes through 'ar'
which doesn't expose any such option.  In any case that'd necessarily
be an OS-specific option.

I previously suggested that we should teach the build systems not
to build the foo_x86 and foo_aarch64 modules when not on those
architectures.  That was shot down for reasons that made no great
amount of sense to me, but I think it'd be fairly easy and clean.

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Sun, 26 Apr 2026 21:31:37 -0500

> amount of sense to me, but I think it'd be fairly easy and clean.

Yeah, AFAICT that's our best bet.  Will write it up in the morning.

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Mon, 27 Apr 2026 14:43:20 -0500

> Yeah, AFAICT that's our best bet.  Will write it up in the morning.

Here's what I have so far.  Two notes:

* Since pg_popcount_aarch64.c only builds symbols when USE_NEON is defined,
I needed to teach the build code about that #define.  So, this patch
effectively moves USE_NEON and USE_SSE2 from c.h to pg_config.h, which
happens to be the first #include within c.h.  The reason that I bring this
up is because back-patching it seems a little scary, although I don't see
any concrete reasons it would be unsafe.

* pg_cpu_x86.c has a similar problem, which I haven't fixed yet.
Presumably a similar approach will work there.  I've added John Naylor to
this thread for his thoughts.

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Mon, 27 Apr 2026 15:03:37 -0500

> this thread for his thoughts.

Sorry, I noticed I was using USE_SSE2 for choosing whether to build
pg_popcount_x86.c, but the code in that file is actually surrounded by
HAVE_X86_64_POPCNTQ.  New patch attached.

-- 
nathan

---

From: John Naylor <[email-masked]>
Date: Tue, 28 Apr 2026 13:18:22 +0700

> > Yeah, AFAICT that's our best bet.  Will write it up in the morning.

The gift that keeps on giving. ;-)

> any concrete reasons it would be unsafe.

It'd be a bit unfortunate for those symbols to bleed out into the
build system, so it seems best to minimize the need for that and do as
much as possible with just architecture. src/port/meson.build could do
instead

if host_cpu == 'x86' or host_cpu == 'x86_64'
  pgport_sources += files(
  'pg_cpu_x86.c',
  ...etc

(Ditto arm / aarch64) Likewise autoconf.ac could set e.g. PG_ARCH_OBJS
since it knows the host CPU as well. Some files could still guard on
USE_NEON or HAVE_X86_64_POPCNTQ, but at least they wouldn't get built
on the wrong arch. Would that be enough?

--
John Naylor
Amazon Web Services

---

From: Tom Lane <[email-masked]>
Date: Tue, 28 Apr 2026 09:29:41 -0400

> if host_cpu == 'x86' or host_cpu == 'x86_64'

This level of refinement is about what I was imagining for the
build systems.  Otherwise, if we add any more platform sub-categories
to those files, we'll have to complicate the build systems to match.

I'm not sure if we need to care about suppressing these warnings to
a greater degree than that.  My impression is that it won't be an
issue for macOS because of the uniformity of the underlying hardware.

If we do care, a low-tech solution could be to have a dummy symbol
declared in each file, along the lines of

#if HAVE_X86_64_POPCNTQ
// code for popcntq case
#elif HAVE_FROBNITZ
// code for frobnitz case
...
#else
/* prevent linker complaints about empty module */
extern int pg_cpu_x86_dummy_variable;
int	pg_cpu_x86_dummy_variable = 0;
#endif

Actually then we'd not need to change the build systems either...

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Tue, 28 Apr 2026 09:09:09 -0500

> Actually then we'd not need to change the build systems either...

I've been trying to avoid doing that, but it's a far simpler solution, and
in theory it should fix the problem for all platforms, too.  So, it's
probably the way to go.

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Tue, 28 Apr 2026 15:32:28 -0500

> in theory it should fix the problem for all platforms, too.  So, it's

Here's a full set of patches for back-patching purposes.
protocol_openssl.c has a similar problem on older versions.  I suppose this
is the sort of thing I could back-patch all the way to v9.2.  Does anyone
feel strongly one way or the other about that?

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Tue, 28 Apr 2026 15:48:13 -0500

> feel strongly one way or the other about that?

Actually, v9.2-v12 don't have protocol_openssl.c, so I'd only need to
back-patch this to v13.

-- 
nathan

---

From: John Naylor <[email-masked]>
Date: Wed, 29 Apr 2026 12:04:48 +0700

> Here's a full set of patches for back-patching purposes.

+1

-#endif           /* USE_NEON */
+#else
...
+#endif

Is the removal of the comment intentional?

-- 
John Naylor
Amazon Web Services

---

From: Peter Eisentraut <[email-masked]>
Date: Wed, 29 Apr 2026 08:07:12 +0200

> feel strongly one way or the other about that?

Why should this be backpatched at all?

---

From: Tom Lane <[email-masked]>
Date: Wed, 29 Apr 2026 09:58:58 -0400

> Why should this be backpatched at all?

To silence those warnings.  If you're using a Mac for development,
they're pretty annoying.  And we have generally had a policy of
trying to silence warnings in still-interesting branches.

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Wed, 29 Apr 2026 10:40:15 -0500

> trying to silence warnings in still-interesting branches.

Right, I was under the impression that was project policy, or at least
allowed per project policy.

-- 
nathan

---

From: Nathan Bossart <[email-masked]>
Date: Wed, 29 Apr 2026 10:41:29 -0500

> Is the removal of the comment intentional?

It was, but I'll add them back before committing.

-- 
nathan

---

From: Tom Lane <[email-masked]>
Date: Wed, 29 Apr 2026 11:44:14 -0400

> It was, but I'll add them back before committing.

+1, I found that annoying too.

			regards, tom lane

---

From: Nathan Bossart <[email-masked]>
Date: Wed, 29 Apr 2026 12:32:14 -0500

Committed.

-- 
nathan