bugmake - Bugs: bug #60444, gnulib fcntl breaks output-sync on...

 
 

bug #60444: gnulib fcntl breaks output-sync on mingw

Submitted by:  Ryan Prichard <rprichard>
Submitted on:  Fri 23 Apr 2021 03:11:46 AM UTC
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.3 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Fri 23 Apr 2021 06:24:09 AM UTC, comment #2: 

Using build_w32.bat batch file natively on MS-Windows is the only method of building a MinGW port of GNU Make that is officially supported as of now.  Support for building Make using the Posix configury would be welcome, but it probably needs a non-trivial amount of work.  In particular, my recommendation is to avoid any Gnulib replacements that the batch file method doesn't use, and try making the resulting config.h file as close to the one produced by the batch file as possible.  One easy (though somewhat hack-ish) way of forcing the Gnulib parts of the configure script do what you want is to set the corresponding shell variables manually before running the configure script.

Eli Zaretskii <eliz>
Project Member
Fri 23 Apr 2021 04:47:23 AM UTC, comment #1: 

I noticed that if I build make using `build_w32.bat gcc` instead, only a single C file from gnulib is compiled (lib/getloadavg.c). There are two other files from lib that aren't from gnulib (lib/fnmatch.c and lib/glob.c). make.exe then uses its own fcntl from posixfcn.c, which avoids this issue.

I see this same bug if I build using a "MSYS2 MinGW 64-bit" environment.

I'm working on a patch that moves the F_SETLKW handling from posixfcn.c into output.c. Maybe that's a fix.

To reproduce the bug (on Linux, using a cross-compiled make.exe):

$ cat Makefile
$(info HELLO)
all:
        echo ALL

$ wine /x/make/make.exe -O
wine: Read access denied for device L"\\??\\Z:\\", FS volume label and serial are not available.
fcntl(): Bad file descriptor
HELLO
echo ALL
ALL

(file #51310)

Ryan Prichard <rprichard>
Fri 23 Apr 2021 03:11:46 AM UTC, original submission:  

When I build make on Linux, using the autoconf script, cross-compiling to mingw-w64, the fcntl in src/w32/compat/posixfcn.c is disabled in favor of the version in gnulib. This is a problem for output synchronization (-O), which does something unusual on Windows:

[in src/output.c]
 - sync_handle is initialized using create_mutex(), which returns a Windows HANDLE rather than an fd.
 - This HANDLE is then passed to fcntl with F_SETLKW.

The gnulib fcntl doesn't have F_SETLKW, but in any case, the mutex HANDLE isn't a valid fd, so make prints errors:

    fcntl(): Bad file descriptor

This issue affects the Android NDK build of make.exe on Windows: https://github.com/android/ndk/issues/1492

Aside: The w32/compat/posixfcn.c version of fcntl assumes that F_SETLKW is only used with a single Win32 mutex HANDLE. The `last_fl` static variable is used to allow redundant F_WRLCK operations to succeed -- the first F_UNLCK operation releases the mutex.

Related issues:
 - https://savannah.gnu.org/bugs/?52922
 - https://savannah.gnu.org/bugs/?57888

Ryan Prichard <rprichard>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eliz (Posted a comment)
  • -email is unavailable- added by rprichard
  • -email is unavailable- added by rprichard (Submitted the item)
  • -email is unavailable- added by rprichard
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-23 rprichard Attached File- => Added inline-Windows-fcntl-locking.patch, #51310
        Carbon-Copy- => Added psmith
    2021-04-23 rprichard Carbon-Copy- => Added sno

    Back to the top


    Powered by Savane 3.9