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

The default example does not work on Windows #1908

Closed
Wulfklaue opened this issue Aug 31, 2017 · 30 comments
Closed

The default example does not work on Windows #1908

Wulfklaue opened this issue Aug 31, 2017 · 30 comments

Comments

@Wulfklaue
Copy link

`#!/usr/bin/env dub
/+ dub.sdl:
name "hello_vibed"
dependency "vibe-d" version="~>0.8.0"
+/
import vibe.d;

void main()
{
auto settings = new HTTPServerSettings;
settings.port = 8080;

listenHTTP(settings, (req, res) { res.writeBody("Hello Vibe.d: " ~ req.path); });
runApplication();

}`

dub .\hello.d
C:\Users\xxx\AppData\Local\Temp.dub\build\vibe-d:utils-0.8.1: The directory name is invalid.


Packages get placed by Dub in the following locations:

C:\Users\xxx\AppData\Local*lxss\home\xxx*.dub\packages\vibe-d-0.8.1
C:\Users\xxx\AppData*Roaming*\dub\packages\vibe-d-0.8.1\


DMD32 D Compiler v2.074.1
DUB version 1.3.0, built on May 31 2017


Attempt 2:

DMD32 D Compiler v2.075.1
DUB version 1.4.1, built on Aug 10 2017

Correct locations this time!

But error:

Error: linker exited with status 1
dmd failed with exit code 1.

Unexpected OPTLINK Termination at EIP=0040F60A
EAX=03880000 EBX=00438C70 ECX=00000A7A EDX=000002BF
ESI=0000011C EDI=03881618 EBP=0019FF38 ESP=0019FEF0
First=00402000

@PetarKirov
Copy link
Contributor

The problem with Dub 1.3.0 has already been fixed, see dlang/dub#1130

I believe the OptLink issue is a new one. There two things you could try:

  1. Use newer Dub with an older version of dmd, just to verify if it's a compiler regression.
  2. If you have Visual Studio installed, you could try their linker, by building with vibe.d in sub configuration win32_mscoff, which was recently fixed, see: Doesn't build on Windows with --build=x86_mscoff #1771

@PetarKirov
Copy link
Contributor

PetarKirov commented Sep 1, 2017

I must point out that it's really strange that vibe.d doesn't work on Windows for you, as it's tested on AppVeyor with various compilers and all tests pass, see: https://ci.appveyor.com/project/s-ludwig/vibe-d/branch/master

@s-ludwig
Copy link
Member

s-ludwig commented Sep 1, 2017

Windows tends to be tricky. Sometimes it works and sometimes it fails either in Optlink or in DMD's COFF code for no apparent reason (e.g. just an additional plain function call that is used elsewhere in a similar fashion). If DigitalMars/optlink#20 were addressed, that would at least make it more realistic to get a reduced test case for OMF.

@Wulfklaue
Copy link
Author

I must point out that it's really strange that vibe.d doesn't work on Windows for you, as it's tested on AppVeyor with various compilers and all tests pass, see: https://ci.appveyor.com/project/s-ludwig/vibe-d/branch/master

What can i say... I must be special :-)


Another interesting issue, when trying a different compiler:
dub --compiler=ldc2 .\hello.d
Failed to find a package named '.\hello.d'.

So for some reason it can only read the default sample with the included dub configuration. The moment i use argumentation, it wants the package name.


DMD32 D Compiler v2.074.1 ( everything 2.074.1 except custom 1.4.1 dub )
DUB version 1.4.1, built on Aug 10 2017
LDC removed so no conflicts can happen.

Path OK
Massive error chain related to the Optlink ....

OPTLINK (R) for Win32 Release 8.00.17
Copyright (C) Digital Mars 1989-2013 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
C:\Users\xxx\AppData\Local\Temp.dub\build\vibe-d-0.8.1\library-debug-windows-x86-dmd_2074-EB7F69965202A28B7DC375BF8077D122\vibe-d_mongodb.lib(connection)
Error 42: Symbol Undefined _D4vibe4data4bson12BsonObjectID8generateFNfxS3std8datetime7SysTimeZS4vibe4data4bson12BsonObjectID
C:\Users\xxx\AppData\Local\Temp.dub\build\vibe-d-0.8.1\library-debug-windows-x86-dmd_2074-DBDB3D8753C34C26266FFDDF47A3F883\vibe-d_data.lib(bson)
Error 42: Symbol Undefined _D3std8datetime7sys³S¨T·6__ctorMFNbNcNfxSÇì«4Çäë4DÔyCÇìÖ8Òzone8Çä┼ZÇâëZÇÄ║ÇÉÞ
....

Error: linker exited with status 16
dmd failed with exit code 16.


Tonight i will test a normal dub package instead of this include design.

@s-ludwig
Copy link
Member

s-ludwig commented Sep 1, 2017

dub --compiler=ldc2 .\hello.d
Failed to find a package named '.\hello.d'.

The dub *.d [args...] syntax is a special case syntax that exists mainly for shebang style scripts. When using the regular syntax, --single is needed: dub --compiler=ldx2 --single hello.d

C:\Users\xxx\AppData\Local\Temp.dub\build\vibe-d-0.8.1\library-debug-windows-x86-dmd_2074-EB7F69965202A28B7DC375BF8077D122\vibe-d_mongodb.lib(connection)
Error 42: Symbol Undefined

Can you try to run dub clean --all-packages and retry? It could be that there are intermediate build files compiled with DMD 2.074.0 that get reused. Unfortunately DUB cannot detect changes in the patch version, but there may still be some ABI differences between patch releases.

BTW, I'm able to reproduce the Optlink crash and will try to get a reduced case and/or workaround.

@Wulfklaue
Copy link
Author

using the regular syntax, --single

Did not know this syntax. Thanks, that is very helpful.

Can you try to run dub clean --all-packages

Tried it. Unfortunately the same errors as before.

Attempt 2: I just tried the exact same dub/dmd/etc version with a standard dub.json and vibe.d worked perfectly. So somehow the issue seems to be linked to the shebang style.

@Wulfklaue
Copy link
Author

Wulfklaue commented Sep 4, 2017

New tests at my work PC:


DMD32 D Compiler v2.075.1
DUB version 1.5.0, built on Sep 1 2017

OPTLINK: Crash


DMD32 D Compiler v2.076.0
DUB version 1.5.0, built on Sep 1 2017

OPTLINK: Same crash as before.


DMD32 D Compiler v2.074.1
DUB version 1.5.0, built on Sep 1 2017

Ok


Something got introduced in DMD after 2.0.74.1 ( so 2.0.75+ ) that produces these crashes. I hope this can help to backtrace the issue. Its not solve in the 2.0.76 release, that i can confirm with 100%.

@s-ludwig
Copy link
Member

s-ludwig commented Sep 4, 2017

This is good news, as it means we may get a DMD/Optlink fix soon. I'm currently still in the process of reducing one of the Optlink crashes that I get (Dustmite is already running for two days on an i5-6600k). Once that is done, I can start another run with the other crash (if I remember right that was the one from here). Then there is also a COFF issue when using x86_mscoff/x86_64 within VisualD...

@egbertn
Copy link

egbertn commented Jun 17, 2018

It's 17-6-2018 and I also get this exception, exactly the same.
Running DMD v2.080.1 and the default sample after doing dub init [project] vibe.d

@restenb
Copy link

restenb commented Jul 6, 2018

Yep, same issue here. I went back and tried several earlier releases of DMD (all the way back to 2.073.0), same issue while linking on all on them.

Is there a functioning workaround to be able to use vibe at this time? The newest DMD version also fails during build due to a different issue ...

@egbertn
Copy link

egbertn commented Jul 6, 2018

The only workaround I saw, is using Bash on Ubuntu on Windows 10 and I upgraded to 18.04. There the link crash won't occur.

@restenb
Copy link

restenb commented Jul 9, 2018

I found that building in release mode with dub --build=release somehow bypasses this issue.

@M-Ody
Copy link

M-Ody commented Sep 4, 2018

I have the same error. Tested on DMD32 v2.074.1 with DUB1.5.0 and the error is there too. Tested with the last DMD32 2.082.0 to no avail.
Unfortunately I can't give up on Windows for this project, so I'll need to stick to C# for some more time.
__
Although adding --build=release would work, you can't debug the code. That's not a solution.

@wozniakty
Copy link

This is still a problem that basically prevents me from demoing a vibe.d service example...

@leonardoce
Copy link

I stumbled on the same exact issue with optlink on Windows, but I'd like to let you know that the example works in release mode like previously said:

C> dub --build=release
[...]
Running .\prova.exe
[main(----) INF] Listening for requests on http://[::1]:8080/
[main(----) INF] Listening for requests on http://127.0.0.1:8080/
[main(----) INF] Please open http://127.0.0.1:8080/ in your browser.

