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

Merge LLVM's commit that fixes lld-link on Windows 7 and Wine #3691

Closed
SimonN opened this issue Apr 1, 2021 · 7 comments
Closed

Merge LLVM's commit that fixes lld-link on Windows 7 and Wine #3691

SimonN opened this issue Apr 1, 2021 · 7 comments

Comments

@SimonN
Copy link

SimonN commented Apr 1, 2021

Please include this commit from llvm-project upstream in the next LDC release. That commit fixes LDC issue #3675 -- lld-link fails to write any output at all -- on Windows 7, and likely also on Wine.

I use LDC in Wine as my Linux-to-Windows cross-compiling solution. As I explained in the (prematurely closed) LDC issue #3675, the current LDC 1.25.1 is broken in Wine; lld-link errors even on Hello World. Thus, I'm very interested that the upstream fix from LLVM gets merged into the next LDC. Likewise, the Windows 7 users will also be happy about the merge.

My broken LDC is:

LDC - the LLVM D compiler (1.25.1):
  based on DMD v2.095.1 and LLVM 11.0.1
  built with LDC - the LLVM D compiler (1.25.1)
  Default target: x86_64-pc-windows-msvc
  Host CPU: skylake

Example output from failing compiles of Hello World

@kinke
Copy link
Member

kinke commented Apr 1, 2021

The linked commit seems to fix something that landed in 12.0.0; unless it was also cherry-picked for LLVM 11.0.1, I doubt that it fixes the LLD issue.

A workaround for the time being is to download some working lld-link.exe (e.g., older versions of https://github.com/ldc-developers/llvm-project/releases) and use it via -linker=lld-link (e.g., in etc/ldc2.conf).

@SimonN
Copy link
Author

SimonN commented Apr 2, 2021

In the description on LLVM Phabricator, fix author aganea says that this commit fixes the following two downstream bugs:

Then Rust Bug 82677 - Track Windows 7 vs. delete-on-close fixes says that aganea's fix resolves the llvm-ar problem.

How do LLVM fixes normally get into LDC, is there a manual selection or does it always depend on the latest LLVM backend?

Thanks for the workaround idea. I'll keep LDC 1.24 around for now, but breaking changes in the D language might happen anytime, so it's good to have this idea as a backup.

@thewilsonator
Copy link
Contributor

How do LLVM fixes normally get into LDC

Official LDC releases are built with https://github.com/ldc-developers/llvm-project
You can always build LLVM yourself and build LDC against that, though you may need to do some alterations to druntime (updating versions and the like).

@kinke
Copy link
Member

kinke commented Apr 10, 2021

The mentioned commit was cherry-picked onto upstream's release/12.x branch and will thus be in 12.0.0 final (still not released...).

@SimonN
Copy link
Author

SimonN commented May 17, 2021

In Wine 6.7, the same LDC 1.25.1 now works that failed in Wine 6.4. That solves my problem already before updating to the current LDC 1.26.0. Looks like Windows 7 and Wine shared an oddity that doesn't exist anymore in Win 8 and Win 10.

I'll re-test with LDC 1.26.0 on Wine 6.7 within 1-2 days and post results.

@kinke
Copy link
Member

kinke commented May 18, 2021

Official v1.26 builds still use LLVM 11.0.1, so I don't expect any difference.

@SimonN
Copy link
Author

SimonN commented Jun 9, 2021

  • Wine 6.4 + LDC 1.25.1 is the original bug.
  • Wine 6.4 + LDC 1.26.0 has the same bug.
  • Wine 6.4 + LDC 1.27.0-beta1 has the same bug: On compiling/linking Hello World, I get:
lld-link: error: failed to write the output file: Path is invalid.
  • Wine 6.9 + LDC 1.25.1 works.
  • Wine 6.9 + LDC 1.26.0 works.
  • Wine 6.10 + LDC 1.27.0-beta1 works.

You've included aganea's commit exactly as this isssue suggests, thanks! For Wine, the commit turned out irrelevant. Wine 6.7 (or maybe 6.6 or 6.5) has its own fix, and that fix is the only important fix.

But for Windows 7, aganea's commit looks like it's really the fix: Hello World will now compile on Windows 7 using LDC 1.27.0-beta1 that is based on LLVM 12.0.0. Hello World didn't compile on Windows 7 with LDC 1.26.0.

Thus:

  • Windows 7 users: Update to LDC 1.27.0-beta1 or newer.
  • Wine users: Update to Wine 6.7 or newer. Any LDC should then work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants