[Top][All Lists]

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

Re: new module lib-ignore; new section build_lib in MODULES.html

From: Paul Eggert
Subject: Re: new module lib-ignore; new section build_lib in MODULES.html
Date: Tue, 17 Jan 2006 21:07:50 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> If you use the new 'ldd' module, it
>   - should work also when cross-compiling,
>   - should be immune to changed addresses in the output of 'chatr',
>     'dump -H', 'elfdump -Dl', 'ldd', 'odump -Dl',
>   - simply feels safer to use the appropriate command for each system,
>     rather than trying "chatr" or "odump" on every system.

Thanks.  I looked into doing this, and ran into some problems.
LDDPOSTPROC is set in such a way that configure needs to employ 'eval'
to use it, and then I ran into porting problems when using things like
'eval "$LDDPROG ... $LDDPOSTPROC"' since LDDPROG began "LC_ALL=C ..."
and this didn't work in some (buggy?) shells.  Also, I wasn't sure
about the need for build-aux/ldd.sh.in; this file seems to be
something that (say) binutils might want to use, but apps wouldn't
need it if all they wanted was gl_LDD.

Stepping back from things a bit, I discovered a way to simplify
lib-ignore so that it no longer needs to use ldd.  Instead, it merely
uses the '-z ignore' option if this works.  That should be enough in
practice.  This way, we don't need to worry about ldd portability.
And perhaps the ldd module itself isn't necessary any more, at least
for now.

I installed the following into both gnulib and coreutils.  This fixes
another porting problem, which I noticed when using Sun's C compiler.

2006-01-16  Paul Eggert  <address@hidden>

        * m4/lib-ignore.m4 (gl_IGNORE_UNUSED_LIBRARIES): Don't use ldd, as
        it's not portable and it doesn't work with cross-compiles.
        Problem reported by Bruno Haible.  Fix missing-$ typo in
        'test "gl_cv_ignore_unused_libraries" ...' that prevented
        -zignore from being used with Sun's C compiler.

--- m4/lib-ignore.m4    7 Jan 2006 01:55:27 -0000       1.1
+++ m4/lib-ignore.m4    17 Jan 2006 07:21:48 -0000      1.2
@@ -12,31 +12,22 @@ AC_DEFUN([gl_IGNORE_UNUSED_LIBRARIES],
   AC_CACHE_CHECK([for flag to ignore unused libraries],
-       [gl_ldd_output0=`(ldd conftest$ac_exeext) 2>/dev/null` ||
-         gl_ldd_output0=])
-     if test "$gl_ldd_output0"; then
-       gl_saved_ldflags=$LDFLAGS
-       gl_saved_libs=$LIBS
-       LIBS="$LIBS -lm"
+     gl_saved_ldflags=$LDFLAGS
+     # Use long option sequences like '-z ignore' to test for the feature,
+     # to forestall problems with linkers that have -z, -i, -g, -n, etc. flags.
+     for gl_flags in '-Xlinker -z -Xlinker ignore' '-z ignore'; do
+       LDFLAGS="$gl_flags $LDFLAGS"
-        [gl_ldd_output1=`(ldd conftest$ac_exeext) 2>/dev/null` ||
-           gl_ldd_output1=])
-       if test "$gl_ldd_output1" && test "$gl_ldd_output0" != "$gl_ldd_output1"
-       then
-        for gl_flags in '-Xlinker -zignore' '-zignore'; do
-          LDFLAGS="$gl_flags $LDFLAGS"
-            [if gl_ldd_output2=`(ldd conftest$ac_exeext) 2>/dev/null` &&
-                test "$gl_ldd_output0" = "$gl_ldd_output2"; then
-               gl_cv_ignore_unused_libraries=$gl_flags
-             fi])
-          LDFLAGS=$gl_saved_ldflags
-          test "gl_cv_ignore_unused_libraries" != none && break
-        done
-       fi
-       LIBS=$gl_saved_LIBS
-     fi])
+        [case $gl_flags in
+           '-Xlinker -z -Xlinker ignore')
+             # Shorten this ugly thing, for prettier 'make' output.
+              gl_cv_ignore_unused_libraries='-Xlinker -zignore';;
+           *)
+             gl_cv_ignore_unused_libraries=$gl_flags;;
+          esac])
+       LDFLAGS=$gl_saved_ldflags
+       test "$gl_cv_ignore_unused_libraries" != none && break
+     done])
   test "$gl_cv_ignore_unused_libraries" != none &&
     LDFLAGS="$LDFLAGS $gl_cv_ignore_unused_libraries"

reply via email to

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