bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: DESTDIR install final relinking issue.


From: Ryan, Paul L.
Subject: RE: DESTDIR install final relinking issue.
Date: Thu, 14 Apr 2005 09:30:34 -0700

I know it's been a while since I've tagged you about this problem in general
but we've been kind of busy around here.

I've come up with a test that will cause this problem every time but it
doesn't use any of your demo code it uses a very basic hello world program
(with a shared library) that I wrote as the following (each file is sperated
with a the line '-----------------------------------'):

-----------------------------------
// Hello.h
#include <stdio.h>

class Hello
{
public:
    Hello();
    ~Hello();
    
    void print();
private:
    char *m_Text;
};

-----------------------------------
//Hello.cpp
#include "Hello.h"

Hello::Hello() :
    m_Text("Hello World")
{
}

Hello::~Hello()
{
}

void Hello::print()
{
    printf(m_Text);
}

-----------------------------------
####################
# Makefile.am
####################
####################
# Compiler Flags
####################

INCLUDES                        = -I./ 
LIB_PATH                        = -L./ 
ALL_LIBS                        = 

####################
# Libtool Library
####################

lib_LTLIBRARIES                 = libHello.la

libHello_la_SOURCES             = Hello.cpp

####################
# Executables
####################
bin_PROGRAMS                    = HelloWorld

HelloWorld_SOURCES              = HelloWorld.cpp
HelloWorld_LDADD                = $(LIB_PATH) -lHello $(ALL_LIBS)

HelloWorld_DEPENDENCIES         = ./libHello.la

include_HEADERS                 = Hello.h

####################
#  Distribution
####################

####################
#  Cleanup
####################

DISTCLEANFILES                  = Makefile.in aclocal.m4 config.h.in
CLEANFILES                      = *~ .*~ *.flc

-----------------------------------
####################
#  configure.in
####################

AC_PREREQ(2.57)

AC_INIT(HelloWorld, 1.0)

AM_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE(1.6.3)

AC_PREFIX_DEFAULT(/usr/local)

####################
# Checks for programs.
####################
AC_PROG_CXX
AC_PROG_CC
# This is the offending command that interferes with libtool install
AC_DISABLE_FAST_INSTALL
AC_PROG_LIBTOOL
AC_PROG_INSTALL

####################
# Define Output files
####################

AC_OUTPUT(Makefile)

As far as tracking down the root of the problem I think I have it, the
disable fast install command is being passed down and eventtually causeing
the re-link to fail because no destdir based install locations are checked
within the no fast install conditional block on lines 5728 through 5757 of
the ltmain.in (version 1.5.14). 

After much tracking I've found that by simply inserting a line at the end of
the aforementiond conditional with the following patch to ltmain.in the
problem no longer presists and it does not cause any problems with other
tests.

--- ../orig/libtool-1.5.14/ltmain.in    2005-02-12 05:18:34.000000000 -0700
+++ ltmain.in   2005-04-13 17:33:03.433899056 -0600
@@ -5753,6 +5753,9 @@
              fi
              file="$outputname"
            else
+              if test -n "$objdir"; then
+               file=`$echo "X$file$stripped_ext" | $Xsed -e
"s%\([^/]*\)$%$objdir/\1%"`
+              fi
              $echo "$modename: warning: cannot relink \`$file'" 1>&2
            fi
          else

Note: This is a simple patch and could be made more elegant if the
inst_prefix_dir was set to a usefull value for executable installs.

If you have any suggestions as to how to make this patch more robust I'm
open to suggestions.

Also the test that goes with the attached test code is the following:

#!/bin/sh
# hello-destdir.test - Try installing hello to a DESTDIR (libtool
inst_prefix)

# Test script header.
need_prefix=no
if test -z "$srcdir"; then
  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
  test "$srcdir" = "$0" && srcdir=.
  test "${VERBOSE+set}" != "set" && VERBOSE=yes fi . $srcdir/defs || exit 1

cd ../hello || exit 1

inst_prefix=`pwd`/inst_prefix
my_prefix=/usr/local

if test -d $inst_prefix; then
    echo "= removing old inst_prefix"
    rm -rf $inst_prefix || exit 1
fi

echo "= creating install prefix directory  $inst_prefix"
mkdir -p $inst_prefix
echo "= configuring with prefix $my_prefix"
./configure --prefix=$my_prefix

if test -e "HelloWorld"; then
    echo "= Cleaning up old build with $make clean"
fi

echo "= Running $make in hello"
$make || exit 1

echo "= Running $make DESTDIR=$inst_prefix install in hello"
$make DESTDIR=$inst_prefix install || exit 1

echo "= Executing installed program"
status=0
if $inst_prefix/$my_prefix/bin/HelloWorld | grep 'Hello World'; then :
else
    echo "$0: cannot execute $inst_prefix/$my_prefix/bin/HelloWorld" 1>&2
    status=1
fi

exit $status

Paul Ryan
SAIC - Tactical Systems

