Subject: "hardcode_directy=yes" on OpenBSD causes build DBus failure

From: Chengwei Yang <[email-masked]>
Date: Thu, 26 Sep 2013 15:22:32 +0800

Hi List,

When I was trying to build dbus (http://cgit.freedesktop.org/dbus/dbus/)
master branch on OpenBSD 5.3, with GNU libtool 2.4.2 installed, I got
below failure. (https://bugs.freedesktop.org/show_bug.cgi?id=69801)

------------------------>8---------------->8--------------------------
gcc -DHAVE_CONFIG_H -I. -I..  -I..  -I/usr/X11R6/include
-DDBUS_COMPILATION
-DDBUS_MACHINE_UUID_FILE=\""/usr/local/var/lib/dbus/machine-id"\"
-Wall -Wextra -Wchar-subscripts -Wmissing-declarations
-Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align
-Wno-address -Wfloat-equal -Wdeclaration-after-statement
-Wno-missing-field-initializers -Wno-unused-parameter -Wno-sign-compare
-Wno-pointer-sign -fno-common -fno-strict-aliasing -I/usr/local/include
-MT dbus-run-session.o -MD -MP -MF .deps/dbus-run-session.Tpo -c -o
dbus-run-session.o dbus-run-session.c
mv -f .deps/dbus-run-session.Tpo .deps/dbus-run-session.Po
/bin/sh ../libtool  --tag=CC   --mode=link gcc  -Wall -Wextra
-Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes
-Wnested-externs -Wpointer-arith -Wcast-align -Wno-address -Wfloat-equal
-Wdeclaration-after-statement -Wno-missing-field-initializers
-Wno-unused-parameter -Wno-sign-compare -Wno-pointer-sign -fno-common
-fno-strict-aliasing -I/usr/local/include -export-dynamic
-L/usr/local/lib -o dbus-run-session dbus-run-session.o
../dbus/libdbus-1.la  
libtool: link: gcc -Wall -Wextra -Wchar-subscripts
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wcast-align -Wno-address -Wfloat-equal
-Wdeclaration-after-statement -Wno-missing-field-initializers
-Wno-unused-parameter -Wno-sign-compare -Wno-pointer-sign -fno-common
-fno-strict-aliasing -I/usr/local/include -o .libs/dbus-run-session
dbus-run-session.o -Wl,-E  -L/usr/local/lib -L../dbus/.libs -ldbus-1
-lpthread -Wl,-rpath,/usr/local/lib
/usr/local/lib/libdbus-1.so.10.2: warning: vsprintf() is often misused,
please use vsnprintf()
dbus-run-session.o(.text+0x1eb): In function `exec_dbus_daemon':
: warning: sprintf() is often misused, please use snprintf()
dbus-run-session.o(.text+0x9f5): In function `main':
: undefined reference to `dbus_setenv'
dbus-run-session.o(.text+0xa0a): In function `main':
: undefined reference to `dbus_setenv'
dbus-run-session.o(.text+0xa1f): In function `main':
: undefined reference to `dbus_setenv'
dbus-run-session.o(.text+0xa34): In function `main':
: undefined reference to `dbus_setenv'
dbus-run-session.o(.text+0xa49): In function `main':
: undefined reference to `dbus_setenv'
collect2: ld returned 1 exit status
gmake[2]: *** [dbus-run-session] Error 1
gmake[2]: Leaving directory `/home/chengwei/Upstream/dbus.git/tools'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/chengwei/Upstream/dbus.git'
gmake: *** [all] Error 2
------------------------->8--------------->8----------------------

>From the above log, it says libtool was trying to link
/usr/local/lib/libdbus-1.so.10.2 rather than the one in local build
directory.

Since all the non-built-in libs installed with prefix /usr/local, so I
configured dbus with "CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib", so that all the required headers/libs can
pass check when doing configure.

After did some investigations, I found that it's hardcod_direct=yes
cause the build failure and try to link to the old installed library
which hasn't the new introduced symbol.

$ sed -ne '5467,+4p' m4/libtool.m4
    openbsd* | bitrig*)
      if test -f /usr/libexec/ld.so; then
        _LT_TAGVAR(hardcode_direct, $1)=yes
   	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes

Do you consider this is a bug?

--
Thanks,
Chengwei