[SERVER-5254] dependency order of libraries is causing unnecessary relinking Created: 08/Mar/12  Updated: 11/Jul/16  Resolved: 30/Mar/12

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 2.1.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Andy Schwerin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

If you look at "scons --debug=explain", it shows the ordering of the libraries is not consistent across invocations:

old: ['build/linux2/normal/mongo/db/db.o', 'build/linux2/normal/mongo/db/compact.o', '/usr/bin/g++', '/usr/lib64/libm.so', '/usr/lib64/libpthread.so', 'build/linux2/normal/third_party/murmurhash3/libmurmurhash3.a', 'build/linux2/normal/mongo/libmongocommon.a', 'build/linux2/normal/third_party/libpcrecpp.a', 'build/linux2/normal/third_party/libmongo_boost.a', 'build/linux2/normal/mongo/libcoredb.a', 'build/linux2/normal/mongo/libdbcmdline.a', 'build/linux2/normal/mongo/libcoreshard.a', 'build/linux2/normal/mongo/libdefaultversion.a', 'build/linux2/normal/mongo/libserveronly.a', 'build/linux2/normal/mongo/libcoreserver.a', 'build/linux2/normal/third_party/pcre-8.30/libpcrecpp.a', 'build/linux2/normal/third_party/boost/libboost_system.a', 'build/linux2/normal/third_party/boost/libboost_thread.a', 'build/linux2/normal/third_party/boost/libboost_filesystem.a', 'build/linux2/normal/third_party/boost/libboost_program_options.a']
new: ['build/linux2/normal/mongo/db/db.o', 'build/linux2/normal/mongo/db/compact.o', '/usr/bin/g++', '/usr/lib64/libm.so', '/usr/lib64/libpthread.so', 'build/linux2/normal/mongo/libmongocommon.a', 'build/linux2/normal/third_party/libpcrecpp.a', 'build/linux2/normal/third_party/murmurhash3/libmurmurhash3.a', 'build/linux2/normal/mongo/libcoredb.a', 'build/linux2/normal/third_party/libmongo_boost.a', 'build/linux2/normal/mongo/libdbcmdline.a', 'build/linux2/normal/mongo/libcoreshard.a', 'build/linux2/normal/mongo/libdefaultversion.a', 'build/linux2/normal/mongo/libserveronly.a', 'build/linux2/normal/mongo/libcoreserver.a', 'build/linux2/normal/third_party/pcre-8.30/libpcrecpp.a', 'build/linux2/normal/third_party/boost/libboost_system.a', 'build/linux2/normal/third_party/boost/libboost_thread.a', 'build/linux2/normal/third_party/boost/libboost_filesystem.a', 'build/linux2/normal/third_party/boost/libboost_program_options.a']



 Comments   
Comment by auto [ 12/Sep/12 ]

Author:

{u'date': u'2012-09-07T10:16:24-07:00', u'email': u'Andy Schwerin schwerin@10gen.com', u'name': u'Andrew Schwerin'}

Message: SERVER-6960 Always link object files and static archives in the same order.

SCons (correctly) considers two link command lines different if the order of
object files or static libraries changes. As a result, the libdeps system needs
to produce consistent ordering of these files in the $_LIBDEPS expansion. This
patch achieves this by sorting the _LIBDEPS candidate expansion by the string
name of the expanded objects.

This problem is akin to that from SERVER-5254, which was solved in a similar
manner.
Branch: v2.2
https://github.com/mongodb/mongo/commit/bebd9195c40c4b61b1858061e4e0709c1f4121ae

Comment by auto [ 07/Sep/12 ]

Author:

{u'date': u'2012-09-07T10:16:24-07:00', u'name': u'Andrew Schwerin', u'email': u'Andy Schwerin schwerin@10gen.com'}

Message: SERVER-6960 Always link object files and static archives in the same order.

SCons (correctly) considers two link command lines different if the order of
object files or static libraries changes. As a result, the libdeps system needs
to produce consistent ordering of these files in the $_LIBDEPS expansion. This
patch achieves this by sorting the _LIBDEPS candidate expansion by the string
name of the expanded objects.

This problem is akin to that from SERVER-5254, which was solved in a similar
manner.
Branch: master
https://github.com/mongodb/mongo/commit/645aa497732e829fd43092f02102ac37cc3a8b08

Comment by Eric Milkie [ 02/Apr/12 ]

This is amazing – the "tool" suite now takes 5 minutes, 41 seconds on Windows with this fix in action (it was taking > 56 minutes before).

Comment by auto [ 30/Mar/12 ]

Author:

{u'login': u'andy10gen', u'email': u'schwerin@10gen.com', u'name': u'Andy Schwerin'}

Message: SERVER-5254: Make LIBDEPS dependency order stable across SCons invocations.

Turns out that SCons.Node objects are compared on object identity (pointer),
not some value that's stable across invocations of SCons. We now sort by
the "name" of the node (its string representation), instead, which stops
spurious builds.
Branch: master
https://github.com/mongodb/mongo/commit/5455f1d95c232c92647e3e0cfda4f52b28a08ef7

Comment by Eric Milkie [ 30/Mar/12 ]

Note that this is severely affecting our build times. For example, the Windows 64 bit builder takes 56 minutes to complete the "tool" test suite, even though it only spends 6 minutes actually running tests. The remainder of the time is wasted by superfluous invocations of the linker.

Comment by Eric Milkie [ 09/Mar/12 ]

Confirmed, they are different – the order of .o files.

Comment by Andy Schwerin [ 09/Mar/12 ]

I'm not going to get to this until sometime next week, at the earliest. If you have a chance, verify that the command lines for the links are also different?

Comment by Eric Milkie [ 09/Mar/12 ]

There was a discussion of this recently, which ended in someone filing a bug with scons:
http://scons.tigris.org/ds/viewMessage.do?dsForumId=1268&dsMessageId=2850490

"Dependency order problem, rebuilds due to incorrect implicit dependencies"
http://scons.tigris.org/issues/show_bug.cgi?id=2811

Not sure that we'll be able to work around this. It's unfortunate because our link times on Windows are exceptionally long.

Generated at Thu Feb 08 03:08:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.