DannyArends / DaNode

Small and flexible web server written using the D 2.0 language
https://www.dannyarends.nl
GNU General Public License v3.0
61 stars 2 forks source link

"dub build" doesn't compile - dmd failed with exit code 1. #16

Closed AntonOks closed 3 years ago

AntonOks commented 3 years ago

@DannyArends

λ cd .\Temp\Git\ ​C:\Temp\Git

λ git clone https://github.com/DannyArends/DaNode.git Cloning into 'DaNode'... remote: Enumerating objects: 35, done. remote: Counting objects: 100% (35/35), done. remote: Compressing objects: 100% (24/24), done. Rremote: Total 2006 (delta 17), reused 24 (delta 11), pack-reused 1971eceiving objects: 99% (1986/2006) Receiving objects: 100% (2006/2006), 419.11 KiB | 1.15 MiB/s, done. Resolving deltas: 100% (1356/1356), done.

λ cd DaNode ​C:\Temp\Git\DaNode [master ≡]

λ dub build Performing "debug" build using dmd for x86_64. danode ~master: building configuration "default"... danode\cgi.d(110,58): Error: template std.math.fmin cannot deduce function from argument types !()(long, ulong), candidates are: C:\Users\me\scoop\apps\dmd\current\windows\bin....\src\phobos\std\math.d(7267,3): fmin(F)(const F x, const F y) with F = ulong must satisfy the following constraint: traits(isFloating, F) danode\filesystem.d(118,76): Error: template std.math.fmin cannot deduce function from argument types !()(long, ulong), candidates are: C:\Users\me\scoop\apps\dmd\current\windows\bin....\src\phobos\std\math.d(7267,3): fmin(F)(const F x, const F y) with F = ulong must satisfy the following constraint: traits(isFloating, F) danode\filesystem.d(120,70): Error: template std.math.fmin cannot deduce function from argument types !()(long, ulong), candidates are: C:\Users\me\scoop\apps\dmd\current\windows\bin....\src\phobos\std\math.d(7267,3): fmin(F)(const F x, const F y) with F = ulong must satisfy the following constraint: traits(isFloating, F) danode\payload.d(42,48): Error: template std.math.fmin cannot deduce function from argument types !()(long, ulong), candidates are: C:\Users\me\scoop\apps\dmd\current\windows\bin....\src\phobos\std\math.d(7267,3): fmin(F)(const F x, const F y) with F = ulong must satisfy the following constraint: traits(isFloating, F) dmd failed with exit code 1.


systeminfo - OS Version: 10.0.19042 N/A Build 19042

λ dmd --version DMD32 D Compiler v2.094.2-dirty Copyright (C) 1999-2020 by The D Language Foundation, All Rights Reserved written by Walter Bright

λ dub --version DUB version 1.23.0, built on Nov 20 2020

DannyArends commented 3 years ago

Should be fixed in master now.

The error was due to ulong / long not being implicitly convertible to a floating point type. I was unable to test since dub gave me issues downloading the openssl package. However, the change is minor so it should be ok.

Please let me know if you run into any other issues.

AntonOks commented 3 years ago

wow... this was fast, THANKS, compiles as described in the README 👍

AntonOks commented 3 years ago

hmm... some more things...

  1. as soon as I start the server via ./danode/server -p 8080 my virus scanner (MS Defender) says:

    Detected: Behavior:Win32/DefenseEvasion.UM!ml
    ...
    Details: This program is dangerous and executes commands from an attacker

    and the binary is quarantined!

  2. if I try to compile it with SSL, I get

    λ  dub build --config=ssl
    Performing "debug" build using dmd for x86_64.
    danode ~master: building configuration "ssl"...
    danode\https.d(67,32): Error: function deimos.openssl.ssl.SSL_set_fd(ssl_st* s, int fd) is not callable using argument types (ssl_st*, socket_t)
    danode\https.d(67,32):        cannot pass argument this.socket.handle() of type socket_t to parameter int fd
    dmd failed with exit code 1.

I tweaked the dub.json and also dub.selections.json to reflect the latest Deimos OpenSSL but without success.

Anyhow, thanks 4 now!

DannyArends commented 3 years ago

Yeah I haven't gotten around to using the 2.01 version branch of openssl, just the 1.1.6 branch. A socket should be the file descriptor, it might not auto convert. You could try:

to!(int)(this.socket.handle())

I'll have a look in the morning.

DannyArends commented 3 years ago

Looked into it some more

1) The MS Defender seems to be a false positive, as far as I can tell (my MS defender update 5jan2021 doesn't complain). A solution might be to compile using LDC, which might solve the issue.

2) The openSSL libs from Deimos are woefully out of date, the latest release is 1.1.0h (28Dec2018) which is so old I cannot even find openSSL libraries anymore for MS Windows. The current openSSL version with windows binaries available is 1.1.1i and is structured differently from the 1.1.0 version, it fails to link with 4 missing symbols:

SSLv3_server_method SSL_library_init OPENSSL_add_all_algorithms_noconf SSL_load_error_strings

To circumvent this I've pushed a fix to the master branch (based on @CyberShow his work on AE (https://github.com/CyberShadow/ae)) to link the 1.1.1i library when using windows64

To compile the openSSL version under windows x86_64:

1) Obtain the openssl libraries from e.g. https://slproweb.com/products/Win32OpenSSL.html 2) Update the dub.json file and point the "lflags-windows-x86_64" to where openSSL is installed: "lflags-windows-x86_64": ["/LIBPATH:C:/OpenSSL-Win64/lib"], 3) Cross your fingers and hope the compile and linking goes through

Let me know if it works and if there is anything else I can do for you, and thanks for trying (and posting a bug report on) my home made web server.

Danny

AntonOks commented 3 years ago

Thanks, works like a charm here now. Playtime...

You are my hero of the day, thanks again ;)

DannyArends commented 3 years ago

Perfect ! I'll close the issue (be aware I found a minor bug in the code, so I'll update it soon).