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

Windows support #17

Open
JVApen opened this issue Apr 29, 2020 · 15 comments
Open

Windows support #17

JVApen opened this issue Apr 29, 2020 · 15 comments

Comments

@JVApen
Copy link

JVApen commented Apr 29, 2020

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 marxin closed this as completed in 44cd630 Apr 29, 2020
@marxin marxin reopened this Apr 29, 2020
@marxin
Copy link
Owner

marxin commented Apr 29, 2020

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
Copy link
Author

JVApen commented Apr 30, 2020

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:

  • 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)

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
Copy link
Owner

marxin commented Apr 30, 2020

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
Copy link
Author

JVApen commented Apr 30, 2020

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
Copy link
Owner

marxin commented Apr 30, 2020

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
Copy link
Owner

marxin commented May 7, 2020

@JVApen Have you made a progress, please?

@JVApen
Copy link
Author

JVApen commented May 8, 2020

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

@aytey
Copy link
Contributor

aytey commented May 18, 2020

@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
Copy link
Author

JVApen commented May 23, 2020

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
Copy link
Author

JVApen commented May 23, 2020

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:

  • -Wno-unused-function -Wno-unused-parameter doesn't work for MSVC.

All .l files still needed the %option nounistd

Time to try it out

@aytey
Copy link
Contributor

aytey commented May 23, 2020

Awesome news you have it building on Windows!!!

@JVApen
Copy link
Author

JVApen commented May 23, 2020

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
Copy link
Contributor

aytey commented May 23, 2020

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
Copy link
Author

JVApen commented May 24, 2020

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
Copy link
Author

JVApen commented May 24, 2020

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:

  • CMake comes bundled with Visual Studio, so is available.
  • Clang and LLVM build (I have downloaded the code) via CMake using the visual studio compiler.
  • WinFlexBison provides flex via a visual studio solution https://github.com/lexxmark/winflexbison

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

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

3 participants