Hi,

Attached a patch with a (hopefully) better wording of the comment.

I have unsuccessfully tried to find an official source for this policy.
So for reference some discussions about the topic:

-
https://stackoverflow.com/questions/11491065/linking-with-versioned-shared-library-in-android-ndk
-
https://stackoverflow.com/questions/18681401/how-can-i-remove-all-versioning-information-from-shared-object-files

Please let me know if I can help in any way

Matthias

On Tue, Jan 2, 2024 at 6:43 PM Robert Haas <robertmh...@gmail.com> wrote:

> On Sun, Dec 31, 2023 at 1:24 AM Michael Paquier <mich...@paquier.xyz>
> wrote:
> > FWIW, I have mixed feelings about patching the code to treat
> > android-linux as an exception while changing nothing in the
> > documentation to explain why this is required.  A custom patch may
> > serve you better here, and note that you did not even touch the meson
> > paths.  See libpq_c_args in src/interfaces/libpq/meson.build as one
> > example.  That's just my opinion, of course, still there are no
> > buildfarm members that would cover your patch.
>
> It's reasonable to want good comments -- the one in the patch (1)
> doesn't explain why this is required and (2) suggests that it is only
> needed when cross-compiling which seems surprising and (3) has a typo.
> But if it's true that this is needed, I tentatively think we might do
> better to take the patch than force people to carry it out of tree.
>
> --
> Robert Haas
> EDB: http://www.enterprisedb.com
>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 75dc81a..9c88558 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1989,6 +1989,14 @@ build-postgresql:
       among developers is to use <envar>PROFILE</envar> for one-time flag
       adjustments, while <envar>COPT</envar> might be kept set all the time.
      </para>
+
+     <para>
+      When building libpq as shared libraries, the resulting files are suffixed
+      with the version <literal>libpq.5.[version]</literal> and an unversioned
+      symlink <literal>libpq.so</literal>to the versioned file is created. An
+      exception to that is Android where library file names must end with
+      <literal>.so</literal>. Building for Android is only supported using make.
+     </para>
     </note>
   </sect2>
  </sect1>
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 92d893e..4801b7a 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -187,7 +187,13 @@ endif
 ifeq ($(PORTNAME), linux)
   LINK.shared		= $(COMPILER) -shared
   ifdef soname
-    LINK.shared		+= -Wl,-soname,$(soname)
+    ifeq (linux-android,$(findstring linux-android,$(host_os)))
+        # Android does not support versioned soname
+        shlib		= lib$(NAME)$(DLSUFFIX)
+        LINK.shared		+= -Wl,-soname,lib$(NAME)$(DLSUFFIX)
+    else
+        LINK.shared		+= -Wl,-soname,$(soname)
+    endif
   endif
   BUILD.exports		= ( echo '{ global:'; $(AWK) '/^[^\#]/ {printf "%s;\n",$$1}' $<; echo ' local: *; };' ) >$@
   exports_file		= $(SHLIB_EXPORTS:%.txt=%.list)

Reply via email to