Re: libtool is adding "-L/usr/lib" even for cross-compilation with sysroot

2022-02-15 Thread Roumen Petrov

Hi,

Xi Ruoyao wrote:

Hi libtool dev,

We've recently hit an issue cross-compiling some package using libtool
for sysroot.  Saying libfoo.la contains

So there is a number of models . One to use system libtool and another one 
libtool script builds for project.
First is not for cross-compilation.

Second one should learn some thing related to build system .


libdir=/usr/lib

Then libtool will add "-L/usr/lib" to the linker command line during a
"relink" against libfoo.la, because ltmain.in:6500:

[SNIP]


For instance my script hat builds packages for Android has:
...
CC="$CC --sysroot=$ANDROID_SYSROOT"
...
CONFIG_SITE=$TMPDIR/config.site-$FULLNAME-$PLATFORM
  cat > $CONFIG_SITE <

libtool is adding "-L/usr/lib" even for cross-compilation with sysroot

2022-02-14 Thread Xi Ruoyao
Hi libtool dev,

We've recently hit an issue cross-compiling some package using libtool
for sysroot.  Saying libfoo.la contains

libdir=/usr/lib

Then libtool will add "-L/usr/lib" to the linker command line during a
"relink" against libfoo.la, because ltmain.in:6500:

>   else
> # We cannot seem to hardcode it, guess we'll fake it.
> add_dir=-L$libdir
  ^
> # Try looking first in the location we're being installed to.
> if test -n "$inst_prefix_dir"; then
>   case $libdir in
> [\\/]*)
>   func_append add_dir " -L$inst_prefix_dir$libdir"
>   ;;
>   esac
> fi
> add=-l$name
>   fi

Now the linker will try to use the system library in /usr/lib, causing
link error or runtime issue.

There is a patch at
https://lists.gnu.org/archive/html/libtool-patches/2021-10/msg00017.html
changing -L$libdir to -L$lt_sysroot$libdir at this line, but maybe the
author didn't submitted it properly (I guess it should be submitted into
https://savannah.gnu.org/patch/?group=libtool, instead of the list). 
Could this change, or something similar be applied in the incoming new
release?
-- 
Xi Ruoyao 
School of Aerospace Science and Technology, Xidian University