Bug 508 - AC_CHECK_LIB_EXT adds libraries in reverse order
Summary: AC_CHECK_LIB_EXT adds libraries in reverse order
Status: CLOSED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.0
Hardware: All Solaris
: P3 normal
Target Milestone: none
Assignee: Tim Potter
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-25 07:30 UTC by Svein Olav Bjerkeset
Modified: 2005-11-14 09:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Svein Olav Bjerkeset 2003-09-25 07:30:58 UTC
When configuring samba-3.0.0 with kerberos, ldap and ads support on Solaris8, 
the ldap libraries (libldap and liblber) gets added in the wrong order. 
LDAP_LIBS gets the value "-llber -lldap" instead of "-lldap -llber". libldap
is dependent upon liblber and should be the first (leftmost) library of the two 
on the commandline.

It seems that AC_CHECK_LIB_EXT (in aclocal.m4) does not prepend libraries, but
rather adds them at the end. The AC_CHECK_LIB standard autoconf macro prepends 
libraries - shouldn't AC_CHECK_LIB_EXT do the same or have I missed something?

Here is a patch that fixes the problem.

diff -urN samba-3.0.0.orig/source/aclocal.m4 samba-3.0.0/source/aclocal.m4
--- samba-3.0.0.orig/source/aclocal.m4  2003-08-28 23:42:42.000000000 +0200
+++ samba-3.0.0/source/aclocal.m4       2003-09-25 16:09:20.000000000 +0200
@@ -179,7 +179,7 @@
                    *-l$1*)
                        ;;
                    *)
-                       $2="$$2 -l$1"
+                       $2="-l$1 $$2"
                        ;;
                esac])
                [$6]
Comment 1 Tim Potter 2003-09-25 18:45:07 UTC
Metze, what do you think of this?
Comment 2 Stefan Metzmacher 2003-09-26 03:12:54 UTC
I think "-llber -lldap" is the right order.
Because libldap uses liblber...

and it was like that before.

Please donot apply this patch.

when this is a problem, I'll think about it a bit more.

Comment 3 Svein Olav Bjerkeset 2003-09-26 04:46:33 UTC
From the manual page for gcc (version 3.2.1)

    -llibrary
    -l library
    
         It makes a difference where in the command you write
         this option; the linker searches and processes libraries
         and object files in the order they are specified.  Thus,
         foo.o -lz bar.o searches library z after file foo.o but
         before bar.o.  If bar.o refers to functions in z, those
         functions may not be loaded.

In other words, given the linker option "-llber -lldap", because libldap.a
references liblber.a, the link will fail, according to the last line cut from
the gcc manual page.

Anyway: On Solaris 8 with OpenLDAP compiled with static libraries, the Samba 
3.0.0 source does not link without this patch. Also I would like to know why
AC_CHECK_LIB_EXT should add libraries in the reverse order of AC_CHECK_LIB.
Comment 4 Tim Potter 2003-09-26 18:17:01 UTC
My gut feeling here is that the new macro should apply libraries to the list in
the same order as the old one.
Comment 5 Svein Olav Bjerkeset 2003-09-27 07:33:03 UTC
Yes, and that is what this patch is all about. It also makes the ordering
of libraries consistant with the way gcc (and other compiler I would imagine)
works.
Comment 6 Stefan Metzmacher 2003-09-28 01:57:31 UTC
ok, apply it... I hope it will work with all kerberos lib...
but 3.0.0 is out and if this break something we can fix that latter.
Comment 7 Tim Potter 2003-09-28 03:37:14 UTC
I will apply the patch and see if it can last a few rounds in the build farm.
Comment 8 Tim Potter 2003-09-29 21:17:35 UTC
No problems seen on the build farm or user reports so I'm closing this bug as fixed.
Comment 9 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:16:56 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.
Comment 10 Gerald (Jerry) Carter (dead mail address) 2005-11-14 09:26:37 UTC
database cleanup