haskell / ThreadScope

A graphical tool for profiling parallel Haskell programs
http://www.haskell.org/haskellwiki/ThreadScope
Other
153 stars 36 forks source link

Threadscope isn't working on Windows #120

Open kamkamkil opened 3 years ago

kamkamkil commented 3 years ago

Trying to sue current version on Windows, when invoking from CLI i don't get any response, neither while using eventlog file nor with ./threadscope.exe --test ch8 Windows version: 21H1 GHC version: 8.10.4 gtk2 version : 2.24.33-2

Mikolaj commented 3 years ago

CI of our latest release

https://github.com/haskell/ThreadScope/actions/runs/473173253

tests 8.10.3 on Windows, but I doubt it's a regression in 8.10.4. Are you able to run any other GTK programs? A GTK demo of some kind? Are you able to run something like strace and ldd to check what libraries are expected and used by the binary and what's at the paths it mentions?

kamkamkil commented 3 years ago

i was able to run gtk-demo, all logger apps i tried wasn't able to test treadscope because it wouldn't run at all.

kamkamkil commented 3 years ago

downgrading to ghc 8.10.4 didn't help

Mikolaj commented 3 years ago

That won't tell us much, but what's the exit code?

https://stackoverflow.com/questions/334879/how-do-i-get-the-application-exit-code-from-a-windows-command-line

kamkamkil commented 3 years ago

if i understand correctly errorlevel is -1073741701

Mikolaj commented 3 years ago

"The error you're seeing usually indicates that a runtime dll can't be found." If so, something akin to ldd would help or generally any Windows tool that tells you the paths of dlls the binary expects. Then check what's on those paths, I guess.

kamkamkil commented 3 years ago

i think that all dependencies :
obraz i used: https://github.com/lucasg/Dependencies

kamkamkil commented 3 years ago

it clearly can't find gtk library, it does have properly set up environment variables, and demo app does work.

Mikolaj commented 3 years ago

As a workaround, can you copy the missing libraries to where the binary is?

BTW, how did you obtain the threadscope binary?

kamkamkil commented 3 years ago

i got all binaries from Releases, putting libgtk in the same folder doesn't help, and i couldn't find other libraries.

Mikolaj commented 3 years ago

I guess, you need to put all that are marked in red on your picture. If searching your whole computer doesn't turn them out, it means your installation of GTK is faulty. Perhaps the demo exercised only one of the libraries.

@maoe: perhaps we could include all libraries in the release zip? Or does GTK require some special configuration on and budling the dlls would not be enough. E.g., here I bundle SDL dlls for my game in AppVeyor CI: https://github.com/LambdaHack/LambdaHack/blob/master/appveyor.yml#L54--L70

Mikolaj commented 3 years ago

@kamkamkil: e.g., perhaps the installer asked you to install or expose libatk via ticking some boxes, but you didn't? It's also possible they somehow changed the paths where they store the libraries vs January when TS was built.

kamkamkil commented 3 years ago

after coping all the libs to folder dependencies showed me that all the right libs are loaded, now i'm getting -1073741511 error. When trying to run exe i get new error: procedure deflatesetheader not found in libgio and inflateReset2 in libpng16-16. those are not found in dependencies.

Mikolaj commented 3 years ago

Perhaps the version of GTK changed since the binary was compiled? Though in principle they should strive to keep backward compatibility. Doh, the logs for CI expired and so I can't find which version was used for the release.

Did you try reinstalling GTK? Can you describe the steps when installing, version, etc? Perhaps somebody can compare against own installation...

kamkamkil commented 3 years ago

I dowlanded gtk from msys using command from readme, i installed and reinstaled it several times.

Mikolaj commented 3 years ago

I see. Apologies. I'm afraid, I'm running out of ideas and it's not easy for me to replicate.

Mikolaj commented 3 years ago

Also, I don't know which version of GTK was used for the release. I guess this can be somehow read from the binaries? Or perhaps you, @maoe, remember? Not very likely this is the cause, but maybe worth a try. Recompiling with newest GTK would be another avenue of attack.

kamkamkil commented 3 years ago

Well you done what you could, and I'm grateful. I just installed VM and it is working no problem... I love using libs in windows ...

maoe commented 3 years ago

Sorry for the late response.

@kamkamkil Could you write down your environment (type of shell, content of PATH variable etc), and exact commands you ran to install dependencies and to run threadscope?

maoe commented 3 years ago

@Mikolaj I'm personally not eager to bundle runtime deps like GTK+ because of the reasons explained in https://github.com/haskell/ThreadScope/issues/94#issuecomment-501922782. If someone is willing to watch upstream development and maintain the bundled deps in a timely manner I wouldn't object though.

maoe commented 3 years ago

I don't have access to my computer right now so I can't do much help but according to the screeshot in https://github.com/haskell/ThreadScope/issues/120#issuecomment-860805056, GTK+ related libraries seem to come from gnuplot, which looks strange.

The binary releases depend on GTK+ from mingw-w64 installed by msys2.

