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

Would an additional platform check GHC version for Windows Subsystem for Linux make sense? #28471

Closed
NickSeagull opened this issue Aug 22, 2017 · 10 comments
Labels
0.kind: question Requests for a specific question to be answered 6.topic: haskell 6.topic: windows Running, or buiding, packages on Windows

Comments

@NickSeagull
Copy link

Issue description

Currently, if a user tries to use GHC8+ in WSL, when using the versions provided by nixpkgs or by Stackage, it simply fails on compile anything as it tried to allocate more memory than it is able to (1TB+).

This is because GHC 8.0's new block-structured heap for 64-bit platforms. From the GHC 8.0.1 release notes:

We have a shiny new two-step memory allocator for 64-bit platforms (see Trac #9706). In addition to simplifying the runtime system’s implementation this may significantly improve garbage collector performance. Note, however, that Haskell processes will have an apparent virtual memory footprint of a terabyte or so. Don’t worry though, most of this amount is merely mapped but uncommitted address space which is not backed by physical memory.

There is a whole Github thread for discussing this on MS BashOnWindows repo.

Would it make sense for nixpkgs to include a "fixed" version of GHC8, so one is able to run it from WSL?

This is solved easily, as described in this comment:

git clone -b ghc-8.0.2-release --recursive git://git.haskell.org/ghc.git ghc-8.0.2
cd ghc-8.0.2
./boot
./configure --disable-large-address-space #can set --prefix=... here
make -j8 #-j(number-of-threads)
sudo make install

As I can see, it is already being checked for iOS in this file for ghc-8.0.2.

Would it make sense to add another check for WSL here?

Steps to reproduce

Try to compile any project that depends on GHC8+ on WSL.

Technical details

  • System: WSL
$ cat /proc/version
Linux version 4.4.0-43-Microsoft ([email protected]) (gcc version 5.4.0 (GCC) ) #1-Microsoft Wed Dec 31 14:42:53 PST 2014
  • Nix version: nix-env (Nix) 1.11.13
  • Nixpkgs version: "17.09pre112229.e619ace733"
  • Sandboxing enabled: grep: /etc/nix/nix.conf: No such file or directory
@vcunat
Copy link
Member

vcunat commented Aug 26, 2017

/cc @peti.

To me personally, WSL itself doesn't seem worth building all Haskell stuff twice on Hydra, and having --disable-large-address-space for everyone would decrease GC performance by ~8 %. I wonder if this would be a good candidate for some hack replacing the runtime without recompiling, e.g. via pkgs.replaceDependency.

@peti
Copy link
Member

peti commented Aug 26, 2017

I don't understand the technical details behind this request. What is WSL? Is that a separate platform in Nixpkgs? And if so, what is it called?

@vcunat
Copy link
Member

vcunat commented Aug 26, 2017

@peti: it's about the linux-inside-windows situation: https://msdn.microsoft.com/en-us/commandline/wsl/install_guide Using the same linux binaries should usually just work there.

@peti
Copy link
Member

peti commented Aug 26, 2017

So it's not a separate platform in Nixpkgs?

@vcunat
Copy link
Member

vcunat commented Aug 26, 2017

Yes, my understanding is that it doesn't need to be a separate platform, in general. (I don't use Windows, so I've never really tried WSL...)

@NickSeagull
Copy link
Author

Yes, a different platform is kinda overkill. The way to currently detect if the user is running Linux or not is by inpecting the /proc/version file and see if it contains the string Microsoft in it.

I was thinking about adding a check for GHC8+

@peti peti added the 0.kind: question Requests for a specific question to be answered label Aug 26, 2017
@peti
Copy link
Member

peti commented Aug 26, 2017

I think it would be feasible to add a boolean argument to the GHC Nix expression that enables/disables use of large-address-space at compile-time so that people who want that can override the default choice easily. Disabling it for all of Linux by default doesn't sound like a good idea to me.

@NickSeagull, does this answer your question?

@NickSeagull
Copy link
Author

Definitely, disabling it for all of Linux is not feasible at all.

The situation that I'm thinking of is:

  • User wants to create package A which depends on package B
  • The package B depends on GHC8+, but its author didnt enable the large-address-space flag.

How the user would proceed on enabling that flag, and furthermore, could they dynamicly enable it in their default.nix file? I think it would be interesting if the check was automatic @peti

@peti
Copy link
Member

peti commented Aug 29, 2017

I think you'll find that https://nixos.org/nixpkgs/manual/#sec-overrides and https://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure provide a wealth of information towards that end. If you have any specific questions, then it's probably best to ask on the nix-devel mailing list or -- even better -- in the #nixos IRC channel. The bug tracker seems like it's the wrong place for that kind of conversation.

@peti peti closed this as completed Aug 29, 2017
@NickSeagull
Copy link
Author

In case someone comes from Google looking for a working version of GHC for WSL, I've created a repository with overrides for different packages that are meant to be "patched" somehow for working properly in WSL. https://github.com/NickSeagull/wsl-nixpkgs

@Ericson2314 Ericson2314 added 6.topic: windows Running, or buiding, packages on Windows and removed 6.topic: windows Running, or buiding, packages on Windows labels Dec 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question Requests for a specific question to be answered 6.topic: haskell 6.topic: windows Running, or buiding, packages on Windows
Projects
None yet
Development

No branches or pull requests

4 participants