And also works in debug mode but using the linker from Visual Studio:

C>dub --arch=x86_mscoff
[...]
[main(----) INF] Listening for requests on http://[::1]:8080/
[main(----) INF] Listening for requests on http://127.0.0.1:8080/
[main(----) INF] Please open http://127.0.0.1:8080/ in your browser.

These are the exact versions I'm currently using:

C>dmd --version
DMD32 D Compiler v2.084.0

Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved written by Walter Bright

C>dub --version
DUB version 1.13.0, built on Jan  2 2019

@M-Ody
Copy link

M-Ody commented Jan 3, 2019

Does it only work in release mode? If so, this is still an issue. The problem arises when I try to debug the application.

@leonardoce
Copy link

It works only in release mode if you use "optlink", and works in release and in debug mode if you use --arch=x86_mscoff.

I also think that this is still an issue.

@wilzbach
Copy link
Member

wilzbach commented Jan 7, 2019

We should just deprecate optlink ... (or at least not make it the default)

@leonardoce
Copy link

If we just deprecate optlink you will be required to install the Visual C development tools in Windows to get vibe.d working.

This is a strong requirement, IMHO, or at least it's a requirement that can take a lot of time to install.

@wilzbach
Copy link
Member

wilzbach commented Jan 8, 2019

If we just deprecate optlink you will be required to install the Visual C development tools in Windows to get vibe.d working.

No DMD ships with lld since 2.079, i.e. it bundles its own linker. No Visual studio required for linking. LDC does the same since a while too.

@leonardoce
Copy link

I didn't know about that. That's great!

I tested it in a clean Windows VM and it works like a charm with --arch=x86_mscoff in debug and in release mode.

That means that optlink can be deprecated.

@M-Ody
Copy link

M-Ody commented Jan 8, 2019

--arch=x86_mscoff solved my problem too.
Vibe is alive on Windows.

@WalterBright
Copy link

The latest oplink should identify as 8.00.17, be 223,260 bytes, and be 1/29/2015.

Also, undefined symbols are not optlink bugs.

@leonardoce
Copy link

The latest oplink should identify as 8.00.17, be 223,260 bytes, and be 1/29/2015.
Also, undefined symbols are not optlink bugs.

There are two different issues in this discussion: the first one regards the undefined symbols, and @Wulfklaue may have already have resolved it.

The one I'm referring to is the one with the following error from Optlink:

Unexpected OPTLINK Termination at EIP=0040F60A
EAX=03880000 EBX=00438C70 ECX=00000A7A EDX=000002BF
ESI=0000011C EDI=03881618 EBP=0019FF38 ESP=0019FEF0
First=00402000

I can reproduce this bug with the Optlink distributed with DMD 2.084.0, which is OptLink 8.00.17 and its size is 230,472 bytes.

Nevertheless, using --arch=x86_mscoff, vibe.d works correctly even in Windows.

@WalterBright
Copy link

Please send me an email and I'll send you the optlink I have. Also, optlink errors need to be reported in bugzilla.

@leonardoce
Copy link

Thank you @WalterBright for your help, I'm writing you and I'll report how it goes with the optlink you will send me.
In the meantime, I think we already have a bugzilla entry for exactly the same OptLink bug.

@bausshf
Copy link

bausshf commented Jan 17, 2019

If we just deprecate optlink you will be required to install the Visual C development tools in Windows to get vibe.d working.

No DMD ships with lld since 2.079, i.e. it bundles its own linker. No Visual studio required for linking. LDC does the same since a while too.

I had no idea about this.

Glad I know that now so I can uninstall Visual Studio :)

@PetarKirov
Copy link
Contributor

Glad I know that now so I can uninstall Visual Studio :)

I would not advice you to do this yet, but you can look forward to it ;)

@bausshf
Copy link

bausshf commented Jan 17, 2019

Glad I know that now so I can uninstall Visual Studio :)

I would not advice you to do this yet, but you can look forward to it ;)

Someone please ping me when I can do so then since I literally only installed VS for linking.

@Geod24
Copy link
Contributor

Geod24 commented Jun 24, 2021

This was an optlink bug, and I believe the changes to use link.exe have fixed this (as in, better UX). Closing as there's nothing on Vibe.d's side to do.

@Geod24 Geod24 closed this as completed Jun 24, 2021
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