marxin / cvise

Super-parallel Python port of the C-Reduce
Other
240 stars 25 forks source link

Windows support #17

Open JVApen opened 4 years ago

JVApen commented 4 years ago

Trying to compile this on Windows (Visual Studio 2019) doesn't work. I use the following to configure my CMake:

set CC="C:\Program Files\VisualStudio\Vs2019\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64\cl.exe"
set CXX="C:\Program Files\VisualStudio\Vs2019\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64\cl.exe"
set LLVM_DIR=LLVM_BUILD\lib\cmake\llvm
set CLANG_DIR=LLVM_BUILD\lib\cmake\clang
C:\Program Files\VisualStudio\Vs2019\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -G "Visual Studio 16 2019"  -A x64 -Thost=x64  ..\cvise-master

cl : command line error D8021: invalid numeric argument '/Werror' [build\clang_delta\clang_delta.vcxproj]

After removing this flag from source/CMakeLists.txt (line 144-145), an actual build gets started.

Later we get other errors, like:

source\clang_delta\ExpressionDetector.cpp : fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj [build\clang_delta\clang_delta.vcxproj]
cl : command line error D8021: invalid numeric argument '/Wno-unused-function' [build\clex\clex.vcxproj]
cl : command line error D8021: invalid numeric argument '/Wno-unused-function' [build\clex\strlex.vcxproj]

These last 2 warnings are a result of source/clex/CMakeLists.txt

I also encountered some issues with the .l files, however, this could be linked to older hacks I've added to our lexer. (I did have to add %option nounistd to the options).

With these changes, I got the C++ code compiling. Can we get some native windows support instead?

Note: Compile times take long with a lot of warnings. (Over 14 minutes on 1 file)

marxin commented 4 years ago

Thank you for testing build on Windows! I'm seeking for somebody who can help me with that. I fixed the 2 errors you mentioned and I'm curious about compiler warning you see right now? What do you mean by native windows support? A prebuilt installer?

Yes, the clang_delta compilation takes quite some time, LLVM is a huge project.

JVApen commented 4 years ago

Hey Marnix, I'm so glad you made this fork, I've been doing these reductions by hand the last few years. Python is a bit easier to hack than perl to work around some restrictions.

Native windows support for me a gradient, with following elements:

I still haven't managed to get things completely working. However, I made some progress already. Current issues I'm having: unifdef can't be found. So I currently disabled the reductions that relied on that, and am trying to get a simple reduction working.

I saw unifdef is part of CReduce as C or C++ compiled to an exe, here I found a python script. Is that a replacement for that C/C++ code? If so, on windows, those things don't become executable by default. So than I might have to check if it's possible to wrap this in a .cmd file that launches python with that script.

marxin commented 4 years ago

Hey Marnix, I'm so glad you made this fork, I've been doing these reductions by hand the last few years. Python is a bit easier to hack than perl to work around some restrictions.

Yes, I like Python and I hope it's accessible also for other developers.

Native windows support for me a gradient, with following elements:

  • Compile from source results in a build that is directly runnable
  • Have actual tests/CI running on windows
  • Have pre-build executables (I don't like installers, a .zip is good enough)

Good. I think the best would be to start with https://www.appveyor.com/. I know godot uses that where the syntax is quite close to Travis CIL https://github.com/godotengine/godot/blob/master/.appveyor.yml

I still haven't managed to get things completely working. However, I made some progress already. Current issues I'm having: unifdef can't be found. So I currently disabled the reductions that relied on that, and am trying to get a simple reduction working.

I've just pushed a commit that skips passes that don't have prerequisites.

I saw unifdef is part of CReduce as C or C++ compiled to an exe, here I found a python script. Is that a replacement for that C/C++ code?

Right, CReduce contains the project. I didn't want to bundle all tools that are part of a standard distribution.

If so, on windows, those things don't become executable by default. So than I might have to check if it's possible to wrap this in a .cmd file that launches python with that script.

It's really missing, but there are instructions about how to build it on Windows: https://dotat.at/prog/unifdef/

JVApen commented 4 years ago

Thanks for the update, I'll download new source code (can't checkout from git). Unifdef doesn't have instructions for visual studio not has CMake, that's annoying.

From an error point of view, the warning could explain what the missing dependency is

marxin commented 4 years ago

Thanks for the update, I'll download new source code (can't checkout from git). Unifdef doesn't have instructions for visual studio not has CMake, that's annoying.

I see. If it's the last remaining blocker I tend to bundle it (it's small). About the other dependencies: how do you install things like clang-devel, llvm-devel, cmake and flex? I can experiment with AppVeyor then..

From an error point of view, the warning could explain what the missing dependency is

marxin commented 4 years ago

@JVApen Have you made a progress, please?

JVApen commented 4 years ago

Not yet, looking at this is an extra evening activity. Haven't had the ability to look further at this.

aytey commented 4 years ago

@JVApen what are you trying to reduce here? Do you have access to a Linux box?

I have successfully reduced multiple, many-MiB TUs, compiled with MSVC, using cvise, but doing it via Wine -- my "interestingness test" simply called cl.exe under wine, and /et voila/.

JVApen commented 4 years ago

I truly wish I had access to Linux or even WSL to try that out. I even have restrictions in downloading packages. To come back to what I want to reduce, bugs (or differences) in clang-cl and cl

JVApen commented 4 years ago

I've started again from trunk 1.3 trying to get it compiling again. With MSVC, I seem to be needing /bigobj, beside that, everything seems to build from scratch.

The newly added delta does give some of the previous issues:

All .l files still needed the %option nounistd

Time to try it out

aytey commented 4 years ago

Awesome news you have it building on Windows!!!

JVApen commented 4 years ago

Yeah, now I'm trying it out, thanks to a new dependency, I now have to find a way to hack in psutil without the ability to install it. That's gonna be for later.

aytey commented 4 years ago

For psutil, and if you're restricted in what you can download/install, I would git clone the psutil repo, run python setup.py build and then manually set PYTHONPATH to use the build folder.

JVApen commented 4 years ago

Thanks, I was updating the PATH variable, not the PYTHONPATH variable. That got things working :)

Some new improvements, following snippet doesn't work in batch:

  DIR=`mktemp -d`
  cp c:\path\to\t.cpp $DIR
  cd $DIR
  C:\Path\to\checkSuccess.bat c:\path\to\t.cpp
  echo $?

What I changed it to, based on https://stackoverflow.com/a/32109191/2466431

@echo off
setlocal EnableExtensions

:uniqLoop
set "DIR=%tmp%\cvise~%RANDOM%.tmp"
if exist "%DIR%" goto :uniqLoop
mkdir %DIR%
copy c:\path\to\t.cpp %DIR%
cd /D %DIR%
call C:\Path\to\checkSuccess.bat t.cpp
echo %errorlevel%
JVApen commented 4 years ago

Thanks for the update, I'll download new source code (can't checkout from git). Unifdef doesn't have instructions for visual studio not has CMake, that's annoying.

I see. If it's the last remaining blocker I tend to bundle it (it's small). About the other dependencies: how do you install things like clang-devel, llvm-devel, cmake and flex? I can experiment with AppVeyor then..

From an error point of view, the warning could explain what the missing dependency is

To reply on the installation things:

So, I'm basically doing those things from source, however, they all have some support for MSVC