Issue 77360

Summary: build (with --dlv_switch -link) breaks in desktop: can´t open dynamic library: /usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib
Product: porting Reporter: lohmaier
Component: MacOSXAssignee: eric.bachard
Status: CLOSED FIXED QA Contact: issues@porting <issues>
Severity: Trivial    
Priority: P4 CC: issues, pavel
Version: 680m206   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X, all   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description lohmaier 2007-05-14 20:50:51 UTC
This is a rather puzzling error, since it isn't really reproducible, but seems
to  happen more often lately.

Full error:
ld: warning can't open dynamic library:
/usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib referenced from:
../../unxmacxp.pro/lib/libdeploymentmisc680mxp.dylib (checking for undefined
symbols may be affected) (No such file or directory, errno = 2)
ld: Undefined symbols:
_db_create referenced from libdeploymentmisc680mxp expected to be defined in
/usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib
_db_env_create referenced from libdeploymentmisc680mxp expected to be defined in
/usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib
_db_strerror referenced from libdeploymentmisc680mxp expected to be defined in
/usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib
/usr/bin/libtool: internal link edit command failed
dmake:  Error code 1, while making
'../../unxmacxp.pro/lib/deployment680mxp.uno.dylib'
---* tg_merge.mk *---

Of course, berkelydb was built already and libdb-4.2.dylib is in the solver.

no trace of /usr/local at all on the mac at all...
Comment 1 lohmaier 2007-05-15 11:41:33 UTC
Weired thing is:

Despite berkeleydb was already built, rebuilding & delivering it again allows
desktop module to build successfully.

e.g. 
cd berkeleydb
rm -rf unxmacxp.pro # without this, nothing is rebuilt or redelivered
build
build --deliver
cd desktop
build

And desktop builds fine.

So whatever it is, I suspect it is a parallel build issue with berkeleydb -
something that has been built in the meantime apparently solves the problem. But
I don't have a clue what would affect this module. Unfortunately a whole lot of
modules were built in between berkeleydb and desktop, so I don't have a clue
what module could be missing.
Comment 2 pavel 2007-05-15 11:44:28 UTC
Please check its' install_name.

Please run otool -L on it.
Comment 3 lohmaier 2007-05-21 15:07:55 UTC
sorry for the delay, but here's the result:

$ otool -L berkeleydb/unxmacxp.pro/lib/libdb-4.2.dylib
solver/680/unxmacxp.pro/lib/libdb-4.2.dylib
berkeleydb/unxmacxp.pro/lib/libdb-4.2.dylib:
        /usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib (compatibility version
0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
88.1.9)
solver/680/unxmacxp.pro/lib/libdb-4.2.dylib:
        /usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib (compatibility version
0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
88.1.9)

So both the in-module version as well as the delivered one contain the hardcoded
path with /usr/local

The compiler/link line from the logs reads like this:

gcc -dynamiclib -flat_namespace -undefined suppress -o .libs/libdb-4.2.dylib 
.libs/mut_tas.o [many other .o files] .libs/xa_map.o  -install_name 
/usr/local/BerkeleyDB.4.2/lib/libdb-4.2.dylib

It uses -install_name with that hardcoded path.

The deliver-line on stdout prints:
LINK: ../unxmacxp.pro/lib/libdb-4.2.dylib ->
/Users/buildslave/compile/shadow/solver/680/unxmacxp.pro/lib/libdb-4.2.dylib

But deliver.log in solver reads
COPY berkeleydb/unxmacxp.pro/lib/libdb-4.2.dylib unxmacxp.pro/lib/libdb-4.2.dylib

(not sure whether that difference is relevant at all, I doubt it)
Comment 4 pavel 2007-05-22 11:28:44 UTC
Here:

Macintosh:~/BUILD/X11/BuildDir/ooo_OOF680_m17_src pavel$ otool -L solver/680/unxmacxi.pro/lib/
libdb-4.2.dylib berkeleydb/unxmacxi.pro/lib/libdb-4.2.dylib 
solver/680/unxmacxi.pro/lib/libdb-4.2.dylib:
        @executable_path/libdb-4.2.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.7)
berkeleydb/unxmacxi.pro/lib/libdb-4.2.dylib:
        @executable_path/libdb-4.2.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.7)
Macintosh:~/BUILD/X11/BuildDir/ooo_OOF680_m17_src pavel$ 

Are you really building m206? maybe it was fixed later...
Comment 5 lohmaier 2007-05-22 12:45:04 UTC
Yes, that was while building jimmactango3 - at the time of building (and I guess
still now) based on m206

But since tinderbox did build all milestones without problem, and that same cws
without problem on other occasion, and since rm -rf'ing berkeleydb's output-dir
and building only that module again "fixes" the problem, I didn't think it
depends on the milestone at all. But one can be so mislead...

But now I think I got the problem:

While building the first time, I used --dlv_switch -link, when rebuilding I
didn't specify it.

It seems that when using link, it sometimes fails. This is not an issue with
newer milestones that already have @executable_path in the -install_name flag
(from m207 on), but when it relies on deliver to clean up.

Thanks for thinking with (for) me - sometimes you just don't see clear when only
talking with yourself.

###################################
Summary:

* building with "--dlv_switch -link" and < m207 breaks
* building without that switch or a milestone >= m207 works fine

Worth to investigate deliver's behaviour further? Or close as worksforme? 
Comment 6 pavel 2007-07-24 11:09:47 UTC
These two facts are incompatible:

1. deliver is changing the install_name of delivered libraries, thus the library in the local output tree is 
different from the library in the solver.

2. using links in deliver.
Comment 7 eric.bachard 2007-10-07 08:00:26 UTC
@cloph

Is the issue fixed, or pending, or ...  ?
Comment 8 lohmaier 2007-10-08 10:41:56 UTC
Well - the question is whether it is worth to fix deliver for that case
(when deliver should rewrite info in the lib) or not. I mean the specific
problem with berkeleydb is fixed by compiling/linking it with the right flags
from the beginning...

So I guess it is "worksforme"
Comment 9 Pedro Giffuni 2011-12-12 21:30:03 UTC
Berkeley DB is not used anymore due to license concerns so it would be surprising to see this error again.
Comment 10 Marcus 2016-04-09 10:35:41 UTC
see comment #9