]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Suppress "has no symbols" linker warnings on macOS.
authorNathan Bossart <nathan@postgresql.org>
Wed, 29 Apr 2026 17:25:09 +0000 (12:25 -0500)
committerNathan Bossart <nathan@postgresql.org>
Wed, 29 Apr 2026 17:25:09 +0000 (12:25 -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.
Per project policy, this is a candidate for back-patching into
out-of-support branches: it suppresses annoying compiler warnings
but changes no behavior.

Reported-by: Zhang Mingli <zmlpostgres@gmail.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/229aaaf3-f529-44ed-8e50-00cb6909af21%40Spark
Backpatch-through: 13

src/port/pg_cpu_x86.c
src/port/pg_popcount_aarch64.c
src/port/pg_popcount_x86.c

index 150b4a1d574d216e979fe537d571012940854906..f22167da9afb014908106b46511a72970c23e9ba 100644 (file)
@@ -263,5 +263,10 @@ x86_hypervisor_tsc_frequency_khz(void)
        return 0;
 }
 
+#else                                                  /* defined(USE_SSE2) || defined(__i386__) */
 
-#endif                                                 /* defined(USE_SSE2) || defined(__i386__) */
+/* prevent linker complaints about empty module */
+extern int     pg_cpu_x86_dummy_variable;
+int                    pg_cpu_x86_dummy_variable = 0;
+
+#endif                                                 /* ! (USE_SSE2 || __i386__) */
index 3969a42523ca02a55419b5496eabddccb7cd76f9..fc249bf8766ecfcede99873baf2ed53fa1970815 100644 (file)
@@ -463,4 +463,10 @@ pg_popcount_masked_neon(const char *buf, int bytes, uint8 mask)
        return popcnt;
 }
 
-#endif                                                 /* USE_NEON */
+#else                                                  /* USE_NEON */
+
+/* prevent linker complaints about empty module */
+extern int     pg_popcount_aarch64_dummy_variable;
+int                    pg_popcount_aarch64_dummy_variable = 0;
+
+#endif                                                 /* ! USE_NEON */
index 91579e6b56967419d04f33a90eb05bf3b0e22646..6df76c77c4163bbc24fa96c6b0f0884c19d82a97 100644 (file)
@@ -301,4 +301,10 @@ pg_popcount_masked_sse42(const char *buf, int bytes, uint8 mask)
        return popcnt;
 }
 
-#endif                                                 /* HAVE_X86_64_POPCNTQ */
+#else                                                  /* HAVE_X86_64_POPCNTQ */
+
+/* prevent linker complaints about empty module */
+extern int     pg_popcount_x86_dummy_variable;
+int                    pg_popcount_x86_dummy_variable = 0;
+
+#endif                                                 /* ! HAVE_X86_64_POPCNTQ */