Re: ghcup failed

2021-06-02 Thread Karel Gardas
On 6/2/21 10:16 PM, Viktor Dukhovni wrote:
> On Wed, Jun 02, 2021 at 07:06:59PM +, Simon Peyton Jones via ghc-devs 
> wrote:
> 
>> "/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/bin/ghc-pkg" --force 
>> --global-package-db 
>> "/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d" update 
>> rts/dist/package.conf.install
>>
>> ghc-pkg: Couldn't open database 
>> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d for 
>> modification: {handle: 
>> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d/package.cache.lock}:
>>  hLock: invalid argument (Invalid argument)
> 
> With WSL2, what sort of filesystem is /home/?  Is a native
> Linux filesystem (ext4, btrfs, ...) over a block device, or is it NTFS
> (either shared with Windows or dedicated for WSL2)?

IIRC

WSL1 is using windows kernel and Linux support is cooked on top of that
somehow -- like linuxator in freebsd or so. Linux syscalls emulated.

WSL2 is using hyper-v and linux kernel, hence is more or less like
normal linux.
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: ghcup failed

2021-06-02 Thread Viktor Dukhovni
On Wed, Jun 02, 2021 at 07:06:59PM +, Simon Peyton Jones via ghc-devs wrote:

> "/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/bin/ghc-pkg" --force 
> --global-package-db 
> "/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d" update 
> rts/dist/package.conf.install
> 
> ghc-pkg: Couldn't open database 
> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d for 
> modification: {handle: 
> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d/package.cache.lock}:
>  hLock: invalid argument (Invalid argument)

With WSL2, what sort of filesystem is /home/?  Is a native
Linux filesystem (ext4, btrfs, ...) over a block device, or is it NTFS
(either shared with Windows or dedicated for WSL2)?

The "hLock" function in GHC.IO.Handle.Lock makes use of a "lockImpl"
handle that on linux typically expects to find working support for the
sane "open file descriptor locking", which avoids historical POSIX lock
breakage by using:

   F_OFD_SETLK
   F_OFD_SETLKW
   F_OFD_GETLK

The supporting is in GHC.IO.Handle.Lock.LinuxOFD.  It appears that

   F_OFD_SETLKW

is failing on WSL2 with EINVAL.  It is not clear whether the issue is
lack of support for F_OFD_SETLKW in the fcntl(2) implementation, or
something about the structure that's passed to acquire the lock:

instance Storable FLock where
sizeOf _ = #{size struct flock}
alignment _ = #{alignment struct flock}
poke ptr x = do
fillBytes ptr 0 (sizeOf x)
#{poke struct flock, l_type}   ptr (l_type x)
#{poke struct flock, l_whence} ptr (l_whence x)
#{poke struct flock, l_start}  ptr (l_start x)
#{poke struct flock, l_len}ptr (l_len x)
#{poke struct flock, l_pid}ptr (l_pid x)
peek ptr =
FLock <$> #{peek struct flock, l_type}   ptr
  <*> #{peek struct flock, l_whence} ptr
  <*> #{peek struct flock, l_start}  ptr
  <*> #{peek struct flock, l_len}ptr
  <*> #{peek struct flock, l_pid}ptr

or perhaps an issue with locking generally for the filesystem in
question.

Whether the lock is per open file or per file object across all its
open instances (POSIX breakage) should not depend on the filesystem
type, so if locking works with F_SETLKW, it should also work with
F_OFD_SETLW, provided the latter is supported at all.

It should be possible to test lock support on WSL2 with a simple
program (source attached), compiled via:

$ make CFLAGS=-D_GNU_SOURCE ofdlock

and executed (with CWD in the relevant filesystem):

$ ./ofdlock ofdlock.dat
Size of struct flock = 32
  l_type ofset = 0
  l_whence ofset = 2
  l_start ofset = 8
  l_len ofset = 16
  l_pid ofset = 24

This should not report any errors, and should return a size and
structure offset values that match the upstream compilation environment.

-- 
Viktor.
#include 
#include 
#include 
#include 

#include 
#include 

