Re: compiler messages

2016-07-11 Thread Tobin Harding
On Mon, Jul 11, 2016 at 06:29:43PM +0200, Andy Wingo wrote:
> On Thu 07 Jul 2016 14:52, Tobin Harding  writes:
> 
> > I have two issues with this patch after developing with a patched Guile for 
> > a
> > week or so. First is that I have not been able to pass command line options 
> > to
> > Guile while using Geiser, my workaround has been setting the variable
> > %quiet-compiler directly with (set! %quiet-compiler #t) from within 
> > ~/.guile.
> 
> I think you can do this.  Customize geiser-guile-binary to be a "guile
> --quiet" or whatever.

I tried that already to no avail, thanks for the idea though.

> 
> > The second, and bigger problem, is that messages are suppressed only for 
> > the file
> > that is directly named in the load statement i.e (load "file.scm"). If 
> > file.scm has any
> > load statements then when these files are loaded/compiled messages are still
> > output.
> 
> This is a blocker unfortunately.  You need to change the C code as well
> (load.c).

I should be able to manage that, thanks for the pointer to the file.

thanks,
Tobin.



MinGW open-process, take N

2016-07-11 Thread Andy Wingo
Hi Eli,

I have reworked Guile a bit in anticipation of your patch and in the end
reworked your patch a bit too.  Please fetch git and see how things are
working for you, first -- it could be I introduced a MinGW bug.  Then
here attached is your patch, reworked.  Let me know how it looks to
you.  If it looks good I'll apply and release in 2.0.12 tomorrow or so.

Regards,

Andy

>From 0ffd406b582dea54ff080f1785eea25a1199c5df Mon Sep 17 00:00:00 2001
From: Eli Zaretskii 
Date: Mon, 11 Jul 2016 22:52:17 +0200
Subject: [PATCH] Add POSIX shims for MinGW

* libguile/posix-w32.h:
* libguile/posix-w32.c (kill, waitpid, getpriority, setpriority)
  (sched_getaffinity, sched_setaffinity): Add MinGW implementations.
  Also, provides macros that on Posix hosts are in sys/wait.h, like
  WIFEXITED and WTERMSIG.
  (start_child): Add implementation.
---
 libguile/posix-w32.c | 864 ++-
 libguile/posix-w32.h |  48 ++-
 libguile/posix.c |   3 +-
 3 files changed, 912 insertions(+), 3 deletions(-)

diff --git a/libguile/posix-w32.c b/libguile/posix-w32.c
index f1251b2..f7df180 100644
--- a/libguile/posix-w32.c
+++ b/libguile/posix-w32.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2008, 2016 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -22,8 +22,12 @@
 
 #include "libguile/__scm.h"
 
+# define WIN32_LEAN_AND_MEAN
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
 
 #include "posix-w32.h"
@@ -144,3 +148,861 @@ uname (struct utsname *uts)
   GetComputerName (uts->nodename, );
   return 0;
 }
+
+/* Run a child process with redirected standard handles, without
+   redirecting standard handles of the parent.  This is required in
+   multithreaded programs, where redirecting a standard handle affects
+   all threads.  */
+
+/* Prepare a possibly redirected file handle to be passed to a child
+   process.  The handle is for the file/device open on file descriptor
+   FD; if FD is invalid, use the null device instead.
+
+   USE_STD non-zero means we have been passed the descriptor used by
+   the parent.
+
+   ACCESS is the Windows access mode for opening the null device.
+
+   Returns the Win32 handle to be passed to CreateProcess.  */
+static HANDLE
+prepare_child_handle (int fd, int use_std, DWORD access)
+{
+  HANDLE htem, hret;
+  DWORD err = 0;
+
+  /* Start with the descriptor, if specified by the caller and valid,
+ otherwise open the null device.  */
+  if (fd < 0)
+htem = INVALID_HANDLE_VALUE;
+  else
+htem = (HANDLE)_get_osfhandle (fd);
+
+  /* Duplicate the handle and make it inheritable.  */
+  if (DuplicateHandle (GetCurrentProcess (),
+  htem,
+  GetCurrentProcess (),
+  ,
+  0,
+  TRUE,
+  DUPLICATE_SAME_ACCESS) == FALSE)
+{
+  /* If the original standard handle was invalid (happens, e.g.,
+in GUI programs), open the null device instead.  */
+  if ((err = GetLastError ()) == ERROR_INVALID_HANDLE
+ && use_std)
+   {
+ htem = CreateFile ("NUL", access,
+FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
+OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (htem != INVALID_HANDLE_VALUE
+ && DuplicateHandle (GetCurrentProcess (),
+ htem,
+ GetCurrentProcess (),
+ ,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS) == FALSE)
+   {
+ err = GetLastError ();
+ CloseHandle (htem);
+ hret = INVALID_HANDLE_VALUE;
+   }
+   }
+}
+
+  if (hret == INVALID_HANDLE_VALUE)
+{
+  switch (err)
+   {
+ case ERROR_NO_MORE_FILES:
+   errno = EMFILE;
+   break;
+ case ERROR_INVALID_HANDLE:
+ default:
+   errno = EBADF;
+   break;
+   }
+}
+
+  return hret;
+}
+
+/* A comparison function for sorting the environment.  */
+static int
+compenv (const void *a1, const void *a2)
+{
+  return stricmp (*((char**)a1), *((char**)a2));
+}
+
+/* Convert the program's 'environ' array to a block of environment
+   variables suitable to be passed to CreateProcess.  This is needed
+   to ensure the child process inherits the up-to-date environment of
+   the parent, including any variables inserted by the parent.  */
+static void
+prepare_envblk (char **envp, char **envblk)
+{
+  char **tmp;
+  int size_needed;
+  int envcnt;
+  char *ptr;
+
+  for (envcnt = 0; envp[envcnt]; envcnt++)
+;
+
+  tmp = scm_calloc ((envcnt + 1) * sizeof 

Re: compiler messages

2016-07-11 Thread Andy Wingo
On Thu 07 Jul 2016 14:52, Tobin Harding  writes:

> I have two issues with this patch after developing with a patched Guile for a
> week or so. First is that I have not been able to pass command line options to
> Guile while using Geiser, my workaround has been setting the variable
> %quiet-compiler directly with (set! %quiet-compiler #t) from within ~/.guile.

I think you can do this.  Customize geiser-guile-binary to be a "guile
--quiet" or whatever.

> The second, and bigger problem, is that messages are suppressed only for the 
> file
> that is directly named in the load statement i.e (load "file.scm"). If 
> file.scm has any
> load statements then when these files are loaded/compiled messages are still
> output.

This is a blocker unfortunately.  You need to change the C code as well
(load.c).

Andy



Re: Support open-process and friends on MS-Windows

2016-07-11 Thread Eli Zaretskii
> From: l...@gnu.org (Ludovic Courtès)
> Cc: m...@netris.org,  wi...@pobox.com,  guile-devel@gnu.org
> Date: Mon, 11 Jul 2016 10:09:47 +0200
> 
> >> >>> Eli Zaretskii  writes:
> >> >>> > +# define getuid()  (500) /* Local Administrator */
> >> >>> > +# define getgid()  (513) /* None */
> >> >>> > +# define setuid(u) (0)
> >> >>> > +# define setgid(g) (0)
> >> 
> >> What about leaving ‘setuid’ and ‘setgid’ undefined, as was the case
> >> until now?
> >
> > I fail to see how this would be better.  It would mean any program
> > that calls these will not work on MS-Windows.  Why should we expect
> > developers of those Guile programs to be aware of the issue and solve
> > it on the Guile Scheme level?  And what solution will they possibly be
> > able to come up with, except not to call these APIs on Windows?
> 
> Our strategy so far has been to (1) either solve the portability issue
> via Gnulib, or (2) do not provide the feature that is unavailable (the
> #ifdef HAVE_ in posix.c et al.)
> 
> It means that application writers have to be aware of the portability
> problems, even if it’s all Scheme.  That sounds reasonable to me.
> 
> WDYT?

I don't think it's wise, and I explained why.  Gnulib in this case is
unlikely to provide any implementation, except one that always fails,
because these operations have no equivalent on MS-Windows.

But if agreeing to remove these two lines will cause the rest of the
patch to be finally admitted, I'm fine with that compromise.

TIA



Re: ‘mktime’ replacement on glibc systems

2016-07-11 Thread Ludovic Courtès
Paul Eggert  skribis:

> On 07/04/2016 09:53 AM, Ludovic Courtès wrote:
>> the conditional does not prevent
>> mktime-internal’s configure snippet from being run.
>>
>> Any idea how to address it?
> Perhaps your bootstrap script is calling gnulib-tool without the
> --conditional-dependencies option? If so, you might try adding it. But
> please see the Gnulib manual's discussion of this option, a discussion
> that uses timegm as its example (I vaguely recall that timegm was the
> motivation for conditional dependencies...):
>
> https://www.gnu.org/software/gnulib/manual/html_node/Conditional-dependencies.html

Indeed, I had overlooked this feature.  Works for us, thank you!

Ludo’.



Re: Support open-process and friends on MS-Windows

2016-07-11 Thread Ludovic Courtès
Eli Zaretskii  skribis:

>> From: l...@gnu.org (Ludovic Courtès)
>> Cc: Eli Zaretskii ,  wi...@pobox.com,  guile-devel@gnu.org
>> Date: Tue, 05 Jul 2016 10:04:23 +0200
>> 
>> Mark H Weaver  skribis:
>> 
>> > Eli Zaretskii  writes:
>> >
>> >>> From: Mark H Weaver 
>> >>> Cc: l...@gnu.org (Ludovic Courtès),  wi...@pobox.com,
>> >>>   guile-devel@gnu.org
>> >>> Date: Sat, 02 Jul 2016 19:02:08 -0400
>> >>> 
>> >>> Eli Zaretskii  writes:
>> >>> > +# define getuid()  (500) /* Local Administrator */
>> >>> > +# define getgid()  (513) /* None */
>> >>> > +# define setuid(u) (0)
>> >>> > +# define setgid(g) (0)
>> 
>> What about leaving ‘setuid’ and ‘setgid’ undefined, as was the case
>> until now?
>
> I fail to see how this would be better.  It would mean any program
> that calls these will not work on MS-Windows.  Why should we expect
> developers of those Guile programs to be aware of the issue and solve
> it on the Guile Scheme level?  And what solution will they possibly be
> able to come up with, except not to call these APIs on Windows?

Our strategy so far has been to (1) either solve the portability issue
via Gnulib, or (2) do not provide the feature that is unavailable (the
#ifdef HAVE_ in posix.c et al.)

It means that application writers have to be aware of the portability
problems, even if it’s all Scheme.  That sounds reasonable to me.

WDYT?

Thanks,
Ludo’.