public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
Subject: [PATCH v4 1/1] Suppress "has no symbols" linker warnings on macOS.
Date: Tue, 28 Apr 2026 15:27:39 -0500

After a recent macOS update, building Postgres produces warnings
that look like this:

    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

To fix, add a dummy symbol to files that may otherwise have none.

Reported-by: Zhang Mingli <[email protected]>
Discussion: https://postgr.es/m/229aaaf3-f529-44ed-8e50-00cb6909af21%40Spark
Backpatch-through: 14
---
 src/port/pg_cpu_x86.c          | 7 ++++++-
 src/port/pg_popcount_aarch64.c | 8 +++++++-
 src/port/pg_popcount_x86.c     | 8 +++++++-
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/port/pg_cpu_x86.c b/src/port/pg_cpu_x86.c
index 150b4a1d574..2a4eae8688b 100644
--- a/src/port/pg_cpu_x86.c
+++ b/src/port/pg_cpu_x86.c
@@ -263,5 +263,10 @@ x86_hypervisor_tsc_frequency_khz(void)
 	return 0;
 }
 
+#else
+
+/* prevent linker complaints about empty module */
+extern int	pg_cpu_x86_dummy_variable;
+int			pg_cpu_x86_dummy_variable = 0;
 
-#endif							/* defined(USE_SSE2) || defined(__i386__) */
+#endif
diff --git a/src/port/pg_popcount_aarch64.c b/src/port/pg_popcount_aarch64.c
index 3969a42523c..68a768bac01 100644
--- a/src/port/pg_popcount_aarch64.c
+++ b/src/port/pg_popcount_aarch64.c
@@ -463,4 +463,10 @@ pg_popcount_masked_neon(const char *buf, int bytes, uint8 mask)
 	return popcnt;
 }
 
-#endif							/* USE_NEON */
+#else
+
+/* prevent linker complaints about empty module */
+extern int	pg_popcount_aarch64_dummy_variable;
+int			pg_popcount_aarch64_dummy_variable = 0;
+
+#endif
diff --git a/src/port/pg_popcount_x86.c b/src/port/pg_popcount_x86.c
index 91579e6b569..b3a6d8b3b0c 100644
--- a/src/port/pg_popcount_x86.c
+++ b/src/port/pg_popcount_x86.c
@@ -301,4 +301,10 @@ pg_popcount_masked_sse42(const char *buf, int bytes, uint8 mask)
 	return popcnt;
 }
 
-#endif							/* HAVE_X86_64_POPCNTQ */
+#else
+
+/* prevent linker complaints about empty module */
+extern int	pg_popcount_x86_dummy_variable;
+int			pg_popcount_x86_dummy_variable = 0;
+
+#endif
-- 
2.50.1 (Apple Git-155)


--TDT48G9Q3XiJHnLN--





view thread (6+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v4 1/1] Suppress "has no symbols" linker warnings on macOS.
  In-Reply-To: <no-message-id-603099@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox