-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linking an rlib with a dylib may not actually link the rlib #14344
Labels
A-linkage
Area: linking into static, shared libraries and binaries
Comments
Updated with a real description. |
1 task
bors-servo
pushed a commit
to servo/servo
that referenced
this issue
Oct 9, 2014
This includes the previously-reviewed commits from #3533, plus additional fixes for test failures, and a workaround for CEF link errors on Mac (related to rust-lang/rust#14344). Opening a new PR because this required a fairly invasive rebase, and the original was polluted by a bunch of test commits. r? @larsbergstrom
bors-servo
pushed a commit
to servo/servo
that referenced
this issue
Oct 10, 2014
This includes the previously-reviewed commits from #3533, plus additional fixes for test failures, and a workaround for CEF link errors on Mac (related to rust-lang/rust#14344). Opening a new PR because this required a fairly invasive rebase, and the original was polluted by a bunch of test commits. r? @larsbergstrom
alexcrichton
added a commit
to rust-lang/git2-rs
that referenced
this issue
Nov 7, 2014
alexcrichton
added a commit
to alexcrichton/ssh2-rs
that referenced
this issue
Nov 7, 2014
klutzy
added a commit
to klutzy/rust
that referenced
this issue
Nov 21, 2014
If archives are passed to linker, linker does not add all object files but instead scans each object in archive then adds it only if it defines some symbols which has been undefined. It is problematic when rlib needs to be contained in dylib, since some portion of rlib is stripped out if unused by dylib itself. This patch uses `--whole-archive` flag which changes linker behavior that the linker just adds all objects in archive. Unfortunately, ld does not accept rlib as-is because it contains non-object files, so they are manually removed before passed to ld. Also, this change can be problematic if several archives actually contain same symbol. For example, this patch breaks code like: ```Rust #![crate_type = "rlib"] // `libcfoo.a` contains `foo`. #![link(name = "cfoo", kind = "static")] extern {} // `foo` is also defined here! #[no_mangle] pub fn foo() {} // so this rlib archive has two `foo` symbols. ``` Previously it worked because linker stripped out `cfoo`. Fixes rust-lang#14344
This was referenced Jul 2, 2015
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 20, 2023
Add storage dead for let bindings without initializer fix rust-lang#14344
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When linking an rlib to a dylib, it must be required that the object file for the rlib is included in the dylib. Linkers will optimize away the object file if the dylib doesn't actually use any symbols from the rlib.
Downstream consumers of the rlib (using the rlib through the dylib) may want the symbols, ending up with linker errors.
Basically, we need to tell linkers to force inclusion of all objects from an rlib into a dylib. I think this also applies to native objects inside of an rlib.
The text was updated successfully, but these errors were encountered: