public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available
@ 2015-07-19 15:14 keith.marshall at mailinator dot com
  2015-07-19 15:44 ` [Bug libfortran/66936] " kargl at gcc dot gnu.org
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-19 15:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

            Bug ID: 66936
           Summary: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the
                    basis that mkstemp() is available
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: keith.marshall at mailinator dot com
  Target Milestone: ---

Created attachment 36013
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36013&action=edit
Kludge to work around issue for mingw32

When building GCC, with FORTRAN language support, for mingw32 with the
mingwrt-3.21+ runtime library from MinGW.org installed, the build fails in
libgfortran/io/unix.c, because the tempfile_open() function gratuitously
assumes that, if HAVE_MKSTEMP is defined, then it must invoke:

  mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);

regardless of whether or not those access mode flags are defined.  Of course,
the assumption is invalid: while S_IXUSR may have some semblance of meaning on
a windows host, and is defined, S_IRWXG and S_IRWXO are meaningless, and are
not.

Now, I can kludge around this, with the attached patch, but I suspect that it
doesn't represent a true solution.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
@ 2015-07-19 15:44 ` kargl at gcc dot gnu.org
  2015-07-19 17:29 ` keith.marshall at mailinator dot com
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-19 15:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Keith Marshall from comment #0)
> Created attachment 36013 [details]
> Kludge to work around issue for mingw32
> 
> When building GCC, with FORTRAN language support, for mingw32 with the
> mingwrt-3.21+ runtime library from MinGW.org installed, the build fails in
> libgfortran/io/unix.c, because the tempfile_open() function gratuitously
> assumes that, if HAVE_MKSTEMP is defined, then it must invoke:
> 
>   mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
> 
> regardless of whether or not those access mode flags are defined.  Of
> course, the assumption is invalid: while S_IXUSR may have some semblance of
> meaning on a windows host, and is defined, S_IRWXG and S_IRWXO are
> meaningless, and are not.
> 
> Now, I can kludge around this, with the attached patch, but I suspect that
> it doesn't represent a true solution.

The name of the language is Fortran.  The language has been called
Fortran since 1988 or so.

The correct fix would be to add test to configure to define
HAVE_S_IRWXG and HAVE_S_IRWXO.  A better fix would be for 
MingW32 to conform to POSIX.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
  2015-07-19 15:44 ` [Bug libfortran/66936] " kargl at gcc dot gnu.org
@ 2015-07-19 17:29 ` keith.marshall at mailinator dot com
  2015-07-19 18:05 ` sgk at troutmask dot apl.washington.edu
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-19 17:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #2 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to kargl from comment #1)
> The name of the language is Fortran.  The language has been called
> Fortran since 1988 or so.

It was always FORTRAN, in the days when I actually used the language, but how
you choose to capitalize it, or not, is completely irrelevant.

> The correct fix would be to add test to configure to define
> HAVE_S_IRWXG and HAVE_S_IRWXO.

Of course it would, but I'm not going to dirty my hands with your autoconf
code; this is your bug, and that is definitively your responsibility.

> A better fix would be for MingW32 to conform to POSIX.

No, it most definitely would not; that is never going to happen.  MinGW is
definitively aimed at Microsoft Windows compatibility.  Windows is not POSIX,
and nor is MinGW; nor will it ever be, nor will it even aspire to be.  S_IRWXG
and S_IRWXO have no place in the windows environment; it would be wrong for
MinGW to define them, (even if an appropriate pseudo-definition were ever
proposed), just as it is wrong for you to assume that availability of mkstemp()
implies that they should be defined.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
  2015-07-19 15:44 ` [Bug libfortran/66936] " kargl at gcc dot gnu.org
  2015-07-19 17:29 ` keith.marshall at mailinator dot com
@ 2015-07-19 18:05 ` sgk at troutmask dot apl.washington.edu
  2015-07-19 18:05 ` kargl at gcc dot gnu.org
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-07-19 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Jul 19, 2015 at 05:29:35PM +0000, keith.marshall at mailinator dot com
wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936
> 
> --- Comment #2 from Keith Marshall <keith.marshall at mailinator dot com> ---
> (In reply to kargl from comment #1)
> > The name of the language is Fortran.  The language has been called
> > Fortran since 1988 or so.
> 
> It was always FORTRAN, in the days when I actually used the language, but how
> you choose to capitalize it, or not, is completely irrelevant.

Ignorance is bliss.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (2 preceding siblings ...)
  2015-07-19 18:05 ` sgk at troutmask dot apl.washington.edu
@ 2015-07-19 18:05 ` kargl at gcc dot gnu.org
  2015-07-19 19:52 ` [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() " kargl at gcc dot gnu.org
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-19 18:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5
           Severity|normal                      |enhancement


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (3 preceding siblings ...)
  2015-07-19 18:05 ` kargl at gcc dot gnu.org
@ 2015-07-19 19:52 ` kargl at gcc dot gnu.org
  2015-07-19 20:50 ` keith.marshall at mailinator dot com
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-19 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|io/unix.c gratuitously uses |io/unix.c gratuitously uses
                   |S_IRWXG and S_IRWXO on the  |S_IRWXG and S_IRWXO on the
                   |basis that mkstemp() is     |basis that umask() is
                   |available                   |available

--- Comment #4 from kargl at gcc dot gnu.org ---
Update title.  The code in question is

#ifdef HAVE_UMASK
  /* Temporarily set the umask such that the file has 0600 permissions.  */
  mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
#endif

MinGW appears to define HAVE_UMASK, but MinGW seems to lack
a correctly written umask(3).


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (4 preceding siblings ...)
  2015-07-19 19:52 ` [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() " kargl at gcc dot gnu.org
@ 2015-07-19 20:50 ` keith.marshall at mailinator dot com
  2015-07-19 21:04 ` keith.marshall at mailinator dot com
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-19 20:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #5 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to kargl from comment #4)
> Update title.  The code in question is
> 
> #ifdef HAVE_UMASK
>   /* Temporarily set the umask such that the file has 0600 permissions.  */
>   mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
> #endif
> 
> MinGW appears to define HAVE_UMASK, but MinGW seems to lack
> a correctly written umask(3).

MinGW inherits its umask() implementation from Microsoft, in the shape of
whatever MSVCRT.DLL provides; (and yes, at one time Microsoft decided to rename
their umask() implementation to _umask(), but MinGW has always mapped those
renames back to their originals, for backwards compatibility). So, the bug is
that you gratuitously assume that any umask() implementation should conform to
POSIX, even when the platform is not POSIX. IF you aim to support non-POSIX
platforms, (as you do with the mingw32 target), you must be prepared to handle
non-POSIX implementations, such as this umask() --> _umask(), which is
documented at https://msdn.microsoft.com/en-us/library/5axxx3be.aspx


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (5 preceding siblings ...)
  2015-07-19 20:50 ` keith.marshall at mailinator dot com
@ 2015-07-19 21:04 ` keith.marshall at mailinator dot com
  2015-07-19 21:42 ` kargl at gcc dot gnu.org
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-19 21:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #6 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to kargl from comment #4)
> Update title.  The code in question is
> 
> #ifdef HAVE_UMASK
>   /* Temporarily set the umask such that the file has 0600 permissions.  */
>   mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
> #endif
> 
> MinGW appears to define HAVE_UMASK, but MinGW seems to lack
> a correctly written umask(3).

Just for the record: MinGW has had access to Microsoft's umask() implementation
for a very long time; HAVE_UMASK has always been defined, when compiling the
mingw32 builds of GCC.  However, this particular block of code is encapsulated
within an outer #ifdef HAVE_MKSTEMP block, and it is only recently that MinGW
has provided an implementation of mkstemp(), (Microsoft do not offer one),
which has caused HAVE_MKSTEMP to become defined, so exposing this (presumably
long-standing) bug.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (6 preceding siblings ...)
  2015-07-19 21:04 ` keith.marshall at mailinator dot com
@ 2015-07-19 21:42 ` kargl at gcc dot gnu.org
  2015-07-19 22:17 ` keith.marshall at mailinator dot com
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-19 21:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #7 from kargl at gcc dot gnu.org ---
(In reply to Keith Marshall from comment #6)
> (In reply to kargl from comment #4)
> > Update title.  The code in question is
> > 
> > #ifdef HAVE_UMASK
> >   /* Temporarily set the umask such that the file has 0600 permissions.  */
> >   mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
> > #endif
> > 
> > MinGW appears to define HAVE_UMASK, but MinGW seems to lack
> > a correctly written umask(3).
> 
> Just for the record: MinGW has had access to Microsoft's umask()
> implementation for a very long time; HAVE_UMASK has always been defined,
> when compiling the mingw32 builds of GCC.  However, this particular block of
> code is encapsulated within an outer #ifdef HAVE_MKSTEMP block, and it is
> only recently that MinGW has provided an implementation of mkstemp(),
> (Microsoft do not offer one), which has caused HAVE_MKSTEMP to become
> defined, so exposing this (presumably long-standing) bug.

So add

#define S_IRWXG 0
#define S_IRWXO 0

to the header file wherever mingw defines the available mask bits
for umask(3).  The bug is clearly in mingw were it gratuitously maps
umask() to _umask() without properly adding the mappings for the
mode_t argument bits of umask(3).


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (7 preceding siblings ...)
  2015-07-19 21:42 ` kargl at gcc dot gnu.org
@ 2015-07-19 22:17 ` keith.marshall at mailinator dot com
  2015-07-20  9:19 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-19 22:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #8 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to kargl from comment #7)
> So add
> 
> #define S_IRWXG 0
> #define S_IRWXO 0
> 
> to the header file wherever mingw defines the available mask bits
> for umask(3).  The bug is clearly in mingw were it gratuitously maps
> umask() to _umask() without properly adding the mappings for the
> mode_t argument bits of umask(3).

Absolutely not!  Those bits are utterly irrelevant for the windows (MinGW)
platform; to add them would be do nothing more than create confusion.  The mask
bits for umask(), on the windows platform are S_IREAD | S_IWRITE; those are the
only mask bits YOUR code should be passing to non-POSIX umask(5axxx3be.aspx).

This is NOT a MinGW bug; it's a GCC bug, and that's where it should be fixed. 
Until you do fix it, I have my work-around, (which I'm perfectly willing to
publish in MinGW forked source for GCC, prominently commented as a ghastly hack
to circumvent a gross upstream GCC bug).


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (8 preceding siblings ...)
  2015-07-19 22:17 ` keith.marshall at mailinator dot com
@ 2015-07-20  9:19 ` pinskia at gcc dot gnu.org
  2015-07-20 15:26 ` keith.marshall at mailinator dot com
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-07-20  9:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Keith Marshall from comment #8)
> (In reply to kargl from comment #7)
> > So add
> > 
> > #define S_IRWXG 0
> > #define S_IRWXO 0
> > 
> > to the header file wherever mingw defines the available mask bits
> > for umask(3).  The bug is clearly in mingw were it gratuitously maps
> > umask() to _umask() without properly adding the mappings for the
> > mode_t argument bits of umask(3).
> 
> Absolutely not!  Those bits are utterly irrelevant for the windows (MinGW)
> platform; to add them would be do nothing more than create confusion.  The
> mask bits for umask(), on the windows platform are S_IREAD | S_IWRITE; those
> are the only mask bits YOUR code should be passing to non-POSIX
> umask(5axxx3be.aspx).
> 
> This is NOT a MinGW bug; it's a GCC bug, and that's where it should be
> fixed.  Until you do fix it, I have my work-around, (which I'm perfectly
> willing to publish in MinGW forked source for GCC, prominently commented as
> a ghastly hack to circumvent a gross upstream GCC bug).


Well it is a libgfortran bug yes.  What we could do add to io/unix.c:
#if MINGW && !defined(S_IRWXG)
#define S_IRWXG 0
#endif
#if MINGW && !defined(S_IRWXO)
#define S_IRWXO 0
#endif

And that will allow it to work correctly.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (9 preceding siblings ...)
  2015-07-20  9:19 ` pinskia at gcc dot gnu.org
@ 2015-07-20 15:26 ` keith.marshall at mailinator dot com
  2015-08-06 16:57 ` fxcoudert at gcc dot gnu.org
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-07-20 15:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #10 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to Andrew Pinski from comment #9)
> Well it is a libgfortran bug yes.

Which, being pedantic, makes it a GCC bug, because libgfortran is a component
of GCC.

>  What we could do add to io/unix.c:
> #if MINGW && !defined(S_IRWXG)
> #define S_IRWXG 0
> #endif
> #if MINGW && !defined(S_IRWXO)
> #define S_IRWXO 0
> #endif
> 
> And that will allow it to work correctly.

Conceptually, yes; you'd actually need to test on __MINGW32__, or maybe even
more generically on _WIN32, rather than on (nonexistent) MINGW.  However, that
seems every bit as much of a kludge as my own work-around.  Realistically,
calling umask() in this context on native windows would seem to be completely
redundant anyway; I can't see how it will actually achieve anything, since all
it will do will be to reproduce the already existing state, at the time of the
call.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (10 preceding siblings ...)
  2015-07-20 15:26 ` keith.marshall at mailinator dot com
@ 2015-08-06 16:57 ` fxcoudert at gcc dot gnu.org
  2015-08-06 18:11 ` sgk at troutmask dot apl.washington.edu
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-06 16:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-06
                 CC|                            |fxcoudert at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |fxcoudert at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #11 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
What I do not understand is how this didn't show up before now, since the
relevant libgfortran code was committed in 2012, and the mingw-w64 project has
been providing gfortran builds throughout this time.


Other than that, I would simply suggest we don't use umask() on mingw targets
(no need to make useless system calls):

Index: io/unix.c
===================================================================
--- io/unix.c   (revision 226632)
+++ io/unix.c   (working copy)
@@ -1083,6 +1083,14 @@ set_close_on_exec (int fd __attribute__ 
 }


+/* On mingw, we don't use umask in the function below, because it
+   doesn't support the user/group/other-based permissions.  */
+
+#ifdef __MINGW32__
+#undef HAVE_UMASK
+#endif
+
+
 /* Helper function for tempfile(). Tries to open a temporary file in
    the directory specified by tempdir. If successful, the file name is
    stored in fname and the descriptor returned. Returns -1 on


Can someone (Keith?) actually confirm that this restores the build on mingw32?
(It should, but double-checking never hurts.)


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (11 preceding siblings ...)
  2015-08-06 16:57 ` fxcoudert at gcc dot gnu.org
@ 2015-08-06 18:11 ` sgk at troutmask dot apl.washington.edu
  2015-08-06 18:14 ` fxcoudert at gcc dot gnu.org
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-08-06 18:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #12 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Aug 06, 2015 at 04:57:15PM +0000, fxcoudert at gcc dot gnu.org wrote:
> 
> Index: io/unix.c
> ===================================================================
> --- io/unix.c   (revision 226632)
> +++ io/unix.c   (working copy)
> @@ -1083,6 +1083,14 @@ set_close_on_exec (int fd __attribute__ 
>  }
> 
> 
> +/* On mingw, we don't use umask in the function below, because it
> +   doesn't support the user/group/other-based permissions.  */
> +
> +#ifdef __MINGW32__
> +#undef HAVE_UMASK
> +#endif
> +

Aren't there enough occurences of __MINGW32__ in io/unix.c?
Why add yet another kludge?  Put the #undef at line 48.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (12 preceding siblings ...)
  2015-08-06 18:11 ` sgk at troutmask dot apl.washington.edu
@ 2015-08-06 18:14 ` fxcoudert at gcc dot gnu.org
  2015-08-09  8:53 ` fxcoudert at gcc dot gnu.org
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-06 18:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #13 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #12)
> Aren't there enough occurences of __MINGW32__ in io/unix.c?
> Why add yet another kludge?  Put the #undef at line 48.

Indeed, that works equally:

Index: io/unix.c
===================================================================
--- io/unix.c   (revision 226632)
+++ io/unix.c   (working copy)
@@ -101,6 +101,12 @@ id_from_fd (const int fd)
 }

 #endif /* HAVE_WORKING_STAT */
+
+
+/* On mingw, we don't use umask in tempfile_open(), because it
+   doesn't support the user/group/other-based permissions.  */
+#undef HAVE_UMASK
+
 #endif /* __MINGW32__ */


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (13 preceding siblings ...)
  2015-08-06 18:14 ` fxcoudert at gcc dot gnu.org
@ 2015-08-09  8:53 ` fxcoudert at gcc dot gnu.org
  2015-08-09 16:02 ` sgk at troutmask dot apl.washington.edu
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-09  8:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ktietz at gcc dot gnu.org

--- Comment #14 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Kai, as mingw maintainer, can you comment? Why did this issue appear recently?
And does the patch seem OK to you?


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (14 preceding siblings ...)
  2015-08-09  8:53 ` fxcoudert at gcc dot gnu.org
@ 2015-08-09 16:02 ` sgk at troutmask dot apl.washington.edu
  2015-08-09 16:44 ` fxcoudert at gcc dot gnu.org
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2015-08-09 16:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #15 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Aug 09, 2015 at 08:53:36AM +0000, fxcoudert at gcc dot gnu.org wrote:
> Kai, as mingw maintainer, can you comment? Why did this issue appear recently?
> And does the patch seem OK to you?
> 

See comment #6.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (15 preceding siblings ...)
  2015-08-09 16:02 ` sgk at troutmask dot apl.washington.edu
@ 2015-08-09 16:44 ` fxcoudert at gcc dot gnu.org
  2015-08-09 16:47 ` fxcoudert at gcc dot gnu.org
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-09 16:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #16 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Author: fxcoudert
Date: Sun Aug  9 16:43:42 2015
New Revision: 226750

URL: https://gcc.gnu.org/viewcvs?rev=226750&root=gcc&view=rev
Log:
        PR libfortran/66936
        * io/unix.c (__MINGW32__): Undefine HAVE_UMASK.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (16 preceding siblings ...)
  2015-08-09 16:44 ` fxcoudert at gcc dot gnu.org
@ 2015-08-09 16:47 ` fxcoudert at gcc dot gnu.org
  2015-08-18 17:56 ` keith.marshall at mailinator dot com
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-09 16:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #17 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
(In reply to Steve Kargl from comment #15)
> See comment #6.

Thanks Steve, I had missed that.

Given the history and reasons, I've committed the patch to restore build on
mingw32. Marking as fixed on trunk.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (17 preceding siblings ...)
  2015-08-09 16:47 ` fxcoudert at gcc dot gnu.org
@ 2015-08-18 17:56 ` keith.marshall at mailinator dot com
  2015-08-18 19:58 ` fxcoudert at gcc dot gnu.org
  2015-08-18 20:03 ` fxcoudert at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: keith.marshall at mailinator dot com @ 2015-08-18 17:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #18 from Keith Marshall <keith.marshall at mailinator dot com> ---
(In reply to Francois-Xavier Coudert from comment #17)
> Given the history and reasons, I've committed the patch to restore build on
> mingw32. Marking as fixed on trunk.

Thanks.  Looks like a cleaner way to achieve the same effect as my own Q&D
hack.  Reverted mine, and applied this to my 4.9.3 tree; can confirm that it
now builds successfully for mingw32, (as crossed-native build from GNU/Linux;
still can't build 5.x, but that's an entirely different issue).

I haven't written any Fortran code in near 15 years, and no longer run Windows
myself anyway, so haven't tested usability; let's push it out there, and see if
anyone in the MinGW.org community can identify any consequent problems.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (18 preceding siblings ...)
  2015-08-18 17:56 ` keith.marshall at mailinator dot com
@ 2015-08-18 19:58 ` fxcoudert at gcc dot gnu.org
  2015-08-18 20:03 ` fxcoudert at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-18 19:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #20 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Author: fxcoudert
Date: Tue Aug 18 19:58:15 2015
New Revision: 226989

URL: https://gcc.gnu.org/viewcvs?rev=226989&root=gcc&view=rev
Log:
        PR libfortran/66936
        * io/unix.c (__MINGW32__): Undefine HAVE_UMASK.

Modified:
    branches/gcc-4_9-branch/libgfortran/ChangeLog
    branches/gcc-4_9-branch/libgfortran/io/unix.c


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() is available
  2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
                   ` (19 preceding siblings ...)
  2015-08-18 19:58 ` fxcoudert at gcc dot gnu.org
@ 2015-08-18 20:03 ` fxcoudert at gcc dot gnu.org
  20 siblings, 0 replies; 22+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2015-08-18 20:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66936

--- Comment #21 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Now backported to all active branches.


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2015-08-18 20:03 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-19 15:14 [Bug libfortran/66936] New: io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that mkstemp() is available keith.marshall at mailinator dot com
2015-07-19 15:44 ` [Bug libfortran/66936] " kargl at gcc dot gnu.org
2015-07-19 17:29 ` keith.marshall at mailinator dot com
2015-07-19 18:05 ` sgk at troutmask dot apl.washington.edu
2015-07-19 18:05 ` kargl at gcc dot gnu.org
2015-07-19 19:52 ` [Bug libfortran/66936] io/unix.c gratuitously uses S_IRWXG and S_IRWXO on the basis that umask() " kargl at gcc dot gnu.org
2015-07-19 20:50 ` keith.marshall at mailinator dot com
2015-07-19 21:04 ` keith.marshall at mailinator dot com
2015-07-19 21:42 ` kargl at gcc dot gnu.org
2015-07-19 22:17 ` keith.marshall at mailinator dot com
2015-07-20  9:19 ` pinskia at gcc dot gnu.org
2015-07-20 15:26 ` keith.marshall at mailinator dot com
2015-08-06 16:57 ` fxcoudert at gcc dot gnu.org
2015-08-06 18:11 ` sgk at troutmask dot apl.washington.edu
2015-08-06 18:14 ` fxcoudert at gcc dot gnu.org
2015-08-09  8:53 ` fxcoudert at gcc dot gnu.org
2015-08-09 16:02 ` sgk at troutmask dot apl.washington.edu
2015-08-09 16:44 ` fxcoudert at gcc dot gnu.org
2015-08-09 16:47 ` fxcoudert at gcc dot gnu.org
2015-08-18 17:56 ` keith.marshall at mailinator dot com
2015-08-18 19:58 ` fxcoudert at gcc dot gnu.org
2015-08-18 20:03 ` fxcoudert at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).