When using the waf buildsystem, dynamic linking incorrectly uses paths from the build path rather than from the install prefix. As a result, none of the samba binaries can find their libraries and they will fail to work post-make install.
I tested this on samba 4.0.3 using Mac OS X 10.6.8, and I can also reproduce on samba 4.0.0. To build, I used the following steps:
While I specified an install prefix, the same thing happens if no prefix is specified to ./configure.
I've attached, as an example, the `otool -L` output for the `samba` binary from 4.0.0.
Created attachment 8554 [details]
otool -L output for `samba` binary
Taking a look at the verbose build output, it looks like the problem is that the linking isn't specifying an installname. According to Apple's ld manpage:
Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will record that path as the way dyld should locate this library. If this option is not specified, then the -o path will be used. This option is also called -dylib_install_name for compatibility.
The waf buildscript is a) not specifying an installname, and b) calling -o with the full path to the library in its temporary location. For example:
11:16:12 runner cc default/lib/async_req/async_sock_1.o default/libcli/smb/read_smb_1.o -o /tmp/samba-RX4S/samba-4.0.6/bin/default/libcli/smb/libsmb_transport.dylib -framework CoreFoundation -lpthread -dynamiclib -Wl,-rpath,/tmp/samba-RX4S/samba-4.0.6/bin/shared -Wl,-rpath,/tmp/samba-RX4S/samba-4.0.6/bin/shared/private -Ldefault/lib/replace -Ldefault/lib/tevent -Ldefault/lib/talloc -Ldefault/libcli/util -Ldefault/lib/util -L/usr/local/lib -lsamba-util -lerrors -ltalloc -ltevent-util -ltevent -lutil_setid -lreplace -liconv
As a result, this lib records "/tmp/samba-RX4S/samba-4.0.6/bin/default/libcli/smb/libsmb_transport.dylib" as its installname instead of "$PREFIX/lib/private/libsmp_transport.dylib" or "libsmp_transport.dylib", and any other libraries linking against it will pick up that name. For example, the `otool -L` output of samab shows it links against libsmp_transport in this way:
/tmp/samba-RX4S/samba-4.0.6/bin/default/libcli/smb/libsmb_transport.dylib (compatibility version 0.0.0, current version 0.0.0)
I also notice that ld is being called with -rpath from the temporary build directory, not the install prefix.
This bug is still here.
I can compile Samba 4.1.16 on OSX 10.9.5 but dynamic linking stuck on "build path".
What file must be patch to install on OSX?
*** Bug 11056 has been marked as a duplicate of this bug. ***
If it helps, here is a bit of an explanation of how the waf build works:
- We build and link one during 'make', and then re-link to the final system location in 'make install'
- an is_install flag is used to change some build options between BUILD and INSTALL modes
Patches are welcome (I don't have modern mac), it should probably be to the code in buildtools/wafsamba, probably buildtools/wafsamba/samba_install.py