Thread overview
Are there any working instructions about how to build and test dmd on Windows?
Mar 13, 2018
rumbu
Mar 14, 2018
Rubn
Mar 14, 2018
rumbu
March 13, 2018
I know that there are contributing guides but I fail to successfully follow any of them:

https://wiki.dlang.org/Starting_as_a_Contributor

1. Bash install script will not run under Windows. Using git bash will result in error (Command error: undefined switch '-C')
2. Digger it's not compiling
3. Tried to make my own powershell script to mimic the setup.sh behavior. I'm stuck at compilation part (below)

https://wiki.dlang.org/Building_under_Windows

1. After several retries, I managed to compile DMD with make -fwin32.mak. In fact I'm not sure which is the intended makefile (the one in \dmd or the one in \dmd\src?)
2. make -fwin64.mak fails:

make -fwin32.mak C=dmd\backend TK=dmd\tk ROOT=dmd\root MAKE="make" HOST_DC="dmd" MODEL=64 CC="vcbuild\msvc-dmc" LIB="vcbuild\msvc-lib" OBJ_MSVC="..\generated\windows\release\64/strtold.obj ..\generated\windows\release\64\longdouble.obj ..\generated\windows\release\64\ldfpu.obj" "OPT=" "DEBUG=-D -g -DUNITTEST" "DDEBUG=-debug -g -unittest" "DOPT=" "LFLAGS=-L/ma/co/la" ..\generated\windows\release\64\dmd.exe
vcbuild\msvc-dmc -c -o..\generated\windows\release\64\newdelete.obj -Idmd\root   -D -g -DUNITTEST -cpp -DTARGET_WINDOS=1 -DDM_TARGET_CPU_X86=1 dmd\root\newdelete.c
"\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.exe" /nologo /Ivcbuild /Idmd\root /FIwarnings.h /c /Fo..\generated\windows\release\64\newdelete.obj /Idmd\root /DDEBUG /Zi -DUNITTEST /TP ^"-DTARGET_WINDOS=1^" ^"-DDM_TARGET_CPU_X86=1^" dmd\root\newdelete.c

std.process.ProcessException@std\process.d(753): Failed to spawn new process (The system cannot find the file specified.)
----------------
0x004136E8
0x0040D98A
0x00402CDB
0x00412D67
0x00412CE9
0x00412B84
0x0040D5D7
0x758A8654 in BaseThreadInitThunk
0x77B84A77 in RtlGetAppContainerNamedObjectPath
0x77B84A47 in RtlGetAppContainerNamedObjectPath

--- errorlevel 1

--- errorlevel 1

--- errorlevel 1


https://wiki.dlang.org/DMD_development

1. Downloaded GNU Make. How do I install it? What binaries are needed?
2. Installed Linux Subsystem (Debian). What next? Why do I need this?
3. All the make commands failed to execute. I suppose because make.exe is expected to be part of the GNU package. Failed to find such file in the GNU Make distribution.

March 14, 2018
Yah it's not fun.

Some notes:

You might need to set MSVC_CC environment variable cause it doesn't use the right format for VS path, depending on your version.

https://github.com/dlang/dmd/blob/v2.079.0/src/vcbuild/msvc-dmc.d#L19


You could open a command prompt with the batch file running which will add variables used by the script.

C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat


You should be able to build it now with just:

make -f win64.mak reldmd


When building druntime/phobos you need to pass the VCINSTALLDIR environment variable, but it has an unexpected "/" at the end of it so you need to remove it.

make -f win64.mak VCDIR="%VCINSTALLDIR:~0,-1%" DMD=../dmd/src/dmd

Didn't check if it works though I don't normally use batch/cmd.


March 14, 2018
On Wednesday, 14 March 2018 at 00:43:52 UTC, Rubn wrote:
> Yah it's not fun.
>
> Some notes:
>
> You might need to set MSVC_CC environment variable cause it doesn't use the right format for VS path, depending on your version.
>
> https://github.com/dlang/dmd/blob/v2.079.0/src/vcbuild/msvc-dmc.d#L19
>
>
> You could open a command prompt with the batch file running which will add variables used by the script.
>
> C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat
>
>
> You should be able to build it now with just:
>
> make -f win64.mak reldmd

Thanks, but now I'm stuck on this:

[...]

vcbuild\msvc-dmc -cpp -o..\generated\windows\release\64\optabgen.exe dmd\backend\optabgen -DMARS -DDM_TARGET_CPU_X86=1 -Idmd\tk
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe" /nologo /Ivcbuild /Idmd\root /FIwarnings.h ^"/D_HAS_EXCEPTIONS=0^" ^"/Wv:18^" /TP /Fe..\generated\windows\release\64\optabgen.exe dmd\backend\optabgen.c -DMARS ^"-DDM_TARGET_CPU_X86=1^" /Idmd\tk
optabgen.c
optabgen.obj : error LNK2019: unresolved external symbol __report_rangecheckfailure referenced in function "void __cdecl dotytab(void)" (?dotytab@@YAXXZ)
optabgen.obj : error LNK2019: unresolved external symbol __acrt_iob_func referenced in function printf
optabgen.obj : error LNK2019: unresolved external symbol fclose referenced in function "void __cdecl dotab(void)" (?dotab@@YAXXZ)
optabgen.obj : error LNK2019: unresolved external symbol fopen referenced in function "void __cdecl dotab(void)" (?dotab@@YAXXZ)
optabgen.obj : error LNK2019: unresolved external symbol __stdio_common_vfprintf referenced in function _vfprintf_l
optabgen.obj : error LNK2019: unresolved external symbol exit referenced in function "void __cdecl dotab(void)" (?dotab@@YAXXZ)
optabgen.obj : error LNK2019: unresolved external symbol _wassert referenced in function "void __cdecl doreltables(struct _iobuf *)" (?doreltables@@YAXPEAU_iobuf@@@Z)
optabgen.obj : error LNK2001: unresolved external symbol __GSHandlerCheck
optabgen.obj : error LNK2019: unresolved external symbol __security_check_cookie referenced in function "void __cdecl doreltables(struct _iobuf *)" (?doreltables@@YAXPEAU_iobuf@@@Z)
optabgen.obj : error LNK2019: unresolved external symbol __security_cookie referenced in function "void __cdecl doreltables(struct _iobuf *)" (?doreltables@@YAXPEAU_iobuf@@@Z)
LINK : error LNK2001: unresolved external symbol mainCRTStartup
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\libcpmt.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\LIBCMT.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
..\generated\windows\release\64\optabgen.exe : fatal error LNK1120: 11 unresolved externals