IoTone / TheShellProject

The Shell Project aims to build a viable general purpose blockchain written in Dlang, with attributes of security, ease of deployment, clear specification, ease of use for DAPPs, and multiple implementation interop
1 stars 1 forks source link

keccak-tiny doesn't build properly on windows #58

Closed truedat101 closed 5 years ago

truedat101 commented 5 years ago

We forked keccak-tiny, and have it here https://github.com/IoTone/keccak-tiny I need to ensure this builds on windows. The simple do.sh file doesn't properly address the question of what kind of library to produce and assumes it's either a mac or linux. So it produces a .dylib or a .so.

Second problem is that what it produces is odd: libkeccak-tiny.lib: PE32+ executable (DLL) (console) x86-64, for MS Windows

Third problem is it is named wrong. Windows is looking for keccak-tiny.lib, not libkeccak-tiny.lib. Deal with this later.

Also read: http://www.mingw.org/wiki/sampleDLL

https://forums.ni.com/t5/LabVIEW/create-a-dll-for-windows-with-gcc/td-p/332736

https://wiki.dlang.org/Win32_DLLs_in_D

truedat101 commented 5 years ago

Related to #56 .

pedroalvesbatista commented 5 years ago

I'm getting this error when running dub test :

Error: Got .copyFiles-windows-x86 of type array, expected string.

truedat101 commented 5 years ago

From what directory? And what is the exact command?

pedroalvesbatista commented 5 years ago

From shelld/prototype

I use dub test

truedat101 commented 5 years ago

What platform? What compiler?

truedat101 commented 5 years ago

This specific issue is related to building on libkeccak on windows. The error you are pointing out is related to the prototype project build.

pedroalvesbatista commented 5 years ago

Yes, just the prototype. I'm using Debian and ldc2

truedat101 commented 5 years ago

Hmm, let me try to build on linux. Shouldn't have this error. Is this your first time trying to build on linux in a few months?

truedat101 commented 5 years ago

I've either been using windows or Mac.

truedat101 commented 5 years ago

Interesting, but I found this version here has been modified in a similar manner (for NIM, and compiles without error). It looks like they've included some macros in the .c file.

https://github.com/status-im/nim-keccak-tiny/tree/fix-c99-ci/keccak-tiny

Examine why this one works, see if I can just swap it out.

pedroalvesbatista commented 5 years ago

Right, will check this out and see if I can give some insight

truedat101 commented 5 years ago

Anyway, won't affect you since yours builds.

truedat101 commented 5 years ago

More helper stuff:

http://www.mingw.org/wiki/sampleDLL http://cygutils.fruitbat.org/dll-stuff/index.html

Anyway, I think I've got it figured out for windows.

truedat101 commented 5 years ago

Ok, got what looks like working code here: https://github.com/IoTone/nim-keccak-tiny. Note, this is a nem version wrapper around the library. We don't need the NEM portion, just the fork with a few tweaks. If this is all working ok, I'll probably merge the code changes from nim-keccak-tiny to the original keccak-tiny fork that I have.

truedat101 commented 5 years ago

I added a fix for checking the platform and choosing the right-ish shared object extension.

truedat101 commented 5 years ago

Just need to fix the dll loading stuff in the libkeccak-d dub.json. Sigh.

truedat101 commented 5 years ago

I notice using clang with the do.sh defaults, it fails. Fix that later.

truedat101 commented 5 years ago

So the windows builds, but I can't link successfully. I need to go back and work through the library generation.

truedat101 commented 5 years ago

I'm being honest here, I feel like nimlang is way more amazing than D.

Here's an example: https://nim-lang.org/docs/backends.html

There is a silly little compiler directive inside of nim code:

{.compile: "keccak_tiny/keccak-tiny.c".}

This is unbelievably special. It's a little macro expansion or pragma thing. It runs this:

gcc -c keccak-tiny.c ar rvs libkeccak-tiny.lib keccak-tiny.o

That by itself is the simple elegance of Nim. Did I have to build the library? No. Did it build by itself? Yes. Does that work for more complex scenarios like an open-cv or something? No, probably not. But still, wow.

truedat101 commented 5 years ago

And I've verified my output is good:

All unit tests have been run successfully.

truedat101 commented 5 years ago

I'm converting the library libkeccak-d to be classified as a library.

truedat101 commented 5 years ago

I've gotta sleep now, but will finish this off tomorrow. Steps left:

truedat101 commented 5 years ago

If this fix works, it should also knock out #66 .

truedat101 commented 5 years ago

Fixed by 5f4f5730717f0038c7a650748f316c25c4c7a358