ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.19k stars 258 forks source link

Error: failed to locate link.exe #2963

Closed Temtaime closed 5 years ago

Temtaime commented 5 years ago

Hello ! Starting ldc 1.13.0 there's a following change in linker-msvc.cpp:

  const bool useInternalToolchain = useInternalToolchainForMSVC();

#ifdef _WIN32
  if (!useInternalToolchain)
    windows::setupMsvcEnvironment();
#endif

useInternalToolchainForMSVC checks if needed environment variables are set up, but they are going to be set up only after the check... This is something weird and forces the user to setup VSINSTALLDIR and LDC_VSDIR in their own environment, making dumpEnv.bat useless. Better add a command line switch or revert to previous behavior.

kinke commented 5 years ago

This is something weird and forces the user to setup VSINSTALLDIR and LDC_VSDIR in their own environment

Nope, as it defaults to the internal toolchain if the environment isn't set up appropriately, which has no dependencies whatsoever, and should use -link-internally. Are you building LDC yourself without our LLVM fork?

kinke commented 5 years ago

And as to using the MS toolchain, I detailed 3 ways to do so in README.txt - 1) VS command prompt, 2) setting up LDC_VSDIR (to actual dir or some dummy dir for the legacy autodetection), and 3) modding ldc2.conf.

Temtaime commented 5 years ago

Thanks! Yes, i'm making my own build of ldc and msvc's environment is set up using dumpenv.bat. I tried to use internal linking with lld, but with my projects it sometimes were leading to crashing executables. Also, what is the fork and why it should be used instead of standard llvm ?

kinke commented 5 years ago

The fork (LLVM & LLD) contains a few mods we require for some targets, such as Android TLS stuff, Windows debuginfo adaptations and especially making LLD work properly with LDC's -link-internally.

The logic wrt. 'internal' MSVC toolchain is tailored for our prebuilt Windows package, e.g., it also expects the MinGW-based libs to be installed in lib\mingw. I don't think a lot of Windows people build their own LDC, that's why it doesn't work out of the box for you. Btw, I edited README.txt yesterday, as variant 3 was missing one required step.

Temtaime commented 5 years ago

Clear. Then ok, i think i can live with some additional changes to my builds :) Feel free to close the issue, thanks for an explanation. Btw, are those changes will be pushed up in the mainstream llvm ?

kinke commented 5 years ago

I'd like to upstream some crucial changes, especially the LLD ones; the Android TLS stuff on the other hand will most likely never make it upstream. But LLVM hasn't switched to GitHub yet AFAIK.