diff options
author | Ken Takata <kentkt@csc.jp> | 2024-07-26 18:51:20 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-07-26 19:07:41 +0200 |
commit | 032accd98b6915b5d642a2d059cc666c2c786579 (patch) | |
tree | 6da16b98d01363da8f24c02d5921d892ce2dc4c8 | |
parent | b32d0a479d18512be551a3bca6366796c47d2633 (diff) |
patch 9.1.0622: MS-Windows: mingw-build can be optimizedv9.1.0622
Problem: MS-Windows: mingw-build can be optimized
Solution: use --gc-sections to reduce the size of the executable
(Ken Takata)
Use the --gc-sections linker option and the -ffunction-sections compiler
option to reduce the size of the executable files. To make these work,
the -fno-asynchronous-unwind-tables compiler option is also needed.
This is enabled by default and can be disabled by `USE_GC_SECTIONS=no`.
Note: A similar feature has been already used in MSVC. (The /OPT linker
option.)
related: #15350
Signed-off-by: Ken Takata <kentkt@csc.jp>
Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r-- | src/Make_cyg_ming.mak | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak index 911adb5ee0..a0c10b1130 100644 --- a/src/Make_cyg_ming.mak +++ b/src/Make_cyg_ming.mak @@ -130,7 +130,6 @@ ifndef STATIC_STDCPLUS STATIC_STDCPLUS=no endif - # Link against the shared version of libwinpthread by default. Set # STATIC_WINPTHREAD to "yes" to link against static version instead. ifndef STATIC_WINPTHREAD @@ -140,6 +139,12 @@ endif # This is used when STATIC_STDCPLUS=yes. HAS_GCC_EH=yes +# Reduce the size of the executables by using the --gc-sections linker +# option. Set USE_GC_SECTIONS to "no" if you see any issues with this. +ifndef USE_GC_SECTIONS +USE_GC_SECTIONS=yes +endif + # If the user doesn't want gettext, undefine it. ifeq (no, $(GETTEXT)) GETTEXT= @@ -1093,6 +1098,16 @@ LIB += -lgcc_eh LIB += -Wl,-Bstatic -lwinpthread -Wl,-Bdynamic endif +# To reduce the file size +ifeq (yes, $(USE_GC_SECTIONS)) +CFLAGS += -ffunction-sections -fno-asynchronous-unwind-tables +CXXFLAGS += -fasynchronous-unwind-tables +LFLAGS += -Wl,--gc-sections + ifeq (yes, $(VIMDLL)) +EXELFLAGS += -Wl,--gc-sections + endif +endif + ifeq (yes, $(MAP)) LFLAGS += -Wl,-Map=$(TARGET).map endif diff --git a/src/version.c b/src/version.c index a70a978127..01aea1f24d 100644 --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 622, +/**/ 621, /**/ 620, |