-----Original Message-----
From: Ralf Wildenhues [mailto:address@hidden
Sent: Wednesday, March 02, 2005 3:13 AM
To: Ryan, Paul L. 
Cc: address@hidden
Subject: Re: DESTDIR install final relinking issue.

Hi Paul,

[ re-ordered and reformatted ]

* Ryan, Paul L.  wrote on Wed, Mar 02, 2005 at 01:29:44AM CET:
> > 
> > I realize that this destdir issue has been hammered on for quite a 
> > while and I've searched the archives for my particular version of 
> > this issue with no success. While running a make 
> > DESTDIR=/var/tmp/infomanagement-B2C5E4/ install I get the following 
> > warnings and the final install as you can see installs the wrapper 
> > script instead of the actual binary:
> > 
> >   /bin/sh ../../libtool --mode=install /usr/bin/install -c IMMetrics 
> > /var/tmp/infomanagement-B2C5E4/home/ofw/bin/ix86/IMMetrics
> > libtool: install: warning:
> > `/tmp/infomanagement-rpm-build/BUILD/infomanagement-B2C5E4/FFWError/
> > src/
> > libF
> > FWError.la' has not been installed in `/home/ofw/lib/ix86'
*snip*

Alright.  All of the warnings are harmless.

> > libtool: install: warning: cannot relink `IMMetrics'
> > /usr/bin/install -c IMMetrics
> > /var/tmp/infomanagement-B2C5E4/home/ofw/bin/ix86/IMMetrics

OK, bug.

> > This build is being done on an x86 and has been tried with libtool 
> > verions 1.5.6 and 1.5.14 without success in either. Any assistance 
> > on this issue would be greatly apprceated.

It would be really great to have a testcase exposing the problem.
I suppose your software package is quite big -- if it's hard for you to
create a small example yourself, at least provide more info on the relevant
Makefile.am snippets and any other relevant parts (including the commands
you executed to expose this), so we can try to build a testcase.

> As an update I've identified the area within ltmain.sh that causes the 
> problem and below is a patch for 1.5.14 that works for me in fixing 
> this problem. I realize it's probably not generic enough but it does 
> take a DESTDIR into account when present and ignores it all other 
> times. I would definetly like to see something that fixes this in 2.0 
> and if I can give anymore input I will be glad to.

Your patch as-is is not ok.  libtool has -inst-prefix and @inst-prefix@ for
this, and direct use of DESTDIR would definitely need updated documentation
if necessary.  Other than that, a patch against ltmain.in (ltmain.m4sh for
branch-2-0) would be appreciated, but that is a minor detail.

Regards,
Ralf


> --- ltmain.sh.orig    2005-03-01 15:20:59.444761786 -0700
> +++ ltmain.sh 2005-03-01 15:21:02.018584203 -0700
> @@ -5693,6 +5693,7 @@
>         fi
>  
>         finalize=yes
> +          useddestdir=no
>         for lib in $notinst_deplibs; do
>           # Check to see that each library is installed.
>           libdir=
> @@ -5706,10 +5707,20 @@
>           libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ###
> testsuite: skip nested quoting test
>           if test -n "$libdir" && test ! -f "$libfile"; then
>             $echo "$modename: warning: \`$lib' has not been installed in 
> \`$libdir'" 1>&2
> -           finalize=no
> +              if test -n "$DESTDIR$libdir" && test ! -f 
> + "$DESTDIR$libfile";
> then
> +                  $echo "$modname: warning: \`$lib' has not been 
> + installed
> in \`$DESTDIR$libdir'" 1>&2
> +                  finalize=no
> +              else
> +                  useddestdir=yes
> +              fi
>           fi
>         done
>  
> +          if test "$useddestdir" = yes; then
> +              $echo "$modename: info: linking to DESTDIR install" 
> +              $echo "$modename: info: You must put the DESTDIR in 
> + your LD
> path to run \`$file'" 1>&2
> +          fi
> +
>         relink_command=
>         # To insure that "foo" is sourced, and not "foo.exe",
>         # finese the cygwin/MSYS system by explicitly sourcing "foo."
> @@ -5741,16 +5752,20 @@
>             fi
>             file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
>             outputname="$tmpdir/$file"
> +              if test ! "$useddestdir" = yes ; then
>             # Replace the output file specification.
> -           relink_command=`$echo "X$relink_command" | $Xsed -e
> 'address@hidden@%'"$outputname"'%g'`
> -
> -           $show "$relink_command"
> -           if $run eval "$relink_command"; then :
> -           else
> -             $echo "$modename: error: relink \`$file' with the above
> command before installing it" 1>&2
> -             ${rm}r "$tmpdir"
> -             continue
> -           fi
> +                  relink_command=`$echo "X$relink_command" | $Xsed -e
> 'address@hidden@%'"$outputname"'%g'`
> +                  $show "$relink_command"
> +                  if $run eval "$relink_command"; then :
> +                  else
> +                      $echo "$modename: error: relink \`$file' with 
> + the
> above command before installing it" 1>&2
> +                      ${rm}r "$tmpdir"
> +                      continue
> +                  fi
> +              else
> +                  outputname=.libs/$file
> +                  $echo "$modename: warning: cannot relink \`$file'" 1>&2
> +              fi
>             file="$outputname"
>           else
>             $echo "$modename: warning: cannot relink \`$file'" 1>&2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]