From 3eec7ec781cbfd7927b8da5d92d924674a463e86 Mon Sep 17 00:00:00 2001 From: bulk88 Date: Sat, 5 Oct 2024 21:39:59 -0400 Subject: [PATCH] small .h trick for faster win32 interp compiles cl.exe in the terminal is much faster by eye. PERL_CORE only, since CPAN XS assumes the built-in out the box headers/tokens/structs/linker libs selected by p5p decades ago will never change. Since CPAN has been caught doing "-DPERL_CORE" in the past then including p5 core headers, include a provision to enable #include full W32 headers, since it might be difficult to #undef then #include the OS headers a 2nd time with different CPP defines. "#define NONLS" too many core interp .c files need the ANSI/Wide code page apis to special case each .c. Just leave it out for now. A benefit is smaller .pdb or whatever GCC's dbg symbol file format is. So faster debugger startup. Also GCC uncontrollably includes all "#define"s in its symbol disk format (which isnt a separate file, but a many MBs memory mapped data structure embedded into the particular .exe or .dll, on disk, and in VM). Since Perl isn't a Win32 GUI app, keep the GUI APIs out of the compiler if possible and toss the "text" ASAP in the phases of compiling. Whether whole MS .h files are skipped, or CPP discards large chunks of APIs before reaching the C parser/.obj/.pdb files, is implementation specific behaviour by particular MSVCs and Mingw. Our side was completed, in requesting to exclude stuff. --- win32/perllib.c | 2 ++ win32/win32.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/win32/perllib.c b/win32/perllib.c index 64d9fdb8487f..25f2b14d7e15 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -6,10 +6,12 @@ * [Frodo on p.73 of _The Lord of the Rings_, I/iii: "Three Is Company"] */ #define PERLIO_NOT_STDIO 0 +#define PERL_IN_WIN32_PERLLIB_C #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include #ifdef PERL_IMPLICIT_SYS #include "win32iop.h" diff --git a/win32/win32.h b/win32/win32.h index 193990e9bb27..1617ebcac249 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -110,7 +110,62 @@ # define PERL_STATIC_FORCE_INLINE_NO_RET __declspec(noreturn) __forceinline static #endif -#define WIN32_LEAN_AND_MEAN +#ifdef PERL_CORE +# ifndef PERL_CORE_NO_CPAN_W32_H /* unsanctioned unsupported bypass for CPAN */ +# define NOATOM /* GUI IPC RPC strings */ +# define NOCLIPBOARD +# define NOCOLOR /* Widget colors */ +# define NOCOMM /* Serial ports*/ +# define NOCRYPT /* Encryption and employee auth tap cards */ +# define NOCTLMGR /* "Control and Dialog routines" */ +# define NODEFERWINDOWPOS /* Z index resize app windows */ +# define NODRAWTEXT /* Fonts "DrawText() and DT_*" */ +# define NOGDI /* wikipedia "Computer_graphics_algorithms" */ +# define NOGDICAPMASKS /* PNP Monitors/Screens */ +# define NOHELP /* Help engine */ +# define NOICONS /* Icon Img Objs */ +# define NOIMAGE /* MS .h says #def for perf, but OBSOL/UNIMPL/FUT */ +# define NOKANJI +# define NOKERNEL /* MS .h says #def for perf, but OBSOL/UNIMPL/FUT */ +# define NOKEYSTATES /* Mouse */ +# define NOMB /* popup MessageBox() */ +# define NOMCX /* Dialup Modem */ +# define NOMEMMGR /* GUI IPC RPC malloc buffers */ +# define NOMENUS /* GUI Menu obj */ +# define NOMETAFILE /* file format for half rendered graphics */ +# define NOMINMAX /* "Macros min(a,b) and max(a,b)" OBSOL/UNIMPL/FUT */ +# define NOMSG /* GUI Message loop */ +/* #define NONLS "Wide" Code Page conversion APIs */ +/* OBSOL/UNIMPL/FUT "OpenFile(), OemToAnsi, AnsiToOem" etc */ +# define NOOPENFILE +# define NOPROFILER /* "Profiler interface." OBSOL/UNIMPL/FUT */ +# define NOPROXYSTUB /* MS COM DCOM RPC probably, undoced, unimpl */ +# define NORASTEROPS /* see NOGDI */ +# define NORPC +# define NOSCROLL /* App Window Objs */ +# define NOSERVICE /* root/semi kernel service processes */ +# define NOSHOWWINDOW /* App Window Objs */ +# define NOSOUND +# define NOSYSCOMMANDS /* App Window Objs */ +# define NOSYSMETRICS /* Screen resolution */ +# define NOTAPE /* Tape drives */ +# define NOTEXTMETRIC /* Fonts */ +# ifndef PERL_IN_WIN32_PERLLIB_C +# define NOUSER /* high level GUI/IPC/RPC */ +# endif +# define NOVIRTUALKEYCODES /* Keyboards */ +# define NOWH /* SetWindowsHook */ +# ifndef PERL_IN_WIN32_PERLLIB_C +# define NOWINMESSAGES /* GUI Message loop IPC/RPC */ +# endif +# define NOWINOFFSETS /* App Window Obj themes */ +# define NOWINSTYLES /* App Window Obj themes */ +# define OEMRESOURCE /* Mouse cursor file format */ +# define VC_EXTRALEAN /* "MFC" VC 2010s or older??? */ +# endif +#endif + +#define WIN32_LEAN_AND_MEAN /* Day 1 Win32 Perl port, CPAN expects this. */ #include /*