int main(int argc, char *argv[])
{
int fd;
struct flock lck;

if (argc < 2)
errx(1, "Usage: %s pathname", argv[0]);

printf("Size of struct flock = %zu\n", sizeof(lck));
printf("  l_type ofset = %zu\n",   (char *)&lck.l_type - (char *)&lck);
printf("  l_whence ofset = %zu\n", (char *)&lck.l_whence - (char *)&lck);
printf("  l_start ofset = %zu\n", (char *)&lck.l_start - (char *)&lck);
printf("  l_len ofset = %zu\n", (char *)&lck.l_len - (char *)&lck);
printf("  l_pid ofset = %zu\n", (char *)&lck.l_pid - (char *)&lck);

if ((fd = open(argv[1], O_WRONLY|O_CREAT, 0666)) < 0)
err(1, "open: %s", argv[1]);

memset((void *)&lck, 0, sizeof(lck));
lck.l_type   = F_WRLCK;
lck.l_whence = SEEK_SET;
if (fcntl(fd, F_OFD_SETLKW, &lck) != 0)
err(1, "fcntl(F_WRLCK): %s", argv[1]);

lck.l_type = F_UNLCK;
if (fcntl(fd, F_OFD_SETLK, &lck) != 0)
err(1, "fcntl(F_UNLCK): %s", argv[1]);
return 0;
}
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


RE: ghcup failed

2021-06-02 Thread Simon Peyton Jones via ghc-devs
Update: Tom Ellis helped me to discover that I probably had not completed my 
WSL1 -> WSL2 changeover on my laptop, so the error I got below came from WSL1.
Once we’d unravelled that, the error went away.  So it seems that WSL1 is to 
blame, not ghcup, happily.
I wonder if someone might add to this page https://www.haskell.org/ghcup/

  *   a prominent notice saying “Does not work with WLS1”,
  *   explaining how to find out how to know what version you are running (wsl 
-l -v in Powershell)
  *   pointing to the instructions for upgrading to WSL2 
https://docs.microsoft.com/en-us/windows/wsl/install-win10
Thanks
Simon

From: ghc-devs  On Behalf Of Simon Peyton Jones 
via ghc-devs
Sent: 02 June 2021 20:07
To: GHC 
Cc: Julian Ospald 
Subject: ghcup failed

Dear devs
I wanted to install GHC 8.10 on my WSL2 (Windows Subsystem for Linux) computer. 
 So I went here
https://www.haskell.org/ghcup/
and followed the instructions (the curl … command).  There was a long pause then

[ Info  ] verifying digest of: ghc-8.10.4-x86_64-deb9-linux.tar.xz

[ Info  ] Unpacking: ghc-8.10.4-x86_64-deb9-linux.tar.xz to /tmp/ghcup-khiegA

[ Info  ] Installing GHC (this may take a while)

[ Error ] BuildFailed failed in dir "/tmp/ghcup-khiegA": NonZeroExit 2 "make" 
["install"]

Check the logs at "/home/simonpj/.ghcup/logs" and the build directory 
"/tmp/ghcup-khiegA" for more clues.

Make sure to clean up "/tmp/ghcup-khiegA" afterwards.

"_eghcup --cache install ghc recommended" failed!
I looked in the logs as suggested, and found this in the tail of ghc-make.log

Installing library in 
/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/libiserv-8.10.4

"utils/ghc-cabal/dist-install/build/tmp/ghc-cabal-bindist" copy compiler stage2 
"strip" '' '/home/simonpj/.ghcup/ghc/8.10.4' 
'/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4' 
'/home/simonpj/.ghcup/ghc/8.10.4/share/doc/ghc-8.10.4/html/libraries' 'v p dyn'

Installing library in /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/ghc-8.10.4

"/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/bin/ghc-pkg" --force 
--global-package-db 
"/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d" update 
rts/dist/package.conf.install

ghc-pkg: Couldn't open database 
/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d for modification: 
{handle: 
/home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d/package.cache.lock}:
 hLock: invalid argument (Invalid argument)

ghc.mk:967: recipe for target 'install_packages' failed

make[1]: *** [install_packages] Error 1

Makefile:51: recipe for target 'install' failed

make: *** [install] Error 2
So I seem to be stuck.  Any ideas?  I feel embarrassed not to be able to 
install GHC 😊.
Simon
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


Re: ghcup failed

2021-06-02 Thread Tom Ellis
On Wed, Jun 02, 2021 at 07:06:59PM +, Simon Peyton Jones via ghc-devs wrote:
> Dear devs
> I wanted to install GHC 8.10 on my WSL2 (Windows Subsystem for Linux) 
> computer.
[...]
> ghc-pkg: Couldn't open database 
> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d for 
> modification: {handle: 
> /home/simonpj/.ghcup/ghc/8.10.4/lib/ghc-8.10.4/package.conf.d/package.cache.lock}:
>  hLock: invalid argument (Invalid argument)

Turns out it was actually WSL1 and upgrading to WSL2 resolved the
problem.
___
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs