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] remove unreferenced copies of char * swash_property_names[] #16440

Closed
p5pRT opened this issue Feb 26, 2018 · 7 comments
Closed

[PATCH] remove unreferenced copies of char * swash_property_names[] #16440

p5pRT opened this issue Feb 26, 2018 · 7 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Feb 26, 2018

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

Searchable as RT132912$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 26, 2018

From @bulk88

Created by @bulk88

See attached patch.

Perl Info

Flags:
     category=core
     severity=low

Site configuration information for perl 5.27.9:

Configured by Administrator at Tue Jan 30 20:34:30 2018.

Summary of my perl5 (revision 5 version 27 subversion 9) configuration:

   Platform:
     osname=MSWin32
     osvers=5.2.3790
     archname=MSWin32-x86-multi-thread
     uname=''
     config_args='undef'
     hint=recommended
     useposix=true
     d_sigaction=undef
     useithreads=define
     usemultiplicity=define
     use64bitint=undef
     use64bitall=undef
     uselongdouble=undef
     usemymalloc=n
     default_inc_excludes_dot=define
     bincompat5005=undef
   Compiler:
     cc='cl'
     ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -GL -DWIN32
-D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_NONSTDC_NO_DEPRECATE  -DPERL_TEXTMODE_SCRIPTS
-DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DWIN32_NO_REGISTRY'
     optimize='-O1 -MD -Zi -DNDEBUG -GL'
     cppflags='-DWIN32'
     ccversion='15.00.30729.01'
     gccversion=''
     gccosandvers=''
     intsize=4
     longsize=4
     ptrsize=4
     doublesize=8
     byteorder=1234
     doublekind=3
     d_longlong=undef
     longlongsize=8
     d_longdbl=define
     longdblsize=8
     longdblkind=0
     ivtype='long'
     ivsize=4
     nvtype='double'
     nvsize=8
     Off_t='__int64'
     lseeksize=8
     alignbytes=8
     prototype=define
   Linker and Libraries:
     ld='link'
     ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg
-libpath:"c:\perl\lib\CORE"        -machine:x86'
     libpth="C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib"
     libs=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 msvcrt.lib
     perllibs=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 msvcrt.lib
     libc=msvcrt.lib
     so=dll
     useshrplib=true
     libperl=perl527.lib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_win32.xs
     dlext=dll
     d_dlsymun=undef
     ccdlflags=' '
     cccdlflags=' '
     lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -ltcg
     -libpath:"c:\perl\lib\CORE"        -machine:x86'



@INC for perl 5.27.9:
     lib
     C:/p527/srcnew/lib


Environment for perl 5.27.9:
     CYGWIN=tty
     HOME (unset)
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH=/usr/lib/x86:/usr/X11R6/lib
     LOGDIR (unset)
     PATH=C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual
Studio 9.0\VC\BIN;C:\Program Files\Microsoft
SDKs\Windows\v6.0A\bin;C:\Perl\bin;C:\WINDOWS;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files
(x86)\Git\bin;C:\sp3220\c\bin;
     PERL_BADLANG (unset)
     SHELL (unset)




@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 26, 2018

From @bulk88

0001-remove-unreferenced-copies-of-char-swash_property_na.patch
From fb420d463f5404ac48060a81774694e1479ca468 Mon Sep 17 00:00:00 2001
From: Daniel Dragan <bulk88@hotmail.com>
Date: Sun, 25 Feb 2018 21:31:26 -0500
Subject: [PATCH] remove unreferenced copies of char * swash_property_names[]

Due to some MSVC bug or perl's not using MS specific CC options that I've
never figured out, MSVC does not remove unreferenced by a single .obj or
combine identical, static const data vars. MSVC funcs get removed &
combined correctly. Since for var swash_property_names removing it from
.objs that dont need it is very easy, do it. It saves some memory space.
Perhaps some other platforms/OSes/CCs have similar problems removing
unreferenced symbols from final binaries so this patch would help on those
CCs too.

regexec.c stopped using swash_property_names in commit 2a16ac9277 in 5.19.8
"regexec.c: Use compiled-in POSIX definitions"

regcomp.c stopped using swash_property_names in commit bcb875216f in 5.19.8
"regcomp.c: Rmv code for delayed 'til runtime POSIX defns"


with MSVC 2008 64, before

miniperl.exe disk file size 1761KB .rdata virtual size 0xBC354 bytes
perl527.dll disk file size 2040KB .rdata virtual size 0xC9421 bytes

after this commit

miniperl.exe disk file size 1761KB .rdata virtual size 0xBC2C4 bytes
perl527.dll disk file size 2040KB .rdata virtual size 0xC9381 bytes

~144 bytes saved by removing unused copies of swash_property_names array.

There are other cases of large duplicate static const data vars still in
the perl527.dll binary but this patch covers a very simple case.
---
 handy.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/handy.h b/handy.h
index 12d73b9..7fe1cf6 100644
--- a/handy.h
+++ b/handy.h
@@ -1216,9 +1216,7 @@ typedef enum {
 #define POSIX_SWASH_COUNT _FIRST_NON_SWASH_CC
 #define POSIX_CC_COUNT    (_HIGHEST_REGCOMP_DOT_H_SYNC + 1)
 
-#if defined(PERL_IN_UTF8_C)                         \
- || defined(PERL_IN_REGCOMP_C)                      \
- || defined(PERL_IN_REGEXEC_C)
+#if defined(PERL_IN_UTF8_C)
 #   if _CC_WORDCHAR != 0 || _CC_DIGIT != 1 || _CC_ALPHA != 2 || _CC_LOWER != 3 \
        || _CC_UPPER != 4 || _CC_PUNCT != 5 || _CC_PRINT != 6                   \
        || _CC_ALPHANUMERIC != 7 || _CC_GRAPH != 8 || _CC_CASED != 9
-- 
1.8.0.msysgit.0

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 27, 2018

@khwilliamson - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 27, 2018

From @khwilliamson

Thanks,

committed as f1bfbdd
--
Karl Williamson

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Feb 27, 2018

@khwilliamson - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

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

No branches or pull requests

1 participant