Bug 10885 - Need to set install_name
Summary: Need to set install_name
Status: ASSIGNED
Alias: None
Product: TDB
Classification: Unclassified
Component: libtdb (show other bugs)
Version: unspecified
Hardware: All Mac OS X
: P5 normal
Target Milestone: ---
Assignee: Ralph Böhme
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks: 9665 10626 10791 7000 11056
  Show dependency treegraph
 
Reported: 2014-10-19 03:20 UTC by samba
Modified: 2015-10-28 12:40 UTC (History)
2 users (show)

See Also:


Attachments
Experimental patch for master (1.22 KB, patch)
2014-10-20 09:17 UTC, Stefan Metzmacher
slow: review-
Details

Note You need to log in before you can comment on or make changes to this bug.
Description samba 2014-10-19 03:20:00 UTC
Hello, I'm a developer with the MacPorts package management system. We've been asked to update our tdb package to version 1.3.1, and in the process of doing so, I've encountered some problem with your build process.

tdb 1.3.1 builds its libtdb library without specifying the required "-install_name ..." flag. This results in programs that link with the library not being able to find the library after the build directory is removed.

I am not familiar with the waf build system you use so I cannot suggest how to solve this in your build system, I can only tell you that you must add this flag.

For example, if the library will ultimately be installed as /opt/local/lib/libtdb.1.dylib, then when building, in addition to the "-dynamiclib" flag that you already use, you must pass the flag "-install_name /opt/local/lib/libtdb.1.dylib".
Comment 1 Stefan Metzmacher 2014-10-20 09:17:11 UTC
Created attachment 10357 [details]
Experimental patch for master

Can someone test this patch?
Comment 2 Ralph Böhme 2014-10-20 11:36:27 UTC
I'll give it a whirl. We ran into the very same issue when trying to build Samba 4.1.12 with Macports, cf bug #10877.
Comment 3 Ralph Böhme 2014-10-24 08:56:26 UTC
Comment on attachment 10357 [details]
Experimental patch for master

Looks like ordering of the linkflags -install_name and -dynamiclib is important: if -install_name is used if must come *after* -dynamiclib, otherwise the linker gives an error

I had to modify the patch to read
+        t.env.append_value('LINKFLAGS', '-dynamiclib -install_name')
in order to pass at this point.

Unfortunately it then fails at another point, cf my next post.
Comment 4 Ralph Böhme 2014-10-24 09:01:28 UTC
This is the error I see when applying the patch to the Samba 4.1.12 port I'm currently working on, assisting another Macports contributor in getting it to work.

[   5/4011] Linking default/lib/replace/libreplace.inst.dylib
10:51:17 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib
clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib'

Afaict the install_name mustn't be set to the absolute path of the library, instead the leading path component that matches the passed rpath must be replaced by the literal string @rpath@, this would work:

/usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name @rpath@/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib

Anyone with sufficient python and waf skills able to come up with a patch that does this?
Comment 5 samba 2014-10-24 09:10:19 UTC
I have only ever set "-install_name" to the absolute path the library will ultimately be installed into. I am not familiar with "-rpath" or "@rpath@". I do notice that "-dynamiclib" is being specified twice, which is at best redundant, and possibly problematic, I don't know.
Comment 6 Ralph Böhme 2014-10-24 09:41:49 UTC
(In reply to samba from comment #5)

urks, your're right, looks like -install_name is supposed to work with absolute paths. I've done another attempt running the link command by hand and it works, alas the sambe command when executed from make fails:

This is the error from Macports:

# port -v install samba4
...
[   5/4011] Linking default/lib/replace/libreplace.inst.dylib
11:31:51 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib
clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib'
Waf: Leaving directory `/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin'
...
#

Lets run the build with make by hand:

# cd "/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12"
# /usr/bin/make -w install DESTDIR=/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/destroot 
...
[   5/4011] Linking default/lib/replace/libreplace.inst.dylib
11:33:07 runner /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib
clang: error: no such file or directory: '/opt/local/lib/private/libreplace.dylib'
Waf: Leaving directory `/opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin'
#

Now lets take the actual clang command and run that by hand:
# cd /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin
# /usr/bin/clang default/lib/replace/replace_2.o default/lib/replace/strptime_2.o default/lib/replace/xattr_2.o -o /opt/local/var/macports/build/_Users_ralph_ports_net_samba4/samba4/work/samba-4.1.12/bin/default/lib/replace/libreplace.inst.dylib -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -dynamiclib -install_name /opt/local/lib/private/libreplace.dylib -fstack-protector -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/opt/local/lib -L/usr/local/lib
# echo $?
0
#

I'm at my wits end for the moment, sorry.