Skip to content

Prefer bundled linker redux #18797

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

Merged
merged 4 commits into from
Nov 11, 2014
Merged

Prefer bundled linker redux #18797

merged 4 commits into from
Nov 11, 2014

Conversation

vadimcn
Copy link
Contributor

@vadimcn vadimcn commented Nov 9, 2014

Based on Windows bundle feedback we got to date,

  • We do want to prefer the bundled linker: The external one might be for the wrong architecture (e.g. 32 bit vs 64 bit). On the other hand, binutils don't add many new features these days, so using an older bundled linker is not likely to be a problem.
  • We do want to prefer bundled libraries: The external ones might not have the symbols we expect (e.g. what's needed for DWARF exceptions vs SjLj). Since -L rustlib/<triple>/lib appears first on the linker command line, it's a good place to keep our platform libs that we want to be found first.

Closes #18325, closes #17726.

…llect2 cannot be found. The latter is the case for our bundles, because we don't include collect2. Unfortunately, ld does not understand this option and errors out.

On the bright side, -fno-use-linker-plugin still works to suppress gcc's LTO, so we can drop -fno-lto.
@alexcrichton
Copy link
Member

Did you move the bundled libraries from under gcc to back under bin to pass fewer -L flags? I would think that for organizational purposes it would be nice to keep them separated. Other than that though, this looks great to me, thanks!

@brson
Copy link
Contributor

brson commented Nov 10, 2014

I'm also happy with this as long as @alexcrichton is satisfied he can get cargo linking correctly under this scheme.

@alexcrichton
Copy link
Member

Not entirely sure how we'll manage it, but I'm sure I can think of something for Cargo!

@vadimcn
Copy link
Contributor Author

vadimcn commented Nov 10, 2014

@alexcrichton, I am trying to keep this all sufficiently generic so that we don't need to add Windows-specific if's in rustc code. Especially now, that "Flexible Target Specifications" has landed.

rustlib/<triple>/gcc/lib feels awfully Windows-specific. I suppose we could have rustlib/<triple>/lib for Rust libs and rustlib/<triple>/lib/native for platform-specific stuff... Any sugggestions?

cc @cmr

bors added a commit that referenced this pull request Nov 11, 2014
Based on Windows bundle feedback we got to date, 
- We *do* want to prefer the bundled linker: The external one might be for the wrong architecture (e.g. 32 bit vs 64 bit).  On the other hand, binutils don't add many new features these days, so using an older bundled linker is not likely to be a problem.
- We *do* want to prefer bundled libraries: The external ones might not have the symbols we expect (e.g. what's needed for DWARF exceptions vs SjLj).  Since `-L rustlib/<triple>/lib` appears first on the linker command line, it's a good place to keep our platform libs that we want to be found first.

Closes #18325, closes #17726.
@bors bors closed this Nov 11, 2014
@bors bors merged commit cb2328f into rust-lang:master Nov 11, 2014
@vadimcn vadimcn deleted the prefer-bundled2 branch March 1, 2015 08:02
@jeffnyman
Copy link

jeffnyman commented Dec 5, 2021

I made a comment in #17726 (which I know is closed) and that issue redirects people to this one. I find the error in that previous issue still happens as of right now with a complete up-to-date install of Rust via rustup.

Specifically, I see the following error when trying to compile a basic Rust program on Windows:

collect2.exe: error: ld returned 1 exit status

And it's clear that the Rust toolchain is using an existing mingw32 setup, not it's bundled one. I'm using the following:

stable-x86_64-pc-windows-gnu (default)
rustc 1.57.0 (f1edd0429 2021-11-29)

I did try adding the the following to the PATH:

.rust\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\bin\gcc-ld

I added that before the part of the PATH that had a link to the bin directory of the mingw setup. The only way I found this could work was to entirely remove the reference to mingw path from the setup entirely. And when I did that, I didn't even need the above path to the toolchains in place.

So is that the solution that was decided upon?

lnicola pushed a commit to lnicola/rust that referenced this pull request Jan 7, 2025
Fix replace-if-let-with-match generates non-exhausive match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants