Skip to content
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

Force default MSVC linker when building on Windows #12855

Closed

Conversation

IceSentry
Copy link
Contributor

Release Notes:

  • N/A

Description

Using rust-lld.exe globally on windows is pretty common since it can help speed up compilation. Unfortunately, zed fails to build with that linker. This PR forces the default "link.exe" to be used on windows to avoid this potential error. This is intended as a temporary fix until the reason why it fails to compile with another linker is found.

Changing the linker from the global setting might seem a bit wrong but the alternative right now is just crashing with a STATUS_ACCESS_VIOLATION without any explanations as to what went wrong.

See #12041

Copy link

cla-bot bot commented Jun 10, 2024

We require contributors to sign our Contributor License Agreement, and we don't have @IceSentry on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@IceSentry
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jun 10, 2024
Copy link

cla-bot bot commented Jun 10, 2024

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title Force default msvc linker when building on windows Force default MSVC linker when building on Windows Jun 10, 2024
@osiewicz
Copy link
Contributor

Hey, I don't think we should merge this change.

  1. rust-lld is still in experimental phase, so I think it's expected for it to crash on some inputs. I don't think it makes sense to dance around problems with the tooling on dev machine in Zed repository itself, especially when said tooling is still in beta.
  2. This change actually prevents users from using their own linker if they wish to do so (e.g. llvm-lld), even when these linkers don't cause an AV for Zed.

Instead, I'd suggest overriding your global default for rust-lld by having a parent directory over zed repo that contains a separate .cargo/config.toml (and that file would contain the changes from this PR, in a nutshell).
That way, we don't need to maintain that in the repo itself.
So, in short, instead of having zed in E:\projects\zed, you'd need to nest it twice like so:

E:\projects\zed\zed <- path to the root of this repository

There'd also be a sibling directory in E:\projects\zed:
E:\projects\zed\.cargo that would contain config.toml with the overrides you need.

@IceSentry
Copy link
Contributor Author

IceSentry commented Jun 10, 2024

Right, I didn't consider a nested folder because I'm used to not having a checked in .cargo/config.toml which is why I wasn't sure what to do and made that PR. I guess that solution will work too. It's a bit annoying to have to do that though.

About rust-lld being experimental. It is, but it's the first time I've ever had a compile issue with it enabled and I've had it for probably 2 years at this point. I know many people using the same config on windows. So I guess the better PR would be to document this in the windows build guide.

@IceSentry IceSentry closed this Jun 10, 2024
@osiewicz
Copy link
Contributor

Yeah, documenting it in the build guide sounds like a good change, with a link to the issue and all that.

@IceSentry
Copy link
Contributor Author

Here's the updated doc PR #12859

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants