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

Started by Zhang Mingli4 months ago23 messageshackers
Jump to latest
#1Zhang Mingli
zmlpostgres@gmail.com

Hi,

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.

--
Zhang Mingli
HashData

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Zhang Mingli (#1)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

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.

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#2)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

Peter Eisentraut <peter@eisentraut.org> writes:

On 29.01.26 07:35, Zhang Mingli wrote:

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.

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

#4Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#3)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Wed, Feb 04, 2026 at 10:28:53AM -0500, Tom Lane wrote:

Peter Eisentraut <peter@eisentraut.org> writes:

On 29.01.26 07:35, Zhang Mingli wrote:

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.

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...

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

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Bossart (#4)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

Nathan Bossart <nathandbossart@gmail.com> writes:

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.

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

#6Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#5)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Wed, Feb 04, 2026 at 01:27:43PM -0500, Tom Lane wrote:

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.

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

--
nathan

#7Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#6)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

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

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Bossart (#7)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

Nathan Bossart <nathandbossart@gmail.com> writes:

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...

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

#9Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#8)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Sun, Apr 26, 2026 at 10:18:33PM -0400, Tom Lane wrote:

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.

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

--
nathan

#10Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#9)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Sun, Apr 26, 2026 at 09:31:37PM -0500, Nathan Bossart wrote:

On Sun, Apr 26, 2026 at 10:18:33PM -0400, Tom Lane wrote:

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.

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

Attachments:

v1-0001-avoid-ranlib-warnings-on-macOS.patchtext/plain; charset=us-asciiDownload+179-25
#11Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#10)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Mon, Apr 27, 2026 at 02:43:20PM -0500, Nathan Bossart wrote:

On Sun, Apr 26, 2026 at 09:31:37PM -0500, Nathan Bossart wrote:

On Sun, Apr 26, 2026 at 10:18:33PM -0400, Tom Lane wrote:

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.

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.

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

Attachments:

v2-0001-avoid-ranlib-warnings-on-macOS.patchtext/plain; charset=us-asciiDownload+189-32
#12John Naylor
john.naylor@enterprisedb.com
In reply to: Nathan Bossart (#10)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Tue, Apr 28, 2026 at 2:43 AM Nathan Bossart <nathandbossart@gmail.com> wrote:

On Sun, Apr 26, 2026 at 09:31:37PM -0500, Nathan Bossart wrote:

On Sun, Apr 26, 2026 at 10:18:33PM -0400, Tom Lane wrote:

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.

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

The gift that keeps on giving. ;-)

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.

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

#13Tom Lane
tgl@sss.pgh.pa.us
In reply to: John Naylor (#12)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

John Naylor <johncnaylorls@gmail.com> writes:

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

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

#14Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#13)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Tue, Apr 28, 2026 at 09:29:41AM -0400, Tom Lane wrote:

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...

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

Attachments:

v3-0001-avoid-ranlib-warnings-on-macOS.patchtext/plain; charset=us-asciiDownload+20-4
#15Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#14)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Tue, Apr 28, 2026 at 09:09:09AM -0500, Nathan Bossart wrote:

On Tue, Apr 28, 2026 at 09:29:41AM -0400, Tom Lane wrote:

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...

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.

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

Attachments:

v4-0001-Suppress-has-no-symbols-linker-warnings-on-ma.patch.v14text/plain; charset=us-asciiDownload+7-2
v4-0001-Suppress-has-no-symbols-linker-warnings-on-ma.patch.v15text/plain; charset=us-asciiDownload+7-2
v4-0001-Suppress-has-no-symbols-linker-warnings-on-ma.patch.v16text/plain; charset=us-asciiDownload+7-2
v4-0001-Suppress-has-no-symbols-linker-warnings-on-ma.patch.v17text/plain; charset=us-asciiDownload+7-2
v4-0001-Suppress-has-no-symbols-linker-warnings-on-ma.patch.v18text/plain; charset=us-asciiDownload+15-3
v4-0001-Suppress-has-no-symbols-linker-warnings-on.patch.mastertext/plain; charset=us-asciiDownload+20-4
#16Nathan Bossart
nathandbossart@gmail.com
In reply to: Nathan Bossart (#15)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Tue, Apr 28, 2026 at 03:32:28PM -0500, Nathan Bossart wrote:

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?

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

--
nathan

#17John Naylor
john.naylor@enterprisedb.com
In reply to: Nathan Bossart (#15)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Wed, Apr 29, 2026 at 3:32 AM Nathan Bossart <nathandbossart@gmail.com> wrote:

On Tue, Apr 28, 2026 at 09:09:09AM -0500, Nathan Bossart wrote:

On Tue, Apr 28, 2026 at 09:29:41AM -0400, Tom Lane wrote:

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...

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.

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

#18Peter Eisentraut
peter_e@gmx.net
In reply to: Nathan Bossart (#15)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On 28.04.26 22:32, Nathan Bossart wrote:

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?

Why should this be backpatched at all?

#19Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#18)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

Peter Eisentraut <peter@eisentraut.org> writes:

On 28.04.26 22:32, Nathan Bossart wrote:

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?

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

#20Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#19)
Re: [BUG?] macOS (Intel) build warnings: "ranlib: file … has no symbols" for aarch64 objects

On Wed, Apr 29, 2026 at 09:58:58AM -0400, Tom Lane wrote:

Peter Eisentraut <peter@eisentraut.org> writes:

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.

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

--
nathan

#21Nathan Bossart
nathandbossart@gmail.com
In reply to: John Naylor (#17)
#22Tom Lane
tgl@sss.pgh.pa.us
In reply to: Nathan Bossart (#21)
#23Nathan Bossart
nathandbossart@gmail.com
In reply to: Tom Lane (#22)