View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000412 | file | General | public | 2022-12-26 18:37 | 2022-12-26 18:49 |
| Reporter | joveler | Assigned To | christos | ||
| Priority | normal | Severity | block | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Platform | MSYS2 MinGW-w64 | OS | Windows 10 22H2 | OS Version | gcc 12.2.0 |
| Product Version | 5.43 | ||||
| Fixed in Version | 5.45 | ||||
| Summary | 0000412: file 5.43 compile error on MinGW/MSYS2 and fix | ||||
| Description | * This issue is continued from the 5.40 compile issue report, https://bugs.astron.com/view.php?id=255 file 5.43 needs patches to be compiled on MSYS MinGW-w64. [*] putc call In `file.c`, `fname_print()` has a code path dedicated for non-widechar support. MinGW-w64 goes into that route, and meets `putc` without any FILE* to write on. Simply adding `stdout` parameter solves the issue. ----- file.c: In function 'fname_print': file.c:605:25: error: too few arguments to function 'putc' 605 | putc(c); | ^~~~ In file included from file.h:79, from file.c:32: C:/msys64/mingw64/include/stdio.h:705:15: note: declared here 705 | int __cdecl putc(int _Ch,FILE *_File); | ^~~~ ----- [*] pipe call This issue is related to the previous 5.40 fcntl build error. Thanks to the official patch, 5.43 does not have any fcntl compile/link error on Windows. In spite of the fix, Windows C runtime does not provide `pipe()` function, creating a linker error. The proposed patch adds `__MINGW32__` check at the top of the function to mitigate this. ----- C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: .libs/funcs.o: in function `file_pipe_closexec': src/funcs.c:850: undefined reference to `pipe' ----- [*] ioctl call This issue is identical with the previous 5.40 ioctl build error. MinGW does not support ioctl call and produce a linker error. ----- C:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld.exe: D:\Jang\Build\Source\PEBakery\Library\libmagic\file-5.40-mod\src/compress.c:417: undefined reference to `ioctl' ----- The proposed patch fixes this by adding !defined(__MINGW32__) check. If the library is configured with `--disable-xzlib --disable-bzlib`, the code is excluded and does not block the build. | ||||
| Steps To Reproduce | - Install MSYS2 on a Windows machine, and compile file source with normal `configure` and `make`. | ||||
| Additional Information | [*] Additional info of compile environment - Platform: Windows 10 22H2 with MSYS2 - Tested Target Arch : i686, x86_64, aarch64 - Toolchain: (1) MinGW-w64 of MSYS2 (i686/x86_64) (2) llvm-mingw (aarch64) | ||||
| Tags | build, patch, Windows | ||||
|
|
MinGW_w64_putc_fix.diff (326 bytes)
diff --git a/src/file.c b/src/file.c
index 1566a17..737ce31 100644
--- a/src/file.c
+++ b/src/file.c
@@ -602,7 +602,7 @@ fname_print(const char *inname)
for (i = 0; i < n; i++) {
unsigned char c = CAST(unsigned char, inname[i]);
if (isprint(c)) {
- putc(c);
+ putc(c, stdout);
continue;
}
file_octal(c);
MinGW_w64_ioctl_fix.diff (660 bytes)
diff --git a/src/compress.c b/src/compress.c
index 9f65e4fa..6b3b1b95 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -380,7 +380,7 @@ protected ssize_t
sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__)))
{
ssize_t rv;
-#ifdef FIONREAD
+#if defined(FIONREAD) && !defined(__MINGW32__)
int t = 0;
#endif
size_t rn = n;
@@ -388,7 +388,7 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__)))
if (fd == STDIN_FILENO)
goto nocheck;
-#ifdef FIONREAD
+#if defined(FIONREAD) && !defined(__MINGW32__)
if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) {
#ifdef FD_ZERO
ssize_t cnt;
MinGW_w64_pipe_fix.diff (374 bytes)
diff --git a/src/funcs.c b/src/funcs.c
index 41c4106..f9920a5 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -844,7 +844,9 @@ file_print_guid(char *str, size_t len, const uint64_t *guid)
protected int
file_pipe_closexec(int *fds)
{
-#ifdef HAVE_PIPE2
+#ifdef __MINGW32__
+ return 0;
+#elif defined(HAVE_PIPE2)
return pipe2(fds, O_CLOEXEC);
#else
if (pipe(fds) == -1)
|
|
|
Committed, thanks! |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2022-12-26 18:37 | joveler | New Issue | |
| 2022-12-26 18:37 | joveler | Tag Attached: build | |
| 2022-12-26 18:37 | joveler | Tag Attached: patch | |
| 2022-12-26 18:37 | joveler | Tag Attached: Windows | |
| 2022-12-26 18:37 | joveler | File Added: MinGW_w64_putc_fix.diff | |
| 2022-12-26 18:37 | joveler | File Added: MinGW_w64_ioctl_fix.diff | |
| 2022-12-26 18:37 | joveler | File Added: MinGW_w64_pipe_fix.diff | |
| 2022-12-26 18:49 | christos | Assigned To | => christos |
| 2022-12-26 18:49 | christos | Status | new => assigned |
| 2022-12-26 18:49 | christos | Status | assigned => resolved |
| 2022-12-26 18:49 | christos | Resolution | open => fixed |
| 2022-12-26 18:49 | christos | Fixed in Version | => 5.45 |
| 2022-12-26 18:49 | christos | Note Added: 0003875 |