Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Improve Windows-friendliness for MSVC builds. #10

Closed
wants to merge 3 commits into from

Conversation

kinke
Copy link
Member

@kinke kinke commented Aug 7, 2015

The only essential dependencies are GNU make for Windows and bash with some tools (diff, grep...). bash and GNU tools are included by git for Windows distributions.

This commit fixes the x64/x86 detection (my Win8 x64 was detected as OS=win32 due to uname.exe provided by git returning MINGW32_NT-6.2), doesn't overwrite the LIB environment variable (which is crucial for the MS linker) and assumes cl.exe to be in a directory in the PATH environment variable rather than a hardcoded path to VS 2010.

A binary distribution of GNU make for Windows (v3.81 from 2006) is available at http://gnuwin32.sourceforge.net/packages/make.htm - you'll need the binaries and dependencies ZIPs.
Some scripts require GNU diff to support --strip-trailing-cr, which wasn't the case for the ancient diff.exe (v2.7) provided by my git distribution. A newer version (2.8.7) can be downloaded from http://gnuwin32.sourceforge.net/packages/diffutils.htm.

@kinke kinke changed the title Increase Windows-friendliness for MSVC builds. Improve Windows-friendliness for MSVC builds. Aug 8, 2015
@kinke
Copy link
Member Author

kinke commented Aug 8, 2015

After working on various issues, this is the current state of dmd-testsuite(-debug) on my win64 branch:

  • 7 debug & 6 release (congruent) failures
  • 2 of which I cannot reproduce when invoking the command manually

Pretty cool, huh? :)

 ... runnable\cppa.d                (-g)
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\cppa_0.exe runnable\cppa.d C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\cppb.cpp.obj
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
druntime-ldc-debug.lib(errno.c.obj) : warning LNK4217: locally defined symbol _errno imported in function getErrno
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\cppa_0.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\cppa_0.exe
...
bar = 0000000000913970
This = 000000000075F2E0
f.p = 0000000803FA1010, b = 0000000000913970
core.exception.AssertError@runnable\cppa.d(120): Assertion failure
==============================
Test failed: expected rc == 0, exited with rc == 1
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/cppa.d.out] Fehler 1



 ... runnable\ldc_extern_weak.d     ()
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\ldc_extern_weak_0.exe runnable\ldc_extern_weak.d
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\ldc_extern_weak_0.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\ldc_extern_weak_0.exe
core.exception.AssertError@runnable\ldc_extern_weak.d(10): Assertion failure
==============================
Test failed: expected rc == 0, exited with rc == 1
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/ldc_extern_weak.d.out] Fehler 1



 ... runnable\opover2.d             (-inline -O -property)
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\opover2_0.exe runnable\opover2.d
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\opover2_0.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\opover2_0.exe
...
Success
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable  -inline -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\opover2_1.exe runnable\opover2.d
Assertion failed: cast<DISubprogram>(Scope)->describes(MF->getFunction()), file C:\LDC\llvm\lib\CodeGen\LexicalScopes.cpp, line 160
0x000007F73EFC53C5 (0x0000000000000016 0x000007F73E8B7E8F 0x00000000000000A0 0x000007FDE9E263A4), HandleAbort() + 0x5 bytes(s), c:\ldc\llvm\lib\support\windows\signals.inc, line 296
0x000007FDE9E7DA08 (0x0000000000000001 0x000007F700000000 0x0000000000000000 0x0000003D0EFDEC70), raise() + 0x1E8 bytes(s)
0x000007FDE9E7E9D1 (0x000007FD00000003 0x0000000000000003 0x000007F73FAA70A0 0x000007F73FAA7030), abort() + 0x31 bytes(s)
0x000007FDE9E80E61 (0x00000000000000A0 0x000007F73FAA70A0 0x0000000000000000 0x0000000000000000), _get_wide_winmain_command_line() + 0x1171 bytes(s)
0x000007FDE9E8116F (0x0000003D112E2668 0x0000003D1123EA68 0x0000003D11260BF0 0x000007F73EFB6C42), _wassert() + 0x3F bytes(s)
0x000007F73E8B7E8F (0x0000003D11801400 0x0000003D1123EA68 0x0000000000000000 0x0000000000000000), llvm::LexicalScopes::getOrCreateRegularScope() + 0x27F bytes(s), c:\ldc\llvm\lib\codegen\lexicalscopes.cpp, line 161
0x000007F73E8B6809 (0x0000003D0F0F4408 0x0000003D0EFDEE70 0x0000003D0F0F4408 0x0000003D11D49930), llvm::LexicalScopes::extractLexicalScopes() + 0xE9 bytes(s), c:\ldc\llvm\lib\codegen\lexicalscopes.cpp, line 86 + 0x26 byte(s)
0x000007F73E8B8335 (0x0000003D0F0F5E58 0x0000003D0F0F5E58 0x0000003D11C00D38 0x0000003D11C00D08), llvm::LexicalScopes::initialize() + 0x75 bytes(s), c:\ldc\llvm\lib\codegen\lexicalscopes.cpp, line 46
0x000007F73F3A3992 (0x0000003D112E2668 0x0000003D11279830 0x0000003D0F0E6BB0 0x0000003D11B47048), llvm::DwarfDebug::beginFunction() + 0xC2 bytes(s), c:\ldc\llvm\lib\codegen\asmprinter\dwarfdebug.cpp, line 1089
0x000007F73F37C9AC (0x0000000000000000 0x0000003D11279800 0x0000003D11BF6A70 0x0000000000000001), llvm::AsmPrinter::EmitFunctionHeader() + 0x30C bytes(s), c:\ldc\llvm\lib\codegen\asmprinter\asmprinter.cpp, line 579
0x000007F73F37B6D8 (0x0000003D11279800 0x0000003D11279800 0x0000003D11BF6A70 0x0000003D11BF6A70), llvm::AsmPrinter::EmitFunctionBody() + 0x48 bytes(s), c:\ldc\llvm\lib\codegen\asmprinter\asmprinter.cpp, line 788
0x000007F73F153BC0 (0x0000000000000000 0x0000003D10BCD520 0x0000000000000000 0x0000003D10BCD520), llvm::X86AsmPrinter::runOnMachineFunction() + 0xA0 bytes(s), c:\ldc\llvm\lib\target\x86\x86asmprinter.cpp, line 71
0x000007F73E98BBEF (0x0000003D112E2668 0x0000003D10BCD520 0x0000003D10F57FE0 0x000000000000000A), llvm::FPPassManager::runOnFunction() + 0x1AF bytes(s), c:\ldc\llvm\lib\ir\legacypassmanager.cpp, line 1520 + 0xF byte(s)
0x000007F73E98BDEF (0x0000000000000000 0x0000000000000001 0x0000003D11035410 0x0000003D10F580E8), llvm::FPPassManager::runOnModule() + 0x3F bytes(s), c:\ldc\llvm\lib\ir\legacypassmanager.cpp, line 1539
0x000007F73E98C0B3 (0x0000003D00000002 0x000000000000000A 0x0000000000000000 0x0000003D10F58010), `anonymous namespace'::MPPassManager::runOnModule() + 0x283 bytes(s), c:\ldc\llvm\lib\ir\legacypassmanager.cpp, line 1596 + 0xF byte(s)
0x000007F73E98B556 (0x000007F73FB7A6C0 0x0000003D10F58010 0x0000003D0EFDF580 0x0000003D10F58010), llvm::legacy::PassManagerImpl::run() + 0x146 bytes(s), c:\ldc\llvm\lib\ir\legacypassmanager.cpp, line 1699
0x000007F73E28552F (0x0000003D0EFDF7B0 0x0000003D0EFDF630 0x0000003D11BF0290 0x000000000000003B), codegenModule() + 0x9F bytes(s), c:\ldc\ldc\driver\toobj.cpp, line 131
0x000007F73E288267 (0x000000000000003B 0x0000003D0EFDF940 0x0000003D11BF07E0 0x0000000000000000), writeModule() + 0x907 bytes(s), c:\ldc\ldc\driver\toobj.cpp, line 581
0x000007F73E2798D6 (0x0000000000000000 0x0000003D0EFDF930 0x0000000000000000 0x0000000000000001), ldc::CodeGenerator::writeAndFreeLLModule() + 0x1E6 bytes(s), c:\ldc\ldc\driver\codegenerator.cpp, line 172
0x000007F73E29824C (0x0000000000000000 0x000007F7400AA610 0x0000000000000000 0x0000000000000000), main() + 0xF7C bytes(s), c:\ldc\ldc\driver\main.cpp, line 1304
0x000007F73F347CEC (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), __scrt_common_main_seh() + 0x124 bytes(s), f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl, line 264 + 0x22 byte(s)
0x000007FDFCAF1832 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0x1A bytes(s)
0x000007FDFE84D609 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)
==============================
Test failed: expected rc == 0, exited with rc == 3
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/opover2.d.out] Fehler 1

=> compiles & runs fine from cmdline! also works for dmd-testsuite (release)



 ... runnable\statictor.d           ()
Test failed.  The logged output:
Executing post-test script: bash runnable\extra-files\statictor-postscript.sh C:/LDC/ninja-ldc/dmd-testsuite-debug\d5547de1e6cc8043124b9521bd33d5be28d41b70cd9134e19b053b7da7f50ee8
0a1,2271
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\statictor_0.exe runnable\statictor.d
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\statictor_0.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\statictor_0.exe
shared static this()
Foo static ctor
static ctor
Bar static ctor
Bar static dtor
static dtor
Foo static dtor
shared static this()
==============================
Test failed: expected rc == 0, exited with rc == 1
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/statictor.d.out] Fehler 1

=> returns 0 from cmdline!



 ... runnable\test13613.d           ()
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\test13613_0.exe runnable\test13613.d
...
==============================
Test failed: 
expected:
----
CT x.offsetof = <
CT y.offsetof = <
0 > y
0 > x
----
actual:
----
CT x.offsetof = <
CT y.offsetof = <
0 > y
0 > x
C:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\test13613_0.exe : warning LNK4088: image being generated due to /FORCE option; image may not run
----
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/test13613.d.out] Fehler 1

=> just an additional warning



 ... runnable\test42.d              ()
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Irunnable   -odC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\runnable\test42_0.exe runnable\test42.d
...
r = 1.84467e+19, ulong.max = 18446744073709551615
d = 0, ulong.max = ffffffffffffffff
~one
~two
core.exception.AssertError@runnable\test42.d(1652): Assertion failure
==============================
Test failed: expected rc == 0, exited with rc == 1
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/runnable/test42.d.out] Fehler 1

=> cast(ulong) (real r = ulong.max) == 0 instead of ulong.max



 ... fail_compilation\diag4479.d    fail_compilation/imports/fail4479.d ()
Test failed.  The logged output:
C:\LDC\ninja-ldc\bin\ldmd2.exe -conf= -m64 -Ifail_compilation -verrors=0 fail_compilation/imports/fail4479.d  -odC:/LDC/ninja-ldc/dmd-testsuite-debug\fail_compilation -ofC:/LDC/ninja-ldc/dmd-testsuite-debug\fail_compilation\diag4479_0.obj -c fail_compilation\diag4479.d
...
==============================
Test failed: 
expected:
----
fail_compilation\diag4479.d(10): Error: module imports.fail4479mod from file fail_compilation\imports\fail4479.d must be imported with 'import imports.fail4479mod;'
----
actual:
----
fail_compilation\diag4479.d(10): Error: module imports.fail4479mod from file fail_compilation\imports\fail4479.d conflicts with another module fail4479mod from file fail_compilation/imports/fail4479.d
----
make[2]: *** [C:/LDC/ninja-ldc/dmd-testsuite-debug/fail_compilation/diag4479.d.out] Fehler 1

=> different error msg

@Trass3r
Copy link

Trass3r commented Aug 15, 2015

Nice write-up 👍

@kinke
Copy link
Member Author

kinke commented Aug 15, 2015

The last 2 issues about the invalid hex exponent is fixed by using MSVCRT (2015) strtold() in Port::strtold() instead of the LLVM function which asserts the input string is valid. I'll add the corresponding commit once dlang/dmd#4870 makes it upstream (if ever).

@Trass3r It'd be cool if you could help investigating some issues. E.g., in runnable\test42.d:1650, the result of casting real r = ulong.max back to ulong appears to be 0 instead of ulong.max. As the following test with ulong.max-1 is explicitly disabled for 64-bit reals, the first one should most likely work, but currently doesn't on Win64...

@kinke
Copy link
Member Author

kinke commented Aug 16, 2015

I've updated the results; down to 7 (release: 6) dmd-testsuite issues with my updated win64 branch.

@kinke kinke force-pushed the win64 branch 2 times, most recently from 4985098 to b5e216a Compare August 30, 2015 01:31
The only essential dependencies are GNU make for Windows and bash
with some tools (diff, grep...). bash and GNU tools are provided
by git for Windows distributions.

This commit fixes the x64/x86 detection (my Win8 x64 was detected as
Win32 due to `uname.exe` provided by git returning `MINGW32_NT-6.2`),
doesn't overwrite the LIB environment variable (which is crucial for
the MS linker) and assumes cl.exe to be in a directory in the PATH
environment variable rather than a hardcoded path to VS 2010.

A binary distribution of GNU make for Windows (from 2006) is available
at http://gnuwin32.sourceforge.net/packages/make.htm - you'll need the
binaries and dependencies ZIPs.
Some scripts require GNU diff to support `--strip-trailing-cr`, which
wasn't the case for the ancient diff.exe (v2.7) provided by my git
distribution. A newer version (2.8.7) can be downloaded from
http://gnuwin32.sourceforge.net/packages/diffutils.htm.
Occurs if the make command is invoked with ctest, not if run directly
in a command line.
Note that the `quick` make target is supposed to clear ARGS.
@redstar redstar closed this Sep 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants