New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pod2usage and podchecker not being built on Win32/MSVC 2019 #17145
Comments
From @tonycozCreated by @tonycozEver since I switched to windows 10 and MSVC 2019 I've had a problem porting/dual-life.t ....... 1/? # Failed test 11 - Verify -f '../cpan/Pod-Checker/podchecker' at porting/dual-life.t line 70 Tracing this it turned out to be glob not returning any files for this part of foreach (glob('scripts/pod*.PL')) { At this point of the build process on Win32/MSVC glob is handled by perlglob.exe, If I run it directly in the directories with the problem: C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage>..\..\perlglob.exe scripts/pod*.PL C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage> But dir produces the expected files: C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage>dir scripts\pod*.PL Directory of C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage\scripts 25/01/2019 09:34 AM 5,151 pod2usage.PL Note that supplying \ instead of / to perlglob makes no difference: C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage>..\..\perlglob.exe scripts\pod*.PL C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage> perlglob produces strange output in other cases too: C:\Users\Tony\dev\perl\git\perl\win32>perlglob bin\*.pl Directory of C:\Users\Tony\dev\perl\git\perl\win32\bin 25/01/2019 09:34 AM 2,740 exetype.pl Note the truncation of bin\exetype.pl from perlglob. A side issue: we install win32/bin/perlglob.pl as perlglob.bat and Perl Info
|
From @tonycozOn Wed, 04 Sep 2019 19:06:07 -0700, tonyc wrote:
With the attached patch: C:\Users\Tony\dev\perl\git\perl\win32>..\perlglob bin\*.pl C:\Users\Tony\dev\perl\git\perl\cpan\Pod-Usage>..\..\perlglob scripts/pod*.PL Tony |
From @tonycoz0001-perl-134406-avoid-setargv-for-globbing.patchFrom 6ef6fccefc402ee57472ee7f149dae883f074a9f Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Thu, 5 Sep 2019 11:03:50 +1000
Subject: (perl #134406) avoid setargv for globbing
Since running windows 10 regularly, I've been seeing porting test
failure complaining that pod2usage and podchecker weren't being built
and installed.
I eventually tracked this down to perlglob scripts/pod*.PL not returning
any files.
---
win32/GNUmakefile | 2 +-
win32/Makefile | 2 +-
win32/makefile.mk | 2 +-
win32/perlglob.c | 87 +++++++++++++++++++++++++++++++++++------------
4 files changed, 69 insertions(+), 24 deletions(-)
diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index bad4db8107..a181678e09 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -1287,7 +1287,7 @@ ifeq ($(CCTYPE),GCC)
$(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
else
$(CC) $(OPTIMIZE) $(PDBOUT) -Fe$@ perlglob.c -link $(BLINK_FLAGS) \
- setargv$(o) $(LIBFILES) && $(EMBED_EXE_MANI)
+ $(LIBFILES) && $(EMBED_EXE_MANI)
endif
..\git_version.h : $(HAVEMINIPERL) ..\make_patchnum.pl
diff --git a/win32/Makefile b/win32/Makefile
index b5cdb287b2..9e8065e78b 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -964,7 +964,7 @@ static: $(PERLEXESTATIC)
$(GLOBEXE) : perlglob$(o)
$(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ \
- perlglob$(o) setargv$(o)
+ perlglob$(o)
$(EMBED_EXE_MANI)
perlglob$(o) : perlglob.c
diff --git a/win32/makefile.mk b/win32/makefile.mk
index e11de053d9..f8d50784bc 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -1233,7 +1233,7 @@ $(GLOBEXE) : perlglob.c
$(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
.ELSE
$(CC) $(OPTIMIZE) $(PDBOUT) -Fe$@ perlglob.c -link $(BLINK_FLAGS) \
- setargv$(o) $(LIBFILES) && $(EMBED_EXE_MANI)
+ $(LIBFILES) && $(EMBED_EXE_MANI)
.ENDIF
..\git_version.h : $(HAVEMINIPERL) ..\make_patchnum.pl
diff --git a/win32/perlglob.c b/win32/perlglob.c
index 8add30f2a5..6edc000018 100644
--- a/win32/perlglob.c
+++ b/win32/perlglob.c
@@ -1,28 +1,35 @@
/*
- * Globbing for NT. Relies on the expansion done by the library
- * startup code (provided by Visual C++ by linking in setargv.obj).
+ * Globbing for NT. Previously relied on the expansion done by the library
+ * startup code (provided by Visual C++ by linking in setargv.obj), but
+ * that was flaky in some cases.
*/
-/* Enable wildcard expansion for gcc's C-runtime library if not enabled by
- * default (currently necessary with the automated build of the mingw-w64
- * cross-compiler, but there's no harm in making sure for others too). */
-#ifdef __MINGW32__
-#include <_mingw.h>
-#if defined(__MINGW64_VERSION_MAJOR) && defined(__MINGW64_VERSION_MINOR)
- // MinGW-w64
- int _dowildcard = -1;
-#else
- // MinGW
- int _CRT_glob = -1;
-#endif
-#endif
-
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <string.h>
+#include <stdlib.h>
#include <windows.h>
+static void
+resize_path(char **ppath, size_t *alloc, size_t needed) {
+ ++needed;
+ if (needed > *alloc) {
+ /* exponential growth, these are filenames we're fetching
+ from disk and from the command-line, both of which
+ have reasonably small size limits, so we don't need to
+ worry about overflow here.
+ */
+ size_t new_size = needed * 2;
+ *ppath = realloc(*ppath, new_size);
+ if (!*ppath) {
+ perror("Out of memory");
+ exit(1);
+ }
+ *alloc = new_size;
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -33,6 +40,9 @@ main(int argc, char *argv[])
char volname[MAX_PATH];
DWORD serial, maxname, flags;
BOOL downcase = TRUE;
+ BOOL add_sep = FALSE;
+ char *base = NULL;
+ size_t base_alloc = 0;
/* check out the file system characteristics */
if (GetFullPathName(".", MAX_PATH, root, &dummy)) {
@@ -47,11 +57,46 @@ main(int argc, char *argv[])
setmode(fileno(stdout), O_BINARY);
for (i = 1; i < argc; i++) {
- len = strlen(argv[i]);
- if (downcase)
- strlwr(argv[i]);
- if (i > 1) fwrite("\0", sizeof(char), 1, stdout);
- fwrite(argv[i], sizeof(char), len, stdout);
+ WIN32_FIND_DATAA fd;
+ HANDLE fh = FindFirstFileA(argv[i], &fd);
+
+ if (fh != INVALID_HANDLE_VALUE) {
+ char *bs, *sl, *end;
+ ptrdiff_t end_off;
+ size_t len = strlen(argv[i]);
+
+ resize_path(&base, &base_alloc, len);
+ strcpy(base, argv[i]);
+
+ bs = (char *)strrchr(base, '\\');
+ sl = (char *)strrchr(base, '/');
+ if (bs || sl) {
+ end = bs && sl ? ( bs < sl ? sl : bs )
+ : bs ? bs : sl;
+ ++end;
+ }
+ else {
+ end = base; /* "*.c" or something similar */
+ }
+ end_off = end - base;
+
+ do {
+ len = strlen(fd.cFileName);
+ if (downcase)
+ strlwr(fd.cFileName);
+ resize_path(&base, &base_alloc, end_off + len);
+ strcpy(base + end_off, fd.cFileName);
+ if (add_sep) fwrite("\0", sizeof(char), 1, stdout);
+ fputs(base, stdout);
+ add_sep = 1;
+ } while (FindNextFileA(fh, &fd));
+ FindClose(fh);
+ }
+ else {
+ /* glob writes the pattern if no matches are found */
+ if (add_sep) fwrite("\0", sizeof(char), 1, stdout);
+ fputs(argv[i], stdout);
+ }
}
return 0;
}
--
2.23.0.windows.1
|
From @xenuOn Wed, 04 Sep 2019 21:16:25 -0700
Are you using the latest Windows SDK? See |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Wed, Sep 04, 2019 at 09:46:36PM -0700, Tomasz Konojacki via RT wrote:
C:\> perl -le "print for split /;/, $ENV{PATH}" So it looks like I'm using the latest SDK. I am running Windows 10 1803 (1903 fails to install[1].) Going by the issue link I'll need to upgrade the OS to fix this, if Tony [1] and fails to install and fails to install on and on and on. |
Upgrading (via installing 1903 from scratch) fixed this. |
Migrated from rt.perl.org#134406 (status was 'open')
Searchable as RT134406$
The text was updated successfully, but these errors were encountered: