Subject: [PATCH v4 1/1] Suppress "has no symbols" linker warnings on macOS.

From: Nathan Bossart <[email-masked]>
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-masked]>
Discussion: https://postgr.es/m/229aaaf3-f529-44ed-8e50-00cb6909af21%40Spark
Backpatch-through: 14
---
 src/port/pg_popcount_aarch64.c | 8 +++++++-
 src/port/pg_popcount_avx512.c  | 9 ++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/port/pg_popcount_aarch64.c b/src/port/pg_popcount_aarch64.c
index 0b6b86de4d0..7a8c6d44e3c 100644
--- a/src/port/pg_popcount_aarch64.c
+++ b/src/port/pg_popcount_aarch64.c
@@ -478,4 +478,10 @@ pg_popcount_masked_neon(const char *buf, int bytes, bits8 mask)
 	return popcnt;
 }
 
-#endif							/* POPCNT_AARCH64 */
+#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_avx512.c b/src/port/pg_popcount_avx512.c
index 80c0aee3e73..d8998aa2083 100644
--- a/src/port/pg_popcount_avx512.c
+++ b/src/port/pg_popcount_avx512.c
@@ -220,4 +220,11 @@ pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask)
 }
 
 #endif							/* TRY_POPCNT_X86_64 */
-#endif							/* USE_AVX512_POPCNT_WITH_RUNTIME_CHECK */
+
+#else
+
+/* prevent linker complaints about empty module */
+extern int	pg_popcount_avx512_dummy_variable;
+int			pg_popcount_avx512_dummy_variable = 0;
+
+#endif
-- 
2.50.1 (Apple Git-155)

--TDT48G9Q3XiJHnLN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v4-0001-Suppress-has-no-symbols-linker-warnings-on.patch.master