You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discovered in #15460, a particular #[link(kind = "static", ...)] line is not
actually guaranteed to link the library at all. The reason for this is that if
the external library doesn't have any referenced symbols in the object generated
by rustc, the entire library is dropped by the linker.
For dynamic native libraries, this is solved by passing -lfoo for all downstream
compilations unconditionally. For static libraries in rlibs this is solved
because the entire archive is bundled in the rlib. The only situation in which
this was a problem was when a static native library was linked to a rust dynamic
library.
This commit brings the behavior of dylibs in line with rlibs by passing the
--whole-archive flag to the linker when linking native libraries. On OSX, this
uses the -force_load flag. This flag ensures that the entire archive is
considered candidate for being linked into the final dynamic library.
This is a breaking change because if any static library is included twice in the
same compilation unit then the linker will start emitting errors about duplicate
definitions now. The fix for this would involve only statically linking to a
library once.
Closes#15460
[breaking-change]
9 commit comments
bors commentedon Aug 4, 2014
saw approval from brson
at alexcrichton@1ae1461
bors commentedon Aug 4, 2014
merging alexcrichton/rust/issue-15460 = 1ae1461 into auto
bors commentedon Aug 4, 2014
alexcrichton/rust/issue-15460 = 1ae1461 merged ok, testing candidate = 17ff116f
bors commentedon Aug 4, 2014
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/682
bors commentedon Aug 4, 2014
saw approval from brson
at alexcrichton@1ae1461
bors commentedon Aug 4, 2014
merging alexcrichton/rust/issue-15460 = 1ae1461 into auto
bors commentedon Aug 4, 2014
alexcrichton/rust/issue-15460 = 1ae1461 merged ok, testing candidate = 463d668
bors commentedon Aug 4, 2014
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/681
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/681
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/680
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/681
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/678
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/679
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/678
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/684
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/679
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/678
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/681
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/679
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/679
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/680
bors commentedon Aug 4, 2014
fast-forwarding master to auto = 463d668