Skip to content
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

[PATCH] make Win32 perlglob.exe in 1 shot #15010

Closed
p5pRT opened this issue Oct 25, 2015 · 11 comments
Closed

[PATCH] make Win32 perlglob.exe in 1 shot #15010

p5pRT opened this issue Oct 25, 2015 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 25, 2015

Migrated from rt.perl.org#126452 (status was 'resolved')

Searchable as RT126452$

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2015

From @bulk88

See attached patch.
 

@p5pRT
Copy link
Author

p5pRT commented Oct 25, 2015

From @bulk88

0001-make-Win32-perlglob.exe-in-1-shot.patch
From 5bf111997cda74171804a8e3f8387d3baafe33f3 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Sun, 25 Oct 2015 16:25:32 -0400
Subject: [PATCH 1/2] make Win32 perlglob.exe in 1 shot

-dmake's parallel scheduler is poor and has problems finding work to run
 leading to idle cores, see note in commit c2c7bda088 about
 generate_uudmap.exe target so compile+link in 1 process run
-remove whitespace from LIBFILES as much as possible while keeping some
 prettyness in the makefile. This is so the console isn't flooded as much with
 with a wall of text as before.
-although perlglob.exe is very small, add $(OPTIMIZE), it previously wasnt
---
 win32/makefile.mk | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/win32/makefile.mk b/win32/makefile.mk
index 191e6cb..8741c06 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -498,11 +498,9 @@ LIBC		=
 #LIBC		= -lmsvcrt
 
 # same libs as MSVC
-LIBFILES	= $(LIBC) \
-		  -lmoldname -lkernel32 -luser32 -lgdi32 \
-		  -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 \
-		  -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr \
-		  -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
+LIBFILES	= $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
+	-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 \
+	-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
 
 .IF  "$(CFG)" == "Debug"
 OPTIMIZE	= -g -O2 -DDEBUGGING
@@ -643,11 +641,10 @@ BUILDOPT	+= -D_USE_32BIT_TIME_T
 .ENDIF
 .ENDIF
 
-LIBBASEFILES	= \
-		oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
-		comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
-		netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib \
-		version.lib odbc32.lib odbccp32.lib comctl32.lib
+LIBBASEFILES	= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
+	comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
+	netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib \
+	odbc32.lib odbccp32.lib comctl32.lib
 
 # Avoid __intel_new_proc_init link error for libircmt.
 # libmmd is /MD equivelent, other variants exist.
@@ -1088,16 +1085,14 @@ CHECKDMAKE :
 	@exit 1
 .ENDIF
 
-$(GLOBEXE) : perlglob$(o)
+$(GLOBEXE) : perlglob.c
 .IF "$(CCTYPE)" == "GCC"
-	$(LINK32) $(BLINK_FLAGS) -mconsole -o $@ perlglob$(o) $(LIBFILES)
+	$(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
 .ELSE
-	$(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ perlglob$(o) setargv$(o)
-	$(EMBED_EXE_MANI)
+	$(CC) $(OPTIMIZE) -Fe$@ perlglob.c -link $(BLINK_FLAGS) setargv$(o) \
+	$(LIBFILES) && $(EMBED_EXE_MANI)
 .ENDIF
 
-perlglob$(o)  : perlglob.c
-
 config.w32 : $(CFGSH_TMPL)
 	copy $(CFGSH_TMPL) config.w32
 
-- 
1.9.5.msysgit.1

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @bulk88

See attached patch.<br>

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @bulk88

0001-redo-static-after-perl-126452-partly-0b057af7-revert.patch
From dbad84e50814898acd36a229bace33fda000876c Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Mon, 26 Oct 2015 23:15:43 -0400
Subject: [PATCH] redo static after "[perl #126452] partly 0b057af7 revert for
 C++ builds"

Add back static on C only, after it was reverted in commit eeb9a2fc89
C++ does not allow forward declarations (unlike C) needed to create
circular references/dependencies between symbols.
---
 dist/threads-shared/shared.xs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/dist/threads-shared/shared.xs b/dist/threads-shared/shared.xs
index 66dadec..20a13aa 100644
--- a/dist/threads-shared/shared.xs
+++ b/dist/threads-shared/shared.xs
@@ -332,6 +332,7 @@ static const MGVTBL sharedsv_userlock_vtbl = {
    the shared thing.
  */
 
+#ifdef __cplusplus
 extern const MGVTBL sharedsv_scalar_vtbl;   /* Scalars have this vtable */
 extern const MGVTBL sharedsv_array_vtbl;     /* Hashes and arrays have this
                                             - like 'tie' */
@@ -340,6 +341,11 @@ extern const MGVTBL sharedsv_elem_vtbl;      /* Elements of hashes and arrays ha
    The sharedsv_elem_vtbl associates the element with the array/hash and
    the sharedsv_scalar_vtbl associates it with the value
  */
+#else
+static const MGVTBL sharedsv_scalar_vtbl;
+static const MGVTBL sharedsv_array_vtbl;
+static const MGVTBL sharedsv_elem_vtbl;
+#endif
 
 
 /* Get shared aggregate SV pointed to by threads::shared::tie magic object */
@@ -878,6 +884,9 @@ sharedsv_scalar_mg_local(pTHX_ SV* nsv, MAGIC *mg)
 }
 #endif
 
+#ifndef __cplusplus
+static
+#endif
 const MGVTBL sharedsv_scalar_vtbl = {
     sharedsv_scalar_mg_get,     /* get */
     sharedsv_scalar_mg_set,     /* set */
@@ -1039,6 +1048,9 @@ sharedsv_elem_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
     return (0);
 }
 
+#ifndef __cplusplus
+static
+#endif
 const MGVTBL sharedsv_elem_vtbl = {
     sharedsv_elem_mg_FETCH,     /* get */
     sharedsv_elem_mg_STORE,     /* set */
@@ -1152,6 +1164,9 @@ sharedsv_array_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *param)
     return (0);
 }
 
+#ifndef __cplusplus
+static
+#endif
 const MGVTBL sharedsv_array_vtbl = {
     0,                          /* get */
     0,                          /* set */
-- 
1.9.5.msysgit.1

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @bulk88

On Mon Oct 26 20​:19​:21 2015, bulk88 wrote​:

See attached patch.<br>

how did this email wind up on another ticket? This was supposed to create a new ticket. I think the ticket number is wrong http​://perl5.git.perl.org/perl.git/commit/eeb9a2fc894389772ece9041f75e0a27354508a7 it was supposed to be https://rt-archive.perl.org/perl5/Ticket/Display.html?id=126431 not #125452 (this ticket)

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @tonycoz

On Mon Oct 26 20​:26​:31 2015, bulk88 wrote​:

On Mon Oct 26 20​:19​:21 2015, bulk88 wrote​:

See attached patch.<br>

how did this email wind up on another ticket? This was supposed to
create a new ticket. I think the ticket number is wrong
http​://perl5.git.perl.org/perl.git/commit/eeb9a2fc894389772ece9041f75e0a27354508a7
it was supposed to be
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=126431 not #125452 (this
ticket)

Without the ticket number it may have looked at the References header.

This would be set if you replied to a message instead of starting from scratch.

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @bulk88

On Sun Oct 25 16​:03​:54 2015, bulk88 wrote​:

See attached patch.

The patch in the OP is obsolete and was squashed into a bigger one. New patch attached.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Oct 27, 2015

From @bulk88

0001-Win32-parallel-build-fixes-C.patch
From 9f4ce9f5dbf71a2fb18a247431be3c62290b5f2e Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Tue, 27 Oct 2015 12:07:51 -0400
Subject: [PATCH] Win32 parallel build fixes C++

-dmake's parallel scheduler is poor and has problems finding work to run
 leading to idle cores, see note in commit c2c7bda088 about
 generate_uudmap.exe target so compile+link perlglob.exe in 1 process run
-remove whitespace from LIBFILES as much as possible while keeping some
 prettyness in the makefile. This is so the console isn't flooded as much
 with a wall of text as before.
-although perlglob.exe is very small (1 main func, that is it),
 add $(OPTIMIZE), it previously wasnt CC optimized at all
-when -xc++ flag is used (USE_CPLUSPLUS=define), the command options
 file is compiled like C code and syntax errors, use -x to reset file type
 to nothing/auto

g++ -xc++ -I.\include -I. -I.. -DWIN32 -DPERLDLL -DPERL_CORE -s -O2  -DPERL_TEXT
MODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-ali
asing -mms-bitfields -o..\generate_uudmap.exe ..\generate_uudmap.c  -s -L"c:\per
l\lib\CORE" -L"C:\MinGW\lib" \
            C:\Users\Owner\AppData\Local\Temp\mk10
C:\Users\Owner\AppData\Local\Temp\mk10:1:7: error: expected constructor, destruc
tor, or type conversion before '(' token
 INPUT (  -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool  -lcomdlg32 -ladvapi
32 -lshell32 -lole32 -loleaut32 -lnetapi32  -luuid -lws2_32 -lmpr -lwinmm -lvers
ion -lodbc32 -lodbccp32 -lcomctl32 )
       ^
dmake:  Error code 129, while making '..\bitcount.h'

-since makefile.mk does not create perl523.lib during link time of
 perl523.dll anymore, to allow parallelism the interface (def file and
 .exp/.lib files) between libperl and XS modules is created before libperl
 and XS modules are every created, this allows the 2 to build in parallel
 and not be dependent on each other. This caused a link failure where an
 XS module wanted a C++ mangled perl data symbol, while the def/lib file
 only had the extern "C", C named data symbol (unless you take
 extraordinary measures, the def/lib file is always extern "C" even if
 the symbol is mangled inside C/C++ lang world and for static linking
 purpose), so make all data symbols EXTERN_C, not extern, in the headers

link -out:..\..\lib\auto\PerlIO\encoding\encoding.dll -dll -nologo -nodefaultlib
 -debug -opt:ref,icf -ltcg              -libpath:"c:\perl\lib\CORE"
-machine:x86 "/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Co
ntrols' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144cc
f1df' language='*'" -subsystem:console,"5.01" encoding.obj   "..\..\lib\CORE\per
l523.lib" oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.l
ib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws2_32.
lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.li
b -def:encoding.def
   Creating library ..\..\lib\auto\PerlIO\encoding\encoding.lib and object ..\..
\lib\auto\PerlIO\encoding\encoding.exp
encoding.obj : error LNK2001: unresolved external symbol "__declspec(dllimport)
struct _PerlIO_funcs const PerlIO_perlio" (__imp_?PerlIO_perlio@@3U_PerlIO_funcs
@@B)
..\..\lib\auto\PerlIO\encoding\encoding.dll : fatal error LNK1120: 1 unresolved
externals
dmake:  Error code 224, while making '..\..\lib\auto\PerlIO\encoding\encoding.dl
l'
-------------------------------------------------------------------------
link -dll -out:..\perl523.dll  -nologo -nodefaultlib -debug -opt:ref,icf -ltcg
        -libpath:"c:\perl\lib\CORE"             -machine:x86 "/manifestdependenc
y:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' proces
sorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'" -subsystem:c
onsole,"5.01" \
            @Extensions_static \
            @C:\Users\Owner\AppData\Local\Temp\mk11
perl523.exp : error LNK2001: unresolved external symbol _PL_interp_size
perl523.exp : error LNK2001: unresolved external symbol _PL_interp_size_5_18_0
perl523.exp : error LNK2001: unresolved external symbol _PerlIO_pending
perl523.exp : error LNK2001: unresolved external symbol _PerlIO_perlio
..\perl523.dll : fatal error LNK1120: 4 unresolved externals
dmake:  Error code 224, while making '..\perl523.dll'

With this commit, "dmake all" VC C++ build succeeds to the end, G++ build
won't build until 1 other issue is fixed, I fixed that issue for testing
but it is not in this patch, so only that issue remains preventing a G++
build from running to the end.
---
 EXTERN.h          |  8 ++++----
 INTERN.h          |  2 +-
 win32/makefile.mk | 31 +++++++++++++------------------
 3 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/EXTERN.h b/EXTERN.h
index 4e4f1ad..db8db2b 100644
--- a/EXTERN.h
+++ b/EXTERN.h
@@ -28,14 +28,14 @@
 #      define dEXTCONST const
 #    else
 #      if defined(PERLDLL) || defined(__SYMBIAN32__)
-#        define EXT extern __declspec(dllexport)
+#        define EXT EXTERN_C __declspec(dllexport)
 #        define dEXT 
-#        define EXTCONST extern __declspec(dllexport) const
+#        define EXTCONST EXTERN_C __declspec(dllexport) const
 #        define dEXTCONST const
 #      else
-#        define EXT extern __declspec(dllimport)
+#        define EXT EXTERN_C __declspec(dllimport)
 #        define dEXT 
-#        define EXTCONST extern __declspec(dllimport) const
+#        define EXTCONST EXTERN_C __declspec(dllimport) const
 #        define dEXTCONST const
 #      endif
 #    endif
diff --git a/INTERN.h b/INTERN.h
index e6e0602..eaaf6b2 100644
--- a/INTERN.h
+++ b/INTERN.h
@@ -35,7 +35,7 @@
 #    ifdef __cplusplus
 #      define EXT
 #      define dEXT
-#      define EXTCONST extern const
+#      define EXTCONST EXTERN_C const
 #      define dEXTCONST const
 #    else
 #      define EXT
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 191e6cb..1fb2df4 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -498,11 +498,9 @@ LIBC		=
 #LIBC		= -lmsvcrt
 
 # same libs as MSVC
-LIBFILES	= $(LIBC) \
-		  -lmoldname -lkernel32 -luser32 -lgdi32 \
-		  -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 \
-		  -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr \
-		  -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
+LIBFILES	= $(LIBC) -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool \
+	-lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 \
+	-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
 
 .IF  "$(CFG)" == "Debug"
 OPTIMIZE	= -g -O2 -DDEBUGGING
@@ -643,11 +641,10 @@ BUILDOPT	+= -D_USE_32BIT_TIME_T
 .ENDIF
 .ENDIF
 
-LIBBASEFILES	= \
-		oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
-		comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
-		netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib \
-		version.lib odbc32.lib odbccp32.lib comctl32.lib
+LIBBASEFILES	= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib \
+	comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
+	netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib \
+	odbc32.lib odbccp32.lib comctl32.lib
 
 # Avoid __intel_new_proc_init link error for libircmt.
 # libmmd is /MD equivelent, other variants exist.
@@ -1088,16 +1085,14 @@ CHECKDMAKE :
 	@exit 1
 .ENDIF
 
-$(GLOBEXE) : perlglob$(o)
+$(GLOBEXE) : perlglob.c
 .IF "$(CCTYPE)" == "GCC"
-	$(LINK32) $(BLINK_FLAGS) -mconsole -o $@ perlglob$(o) $(LIBFILES)
+	$(LINK32) $(OPTIMIZE) $(BLINK_FLAGS) -mconsole -o $@ perlglob.c $(LIBFILES)
 .ELSE
-	$(LINK32) $(BLINK_FLAGS) $(LIBFILES) -out:$@ perlglob$(o) setargv$(o)
-	$(EMBED_EXE_MANI)
+	$(CC) $(OPTIMIZE) -Fe$@ perlglob.c -link $(BLINK_FLAGS) setargv$(o) \
+	$(LIBFILES) && $(EMBED_EXE_MANI)
 .ENDIF
 
-perlglob$(o)  : perlglob.c
-
 config.w32 : $(CFGSH_TMPL)
 	copy $(CFGSH_TMPL) config.w32
 
@@ -1408,8 +1403,8 @@ $(MINIDIR)\globals$(o) : $(GENERATED_HEADERS)
 
 $(GENUUDMAP) $(GENERATED_HEADERS) .UPDATEALL : ..\mg_raw.h
 .IF "$(CCTYPE)" == "GCC"
-	$(LINK32) $(CFLAGS_O) -o..\generate_uudmap.exe ..\generate_uudmap.c $(BLINK_FLAGS) \
-	    $(mktmp $(LKPRE) $(LIBFILES) $(LKPOST))
+	$(LINK32) $(CFLAGS_O) -o..\generate_uudmap.exe ..\generate_uudmap.c \
+	$(BLINK_FLAGS) -x $(mktmp $(LKPRE) $(LIBFILES) $(LKPOST))
 .ELSE
 	$(CC) $(CFLAGS_O) -Fe..\generate_uudmap.exe ..\generate_uudmap.c @$(mktmp -link $(LIBFILES)) -link $(BLINK_FLAGS) 
 	$(EMBED_EXE_MANI:s/$@/..\generate_uudmap.exe/)
-- 
1.9.5.msysgit.1

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2015

From @tonycoz

On Tue Oct 27 11​:31​:52 2015, bulk88 wrote​:

On Sun Oct 25 16​:03​:54 2015, bulk88 wrote​:

See attached patch.

The patch in the OP is obsolete and was squashed into a bigger one.
New patch attached.

Thanks, applied as 1545a17.

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 28, 2015

@tonycoz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant