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

LNK 1107 on windows with clang++/link.exe(MSVC)/ninja #10022

Open
UnixY2K opened this issue Feb 21, 2022 · 5 comments
Open

LNK 1107 on windows with clang++/link.exe(MSVC)/ninja #10022

UnixY2K opened this issue Feb 21, 2022 · 5 comments

Comments

@UnixY2K
Copy link

UnixY2K commented Feb 21, 2022

List of know workarounds

Adding this list of known workarrounds so any user that sees this Issue can use them without reading the whole conversation or related issues.

You can run one of the following workarounds

  • set the following environment variables before configuring the project
    • CXX to clang++
    • CXX_LD to lld-link
  • install meson 0.60.1 as this issue was not ported to 0.60.1+
    • via pip run pip install meson==0.60.1

as for this time the issue is present on 1.0.0, if this gets fixed on a newer release feel free to comment it so I can update this description or close the issue if required

as for the time I recommend using the first workaround as is a one setup fix(and you can use any version of meson).

Description

Describe the bug
A LNK 1107 is throw when trying to compile a static library on windows.
image

To Reproduce
the following repo shows this behavior: meson-compile-clang-issue
the compile-meson-MSVC-link.ps1 creates a native build using the default compiler (clang++ detected) and default static compiler(link.exe), this will produce an LNK1107 as MSVC link.exe does not support thin static libraries and clang++ will pick link.exe by default.
image

Expected behavior
Meson should not use the --thin(T) flag when using link.exe (detected by default) or try to use the lld-link compiler when using clang++ in a static library.
manually editing the build.ninja and removing the flag makes it compile successfully:
image
using the compile-meson-lld-link.ps1 will force the use of lld-link (which support thin static libraries generated by LLVM-AR) instead and the code will compile with the following output:
image

system parameters

  • plain native build

Environment:
Clear Windows machine (can be a VM), on this example the Windows 11 dev environment provided by Hyper-V in windows 11 and on my machine.

  • Visual Studio 2022 with C++ tools.
  • LLVM 13.0.1
  • python 3.10.2
  • meson 0.61.2 (pip latest)
  • 1.10.2.git.kitware.jobserver-1 (pip latest)
    image

if installed in that order better

if there is anything else needed, please let me know

@xymy
Copy link

xymy commented Aug 13, 2022

I'm surprised 6 months have passed and the bug has not been fixed.

Thanks. I edit build.ninja and remove the T flag, it works.

@dcbaker
Copy link
Member

dcbaker commented Aug 13, 2022

@eli-schwartz i thought we backed out thin library support?

@eli-schwartz
Copy link
Member

It turns out we only did that for a particular stable branch, see e.g. #9453 and #9482

Our heuristic of checking --help output was known to fail on OSX and was manually disabled there at the time of initial implementation.

It also failed as reported in those tickets for certain types of consumers such as cuda / custom targets.

Apparently it's additionally broken on link.exe (I'm surprised the heuristic matches there???).

So that's just a bundle of cases where it fails, which is disappointing. And we quite obviously don't handle them all. I didn't expect this when I originally implemented it, and honestly I'm not too attached to using thin archives. I seem to recall saying somewhere that I was not opposed to reverting it altogether.

I don't know, maybe it can be saved, but I don't even know why it currently fails so I'm probably not the best person to figure out how to save it. Hardcoding "don't use it on Windows just like we don't use it on macOS"?

Please feel free to revert or fix it as you wish. I won't be back home yet for a day or two.

@dcbaker
Copy link
Member

dcbaker commented Aug 14, 2022

Okay, I won’t have a chance to look till Monday either, and doing have a windows machine atm

@UnixY2K
Copy link
Author

UnixY2K commented Dec 24, 2022

I put a list of know workarrounds in the description so any new user can check them, if it gets fixed on a newer release feel free to close it or update this issue

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

4 participants