www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - ldc2 Windows

reply Carl Sturtivant <sturtivant gmail.com> writes:
Can't find any Windows specific docs for ldc2.

I want to know which environment variables specific to Windows 
ldc2 listens to so as to find the linker and libs so as to speed 
up linking by not searching for a Visual Whatever installation 
every time.

Anyone?
Oct 16 2018
next sibling parent Carl Sturtivant <sturtivant gmail.com> writes:
On Tuesday, 16 October 2018 at 16:43:38 UTC, Carl Sturtivant 
wrote:
 Can't find any Windows specific docs for ldc2.

 I want to know which environment variables specific to Windows 
 ldc2 listens to so as to find the linker and libs so as to 
 speed up linking by not searching for a Visual Whatever 
 installation every time.

 Anyone?
I have determined that the vcvars batch file that comes with the windows 10 sdk sets the following new variables for 64 bit development on windows 10 64-bit. It also adds to Path, which I would prefer to avoid. Some of these are obviously irrelevant, but which ones does ldc2 actually use to speed up linking? I could use intuition and experiment, but it would be nice if someone would just point me to docs or tell me the answer. CommandPromptType DevEnvDir ExtensionSdkDir Framework40Version FrameworkDir FrameworkDir64 FrameworkVersion FrameworkVersion64 INCLUDE LIB LIBPATH Platform UCRTVersion UniversalCRTSdkDir VCIDEInstallDir VCINSTALLDIR VCToolsInstallDir VCToolsRedistDir VCToolsVersion VS150COMNTOOLS VSCMD_ARG_HOST_ARCH VSCMD_ARG_TGT_ARCH VSCMD_ARG_app_plat VSCMD_VER VSINSTALLDIR VisualStudioVersion WindowsLibPath WindowsSDKLibVersion WindowsSDKVersion WindowsSdkBinPath WindowsSdkDir WindowsSdkVerBinPath __DOTNET_ADD_64BIT __DOTNET_PREFERRED_BITNESS __VSCMD_PREINIT_PATH
Oct 16 2018
prev sibling parent reply kinke <kinke libero.it> writes:
On Tuesday, 16 October 2018 at 16:43:38 UTC, Carl Sturtivant 
wrote:
 Can't find any Windows specific docs for ldc2.

 I want to know which environment variables specific to Windows 
 ldc2 listens to so as to find the linker and libs so as to 
 speed up linking by not searching for a Visual Whatever 
 installation every time.
The LDC package contains a README.txt. Quoting: 'If run in a 'VS Native/Cross Tools Command Prompt' (i.e., if the environment variable VSINSTALLDIR is set), LDC skips the Visual C++ detection.' Spawning a new VS command prompt ('shell', cmd.exe with env variables set up by the MS batch file) and invoking LDC in that shell is the preferred way of skipping that ~1-second linking overhead, at least that's how I do things all the time. If for whatever reason you don't want all of those MS env variables, you'll just need VSINSTALLDIR to prevent LDC from autodetecting and then the env variables expected by the MS linker (LIB and LIBPATH may be enough, I don't remember).
Oct 16 2018
parent reply kinke <kinke libero.it> writes:
On Tuesday, 16 October 2018 at 17:34:41 UTC, kinke wrote:
 [...]
PS: * In case you haven't noticed, there are startmenu shortcuts to the VS command prompts, at least with a full VS installation, not sure about the Build Tools. * PATH is also required, LDC invokes `link.exe`. Make sure there's no DMD link.exe in PATH. ;)
Oct 16 2018
parent reply kinke <noone nowhere.com> writes:
On Tuesday, 16 October 2018 at 17:38:48 UTC, kinke wrote:
 * PATH is also required, LDC invokes `link.exe`. Make sure 
 there's no DMD link.exe in PATH. ;)
PPS: Not really required (e.g., with `-link-internally` or with `-linker=<path\to\link.exe>`). You can also specify the lib dirs as linker flags via `-L/LIBPATH:<dir1> -L/LIBPATH:<dir2>` in the LDC command line, so that you don't need that env variable either. You can put these switches into the etc\ldc2.conf file to make them implicit. All you should really need is setting VSINSTALLDIR to something non-empty.
Oct 16 2018
parent reply Carl Sturtivant <sturtivant gmail.com> writes:
On Tuesday, 16 October 2018 at 19:09:26 UTC, kinke wrote:
 On Tuesday, 16 October 2018 at 17:38:48 UTC, kinke wrote:
 * PATH is also required, LDC invokes `link.exe`. Make sure 
 there's no DMD link.exe in PATH. ;)
PPS: Not really required (e.g., with `-link-internally` or with `-linker=<path\to\link.exe>`). You can also specify the lib dirs as linker flags via `-L/LIBPATH:<dir1> -L/LIBPATH:<dir2>` in the LDC command line, so that you don't need that env variable either. You can put these switches into the etc\ldc2.conf file to make them implicit. All you should really need is setting VSINSTALLDIR to something non-empty.
Thanks for all the very useful information! Much appreciated. Based upon all this I tried first setting VSINSTALLDIR and adding to PATH the path to the linker. And setting LIB. (Apparently LIBPATH is for the compiler, not the linker.) This did the job! I'll put the path to the linker and the directories in LIB into switches in etc/ldc2.conf and I'll have a clean setup.
Oct 16 2018
parent Carl Sturtivant <sturtivant gmail.com> writes:
On Tuesday, 16 October 2018 at 20:14:03 UTC, Carl Sturtivant 
wrote:
 Based upon all this I tried first setting VSINSTALLDIR and 
 adding to PATH the path to the linker. And setting LIB. 
 (Apparently LIBPATH is for the compiler, not the linker.) This 
 did the job! I'll put the path to the linker and the 
 directories in LIB into switches in etc/ldc2.conf and I'll have 
 a clean setup.
Specifically for persons new to D on windows who want to follow in these footsteps, the values needed proved to be as follows on 64 bit Windows 10. I obtained these by running the commands listed below in a `x64 Native Tools Command Prompt for VS 2017` under `Visual Studio 2017\Visual Studio Tools\VC` from the start menu. Probably you should do that. VSINSTALLDIR from `echo %VSINSTALLDIR%` C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\ LIB from `echo %LIB%` C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64; PATH --- addition to PATH needed to find link.exe from `where link` C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\bin\Hostx64\x64\
Oct 23 2018