Mikolaj commented 3 years ago

@Mikolaj I'm personally not eager to bundle runtime deps like GTK+ because of the reasons explained in #94 (comment). If someone is willing to watch upstream development and maintain the bundled deps in a timely manner I wouldn't object though.

How about doing it they way in the link I provided, in CI? Do the libraries we need to include vary often? I know the transitive closure may cause problems, but at least the libraries we directly need are fixed and few, aren't they? Statically linking would be even better, because it automatically takes care of the indirect dependencies.

maoe commented 3 years ago

Do the libraries we need to include vary often?

I have no idea. GTK+ is a big project which consists of many sub-projects and I'm not watching every development nor MSYS2 packaging cycles.

I know the transitive closure may cause problems, but at least the libraries we directly need are fixed and few, aren't they?

Yeah direct dependencies are fixed and not many. I think the removal of gtk-mac-integration was the last big change. Though I wouldn't be surprised if there were some upstream changes in the deps including transitive ones.

Statically linking would be even better, because it automatically takes care of the indirect dependencies.

I agree that static linking is better than manually listed dependencies.

I wonder if for Windows it's better to use the WSL 2, which seems to support GUI now. Unfortunately I'm not a Windows user. If someone has experience with WSL 2, please give threadscope a try in it and let us know how it works.

kamkamkil commented 3 years ago

about my environment: i tested with both powershell ver 5, also cmd, and tried with gui. My PATH is quite lenghty : C:\Program Files\ImageMagick-7.0.11-Q16-HDRI;C:\Perl64\bin;C:\Users\kkedr\AppData\Roaming\ActiveState\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\bin\x64;C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\bin\x86;C:\Python39\Scripts\;C:\Python39\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;C:\Program Files\IVI Foundation\VISA\Win64\Bin\;C:\Program Files (x86)\National Instruments\Shared\LabVIEW CLI;C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;C:\cmake-3.17.1;C:\Program Files\gnuplot\bin;C:\Program Files\dotnet\;C:\MinGW\bin;C:\Program Files\nodejs\;C:\Program Files\PuTTY\;C;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GTK2-Runtime\bin;C:\Users\kkedr\AppData\Roaming\local\bin;C:\Users\kkedr\.cargo\bin;C:\Users\kkedr\anaconda3;C:\Users\kkedr\anaconda3\Library\mingw-w64\bin;C:\Users\kkedr\anaconda3\Library\usr\bin;C:\Users\kkedr\anaconda3\Library\bin;C:\Users\kkedr\anaconda3\Scripts;C:\Users\kkedr\AppData\Local\Microsoft\WindowsApps;C:\Users\kkedr\AppData\Roaming\cabal\bin;C:\Users\kkedr\AppData\Local\Programs\Microsoft VS Code\bin;C:\Exercism;C:\Program Files\nodejs;C:\MinGW\bin;C:\Users\kkedr\AppData\Roaming\npm;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files (x86)\Vim\vim82;C:\Program Files\Codeplay\ComputeCpp\bin;C:\Program Files\Codeplay\ComputeCpp\lib;C:\Users\kkedr\AppData\Local\Programs\MiKTeX\miktex\bin\x64\;C:\Perl64\bin;C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.10.4\bin;C:\Program Files\CMake\bin;C:\Program Files (x86)\Gtk+\bin;C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.10.3\bin; I installed MSYS from installer provided from them, and followed starting instruction. To install GTK i used pacman -S $MINGW_PACKAGE_PREFIX-gtk2 as for README instruction. to run ts i used : .\threadscope.exe .\hellofib.eventlog . To test exit code i used : @echo off threadscope.exe echo Failure Reason Given is %errorlevel% exit /b %errorlevel% and to find what dependencies are used i used :
https://github.com/lucasg/Dependencies i also copied all gtk dll straight to folder.

I wonder if for Windows it's better to use the WSL 2, which seems to support GUI now. Unfortunately I'm not a Windows user. If someone has experience with WSL 2, please give threadscope a try in it and let us know how it works.

About running in wsl 2 gui right now it's only in developer preview , i only have one system at my disposal but i could check it out in short while

kamkamkil commented 3 years ago

@maoe about wsl: it works without any problem, you need to be on windows dev channel but you can interact with windows file system without any problem so you can work on windows and just use threadscope in wsl

maoe commented 3 years ago

Ah that's good to hear. Do you think we should endorse WSL for Windows users?

kamkamkil commented 3 years ago

For now, wsl only support GUI application in windows insider program, which now means that you need to work on beta windows 11, but when GUI support will be officially supported then I would recommend that as a solution.

maoe commented 3 years ago

which now means that you need to work on beta windows 11

I see. I guess we can update the instructions in the README for those who are willing to work with the beta, while keeping the MSYS2 the recommended way.

As for the PATH you posted, there seems to be no mingw64 path at the beginning. Could you try prepending mingw paths before running threadscope?

set PATH=C:\\msys64\\mingw64\\bin;C:\\msys64\\usr\\bin;%PATH%