Skip to content

Add missing -lmsvcrt on mingw after -lpthread #70605

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Apr 1, 2020

Conversation

Amanieu
Copy link
Member

@Amanieu Amanieu commented Mar 31, 2020

Fixes #70316

@rust-highfive
Copy link
Contributor

r? @varkor

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2020
@varkor
Copy link
Member

varkor commented Mar 31, 2020

@bors r+ rollup

@mati865
Copy link
Contributor

mati865 commented Mar 31, 2020

Why not move

if let Some(args) = sess.target.target.options.late_link_args.get(&flavor) {
cmd.args(args);
}
below
if any_dynamic_crate {
if let Some(args) = sess.target.target.options.late_link_args_dynamic.get(&flavor) {
cmd.args(args);
}
} else {
if let Some(args) = sess.target.target.options.late_link_args_static.get(&flavor) {
cmd.args(args);
}
}
instead?

late_link_args contain only "CRT" libraries that have no further dependencies:

late_link_args.insert(
LinkerFlavor::Gcc,
vec![
"-lmingwex".to_string(),
"-lmingw32".to_string(),
"-lmsvcrt".to_string(),
// mingw's msvcrt is a weird hybrid import library and static library.
// And it seems that the linker fails to use import symbols from msvcrt
// that are required from functions in msvcrt in certain cases. For example
// `_fmode` that is used by an implementation of `__p__fmode` in x86_64.
// Listing the library twice seems to fix that, and seems to also be done
// by mingw's gcc (Though not sure if it's done on purpose, or by mistake).
//
// See https://github.com/rust-lang/rust/pull/47483
"-lmsvcrt".to_string(),
"-luser32".to_string(),
"-lkernel32".to_string(),
],
);

@Amanieu
Copy link
Member Author

Amanieu commented Mar 31, 2020

It's not that simple: the mingw* libraries depend on libgcc.

@mati865
Copy link
Contributor

mati865 commented Mar 31, 2020

Bummer, I had thought only winpthreads depend on GCC libs.

@pietroalbini
Copy link
Member

@bors r=varkor rollup

Somehow bors missed the approval.

@bors
Copy link
Collaborator

bors commented Mar 31, 2020

📌 Commit 1ae3b50 has been approved by varkor

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 31, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 31, 2020
Add missing -lmsvcrt on mingw after -lpthread

Fixes rust-lang#70316
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 31, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#68770 (BTreeMap/BTreeSet: implement drain_filter )
 - rust-lang#70081 (add `unused_braces` lint)
 - rust-lang#70556 (parse_and_disallow_postfix_after_cast: account for `ExprKind::Err`.)
 - rust-lang#70605 (Add missing -lmsvcrt on mingw after -lpthread)
 - rust-lang#70630 (Update books.)
 - rust-lang#70632 (expand vec![] to Vec::new())

Failed merges:

r? @ghost
@bors bors merged commit ddcc281 into rust-lang:master Apr 1, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

i686-pc-windows-gnu fails to link on appveyor
6 participants