-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Cannot link to --crate-type staticlib as -whole-archive #58277
Comments
This is probably expected. The two different archives contain two definitions of the same compiler-provided function and both compilers are right in including that. |
I ran into the same issue when using nightly (downgrading to stable fixed it). |
I am running into the same problem and my current workaround is to remove
@nagisa I don't understand what you mean with two different compilers. What other compiler than rustc do you mean? The problem seems to me that rustc puts two versions of |
Building librsvg with Rust 1.34.0 fails due to rust-lang/rust#58277.
It look like this is fixed with rust-lang/compiler-builtins@752e35a which is available within Rust 1.36.0 (#60841). Note that the above mentioned workaround only needs to be applied to Rust 1.35.0 and 1.34.0, otherwise it will cause linker errors. See for example: |
e310e36 solved static linking and the MinGW-w64 builds but included a workaround for Rust 1.34 and 1.35 that didn't work for Rust 1.36. The main problem with Rust 1.34 and 1.35 is that it included its own version of the `__clzsi2` intrinsic instead of the C version. This caused duplicate symbols during linking and required a workaround by removing the duplicated symbol, see: rust-lang/rust#58277 Fortunately, this is solved within rustc 1.36, see: rust-lang/compiler-builtins@752e35a The workaround, however, did not ensure that `__clzsi2` intrinsic is only removed when it is duplicated (it could also remove the optimized C version). This commit ensures that the `__clzsi2` intrinsic is present only once. Note that the entire workaround can be removed when the minimum Rust version is bumped to 1.36. Closes: https://gitlab.gnome.org/GNOME/librsvg/issues/485
I have submitted an RFC about supporting whole archive - rust-lang/rfcs#2951. |
Closing this issue, the |
Background: I was trying to integrate
libfoo.a
(compiled ascrate-type = "staticlib"
) as a static depencency oflibbar.so
library (written in C++). Turned out thatbazel
was passing-whole-archive libfoo.a
to the linker, which caused problems:Steps to reproduce
This is a slightly different scenario, but produces the same error:
Fails with (both with
ld
andld.gold
):Failing version
Last working versions
This scenario works without errors on stable (1.32) and beta (1.33.0-beta.6).
I don't actually understand linkers enough to even say if that's a bug or expected behaviour, but at least for me it's a regression, because a scenario that was working on stable has stopped to work on nightly.
The text was updated successfully, but these errors were encountered: