mcsema icon indicating copy to clipboard operation
mcsema copied to clipboard

Please add a Windows workflow

Open TheGreatRambler opened this issue 3 years ago • 13 comments

I've tried for the life of me to compile Mcsema on my computer but my instance of Msys2 conflicts with it at every turn. It would be immensely helpful if there was a github workflow for this. Thank you

TheGreatRambler avatar Oct 15 '20 00:10 TheGreatRambler

Would you mind giving the Zig compiler a go and reporting your progress here? My understanding is that it can cross-compile c/c++ codebases.

pgoodman avatar Oct 15 '20 00:10 pgoodman

Is it possible to compile Mcsema with Mingw, on the other hand? I tried but faced a few errors that seem like Visual Studio specific compiler features.

TheGreatRambler avatar Oct 15 '20 02:10 TheGreatRambler

We will not be supporting mingw. I believe that Microsoft has improved with Clang support. Otherwise I would strongly advise trying Zig.

pgoodman avatar Oct 15 '20 02:10 pgoodman

Just for information:

The Zig C compiler can compile:

  • From Linux to MinGW
  • From Windows to MSVC (except for windows.h)

The Zig C++ compiler can only compile natively: Linux to Linux, Msys2 to MinGW, Windows to MSVC. This is something to do with C++'s ABI being unstable? I don't know the full story.

Zig C is just a wrapper around clang. Zig C++ is just a wrapper around clang++.

I'm willing to attempt to compile mcsema via Zig tomorrow if it's easy to make it try zig c++.

s5bug avatar Oct 15 '20 06:10 s5bug

Hi! Clang and Visual Studio also now support each other enough that it looks like (at least via some Googling) that you can use clang to build Windows binaries on Linux, assuming you have the requisite Windows libraries available.

See: https://stackoverflow.com/a/46246724 and https://gist.github.com/HiImJulien/3eb47d7d874fe5483810bd77940e74c0 (this one uses WSL2, but same technique should apply to native linux)

artemdinaburg avatar Oct 15 '20 06:10 artemdinaburg

hey @sorenbug and @TheGreatRambler can you email me at [email protected]?

I'd like to help solve Windows support and, ideally, also fix other building and packaging issues with mcsema.

artemdinaburg avatar Oct 16 '20 19:10 artemdinaburg

I remembered Docker is a thing and got it up and running on my Windows machine and it appears to work fine with the Mcsema Docker package. I just have this error on startup:

F20201116 22:09:31.365717     6 CFG.cpp:460] Check failed: cfg.ParseFromCodedStream(&cstream) Unable to read module from CFG file games/smm2/config.cfg
*** Check failure stack trace: ***
    @           0x9ed4ec  google::LogMessageFatal::~LogMessageFatal()
    @           0x5dd335  mcsema::ReadProtoBuf()
    @           0x60e306  main
    @     0x7fd9f4a360b3  __libc_start_main
    @           0x5bfaee  _start
Aborted

My config is only 192 megabytes and was generated on a Windows machine. The maximum size appears to be 512 megabytes and I'm well below that.

TheGreatRambler avatar Nov 16 '20 22:11 TheGreatRambler

Any possible fixes on this?

TheGreatRambler avatar Jan 19 '21 04:01 TheGreatRambler

@ekilmer any sense on if the vcpkg migration enables Windows builds?

pgoodman avatar Jan 19 '21 23:01 pgoodman

Windows build should hopefully be easier now, since vcpkg supports it, but I haven't gotten around to testing yet.

XED might need some changes at least for the build process.

I might have time at the end of the week to test on windows

ekilmer avatar Jan 20 '21 00:01 ekilmer

I realized I was creating a config on an earlier version of Mcsema and fixed that, but I'm still getting an error, just a new additional one:

[libprotobuf ERROR /cxx-common/sources/protobuf-2.6.1/src/google/protobuf/message_lite.cc:123] Can't parse message of type "mcsema.Module" because it is missing required fields: name
F20210120 03:42:17.872046     7 CFG.cpp:460] Check failed: cfg.ParseFromCodedStream(&cstream) Unable to read module from CFG file games/smm2/config.cfg
*** Check failure stack trace: ***
    @           0x9ed4ec  google::LogMessageFatal::~LogMessageFatal()
    @           0x5dd335  mcsema::ReadProtoBuf()
    @           0x60e306  main
    @     0x7f48d39640b3  __libc_start_main
    @           0x5bfaee  _start
Aborted

TheGreatRambler avatar Jan 20 '21 03:01 TheGreatRambler

Nevermind, I was stupid and dumb. Somehow the config was zero width. It now appears to be working well. Will update if it generated a LLVM file or not.

TheGreatRambler avatar Jan 20 '21 03:01 TheGreatRambler

Good news! I've been able to build remill on Windows using vcpkg and cxx-common. See this work-in-progress PR for some rough instructions https://github.com/trailofbits/cxx-common/pull/677

I know there's at least one error with anvill trying to use which command to detect Python, and that doesn't work on Windows. I'm sure there are some other gotchas as well. I'll take a look at them later.

ekilmer avatar Jan 23 '21 21:01 ekilmer