]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
build: Fix "make install" failure on Android.
authorBruno Haible <bruno@clisp.org>
Sun, 17 Sep 2023 19:11:09 +0000 (21:11 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 19 Sep 2023 02:11:24 +0000 (04:11 +0200)
This patch fixes two problems with "make install" on Android:

1) On this platform, libtool is configured to relink libraries during
"make install".
This leads to a problem during the installation of libgettextsrc: The relink
command that libtool emits has the form

  $CC -shared -fPIC -DPIC .libs/*.o -L$(libdir) ... -lgettextlib ... \
      -o .libs/libgettextsrc-@VERSION@.soT

The option -lgettextlib resolves to $(libdir)/libgettextlib.a, not to
$(libdir)/libgettextlib-@VERSION@.so.
Thus the linker attempts to include many object files from libgettextlib.a
into libgettextsrc-@VERSION@.soT, but some of these reference global variables
in a non-PIC way, and the linker thus complains

  ld.lld: error: relocation R_ARM_REL32 cannot be used against symbol 'program_name'; recompile with -fPIC

2) The installed executables don't have a RUNPATH property that points to the
directory that contains the shared libraries. Thus these executables don't run.

Reported at <https://savannah.gnu.org/patch/index.php?10393>.

* m4/libtool.m4: On Android, fix library_names_spec and
hardcode_libdir_flag_spec.

m4/libtool.m4

index 5dffb192f9b2f6edb39c2d40bff285dda52509d1..ea4d35963ac77808ccea4e853baf06d1aa47e1e5 100644 (file)
@@ -2840,7 +2840,7 @@ linux*android*)
   version_type=none # Android doesn't support versioned libraries.
   need_lib_prefix=no
   need_version=no
-  library_names_spec='$libname$release$shared_ext'
+  library_names_spec='$libname$release$shared_ext $libname$shared_ext'
   soname_spec='$libname$release$shared_ext'
   finish_cmds=
   shlibpath_var=LD_LIBRARY_PATH
@@ -2852,8 +2852,9 @@ linux*android*)
   hardcode_into_libs=yes
 
   dynamic_linker='Android linker'
-  # Don't embed -rpath directories since the linker doesn't support them.
-  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+  # -rpath works at least for libraries that are not overridden by
+  # libraries installed in system locations.
+  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
   ;;
 
 # This must be glibc/ELF.