Bug 506206

Summary: problems linking with -z defs
Product: [Retired] 389 Reporter: Luis Vivero P. <morenisco>
Component: Directory ServerAssignee: Rich Megginson <rmeggins>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: high Docs Contact:
Priority: low    
Version: 1.2.1CC: rmeggins
Target Milestone: ---Keywords: VerifiedUpstream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:51:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 543590    
Attachments:
Description Flags
patch nhosoi: review+

Description Luis Vivero P. 2009-06-16 02:00:54 UTC
Description of problem:

libslapd is not linked with -lrt, which provides the semaphore functions.
From Rich Megginson:
This is usually fine, since ns-slapd (the executable) is linked with -lrt, so that at runtime all of these references are resolved,  But Debian uses -Wl,-z,defs which forces all references to be looked up at link time.  We should fix this in 389 - please file a bug against 389.  In the meantime, you could either turn off -z,defs, or figure out how to link libslapd with -lrt.

Version-Release number of selected component (if applicable): 389-ds-base-1.2.1


How reproducible: Happens every time.


Steps to Reproduce:
1) 389-ds-base-1.2.1 package - Initial debianization:

root@dirserv1:~/project-389/389-ds-base-1.2.1# dh_make -e morenisco -c gpl -f ../389-ds-base-1.2.1.tar.gz

Type of package: single binary, multiple binary, library, kernel module or cdbs?
[s/m/l/k/b] s

Maintainer name : root
Email-Address   : morenisco
Date            : Thu, 04 Jun 2009 22:56:55 +0000
Package Name    : 389-ds-base
Version         : 1.2.1
License         : gpl
Using dpatch    : no
Type of Package : Single
Hit <enter> to confirm:
Done. Please edit the files in the debian/ subdirectory now. 389-ds-base
uses a configure script, so you probably don't have to edit the Makefiles.

2) I modified the control file as follows:

Source: 389-ds-base
Section: admin
Priority: extra
Maintainer: Morenisco <morenisco>
Build-Depends: debhelper (>= 7), autotools-dev
Standards-Version: 3.7.3
Homepage: http://directory.fedoraproject.org

Package: 389-ds-base
Architecture: any
Depends: libsvrcore0, libsvrcore-dev, libmozldap-0d, libmozldap-dev, libmozilla-ldap-perl, libdb4.6-dev, libicu-dev, libsnmp-dev, libkrb5-dev, libpam-dev, libnet-ldap-perl, libperl-dev
Description: The enterprise-class Open Source LDAP server for Linux.
            It is hardened by real-world use, is full-featured, supports
            multi-master replication, and already handles many of the largest
            LDAP deployments in the world.


3) I tried to build the package with the following command:

root@dirserv1:~/project-389/389-ds-base-1.2.1# dpkg-buildpackage -rfakeroot

The generated output is too long, and the latest part is the following:

ldap/servers/slapd/.libs/libslapd_la-snmp_collator.o: In function `snmp_collator_create_semaphore':
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:532: undefined reference to `sem_open'
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:536: undefined reference to `sem_unlink'
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:542: undefined reference to `sem_open'
ldap/servers/slapd/.libs/libslapd_la-snmp_collator.o: In function `snmp_collator_sem_wait':
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:574: undefined reference to `sem_trywait'
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:586: undefined reference to `sem_close'
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:587: undefined reference to `sem_unlink'
ldap/servers/slapd/.libs/libslapd_la-snmp_collator.o: In function `snmp_collator_update':
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:629: undefined reference to `sem_post'
ldap/servers/slapd/.libs/libslapd_la-snmp_collator.o: In function `snmp_collator_stop':
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:505: undefined reference to `sem_close'
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:506: undefined reference to `sem_unlink'
ldap/servers/slapd/.libs/libslapd_la-snmp_collator.o: In function `snmp_collator_init':
/root/project-389/389-ds-base-1.2.1/ldap/servers/slapd/snmp_collator.c:205: undefined reference to `sem_post'
collect2: ld returned 1 exit status
make[2]: *** [libslapd.la] Error 1
make[2]: Leaving directory `/root/project-389/389-ds-base-1.2.1'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/root/project-389/389-ds-base-1.2.1'
make: *** [build-stamp] Error 2
dpkg-buildpackage: failure: debian/rules build gave error exit status 2
root@dirserv1:~/project-389/389-ds-base-1.2.1# 
  
Actual results: Cannot compile the 389-ds-base-1.2.1 package on Debian.


Expected results: Be able to compile the 389-ds-base-1.2.1 package on Debian.


Additional info:

The complete output is in the following URL:

http://morenisco.noc-root.net/debian/files/Error_Debianizing_389-ds-base-1.2.1

Comment 1 Rich Megginson 2009-06-16 15:06:13 UTC
I think this same thing causes problems with Fedora pre-linking - there may be other libraries that we need to add

Comment 2 Rich Megginson 2010-02-25 03:36:10 UTC
Are you sure it is -lrt that is needed?  On my RHEL5 x86_64 system, the sem_* functions are provided by libpthread:

ll /usr/lib64/librt.so 
lrwxrwxrwx 1 root root 22 Sep 29 20:01 /usr/lib64/librt.so -> ../../lib64/librt.so.1*
readelf -s /lib64/librt.so.1 |grep sem
# nothing

ll /lib64/libpthread.so.0 
lrwxrwxrwx 1 root root 17 Sep 29 19:55 /lib64/libpthread.so.0 -> libpthread-2.5.so*
readelf -s /lib64/libpthread-2.5.so |grep sem
    80: 0000003bac20cb50    57 FUNC    GLOBAL DEFAULT   12 sem_post@@GLIBC_2.2.5
    88: 0000003bac20ca10    36 FUNC    GLOBAL DEFAULT   12 sem_trywait@@GLIBC_2.2.5
....
   907: 0000003bac20ca10    36 FUNC    GLOBAL DEFAULT   12 sem_trywait
   917: 0000003bac20c180   925 FUNC    GLOBAL DEFAULT   12 sem_open
   944: 0000003bac20c970   139 FUNC    GLOBAL DEFAULT   12 sem_wait


So instead of needed -lrt, I think -lpthread is needed.

Comment 3 Rich Megginson 2010-02-25 15:46:59 UTC
Created attachment 396306 [details]
patch

Comment 4 Rich Megginson 2010-02-25 17:15:20 UTC
pushed to master

commit 2cc5ac4e6de01c75d3b974146fde7f41a77b0268
Author: Rich Megginson <rmeggins>
Date:   Thu Feb 25 08:46:32 2010 -0700

    Reviewed by: nhosoi (Thanks!)
    Branch: HEAD
    Fix Description: Some platforms (debian) and some build checking tools
    (rpmlint, others) link with -z defs to look for any undefined references at
    link time.  We had several of these in various directory server objects.
    1) all of the plugins need to link against libslapd.la
    2) most of the plugins need to link against ldapcsdk and nspr
    3) the pwdstorage plugin needs to link against LIBCRYPT, which is platform
    dependent
    4) various other link fixes
    Platforms tested: RHEL5 x86_64
    Flag Day: yes - autotool file changes
    Doc impact: no

Comment 6 Red Hat Bugzilla 2023-09-14 01:16:54 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days