forked from aniani/vim
patch 9.1.0621: MS-Windows: startup code can be improved
Problem: MS-Windows: startup code can be improved Solution: Re-work and optimize win32 startup code (Ken Takata) * Revise the code and reduce #ifdefs. * For VIMDLL, stop using the default CRT startup code to reduce the file size. The file size becomes ~130 KB -> ~34 KB on MSVC. * Update comments. Make them consistent between os_w32dll.c and os_w32exe.c. closes: #15352 Signed-off-by: Ken Takata <kentkt@csc.jp> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
be82825687
commit
b32d0a479d
@@ -995,7 +995,7 @@ VIMDLLBASE := vim32$(DEBUG_SUFFIX)
|
|||||||
endif
|
endif
|
||||||
TARGET = $(VIMDLLBASE).dll
|
TARGET = $(VIMDLLBASE).dll
|
||||||
LFLAGS += -shared
|
LFLAGS += -shared
|
||||||
EXELFLAGS += -municode
|
EXELFLAGS += -municode -nostdlib
|
||||||
ifneq ($(DEBUG),yes)
|
ifneq ($(DEBUG),yes)
|
||||||
EXELFLAGS += -s
|
EXELFLAGS += -s
|
||||||
endif
|
endif
|
||||||
@@ -1122,14 +1122,22 @@ $(EXEOBJG): | $(OUTDIR)
|
|||||||
$(EXEOBJC): | $(OUTDIR)
|
$(EXEOBJC): | $(OUTDIR)
|
||||||
|
|
||||||
ifeq ($(VIMDLL),yes)
|
ifeq ($(VIMDLL),yes)
|
||||||
|
ifeq ($(ARCH),x86-64)
|
||||||
|
EXEENTRYC = -Wl,--entry=wmainCRTStartup
|
||||||
|
EXEENTRYG = -Wl,--entry=wWinMainCRTStartup
|
||||||
|
else ifeq ($(ARCH),i686)
|
||||||
|
EXEENTRYC = -Wl,--entry=_wmainCRTStartup
|
||||||
|
EXEENTRYG = -Wl,--entry=_wWinMainCRTStartup@0
|
||||||
|
endif
|
||||||
|
|
||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ)
|
||||||
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid -lgdi32 $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB) $(SODIUMLIB)
|
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid -lgdi32 $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB) $(SODIUMLIB)
|
||||||
|
|
||||||
$(GVIMEXE): $(EXEOBJG) $(VIMDLLBASE).dll
|
$(GVIMEXE): $(EXEOBJG) $(VIMDLLBASE).dll
|
||||||
$(CC) -L. $(EXELFLAGS) -mwindows -o $@ $(EXEOBJG) -l$(VIMDLLBASE)
|
$(CC) -L. $(EXELFLAGS) -mwindows -o $@ $(EXEOBJG) -l$(VIMDLLBASE) $(EXEENTRYG)
|
||||||
|
|
||||||
$(VIMEXE): $(EXEOBJC) $(VIMDLLBASE).dll
|
$(VIMEXE): $(EXEOBJC) $(VIMDLLBASE).dll
|
||||||
$(CC) -L. $(EXELFLAGS) -o $@ $(EXEOBJC) -l$(VIMDLLBASE)
|
$(CC) -L. $(EXELFLAGS) -o $@ $(EXEOBJC) -l$(VIMDLLBASE) $(EXEENTRYC)
|
||||||
else
|
else
|
||||||
$(TARGET): $(OBJ)
|
$(TARGET): $(OBJ)
|
||||||
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB) $(SODIUMLIB)
|
$(LINK) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB) $(SODIUMLIB)
|
||||||
@@ -1330,10 +1338,10 @@ $(OUTDIR)/netbeans.o: netbeans.c $(INCL) $(NBDEBUG_INCL) $(NBDEBUG_SRC)
|
|||||||
$(CC) -c $(CFLAGS) netbeans.c -o $@
|
$(CC) -c $(CFLAGS) netbeans.c -o $@
|
||||||
|
|
||||||
$(OUTDIR)/os_w32exec.o: os_w32exe.c $(INCL)
|
$(OUTDIR)/os_w32exec.o: os_w32exe.c $(INCL)
|
||||||
$(CC) -c $(CFLAGS) -UFEAT_GUI_MSWIN os_w32exe.c -o $@
|
$(CC) -c $(CFLAGS) -UFEAT_GUI_MSWIN -DUSE_OWNSTARTUP os_w32exe.c -o $@
|
||||||
|
|
||||||
$(OUTDIR)/os_w32exeg.o: os_w32exe.c $(INCL)
|
$(OUTDIR)/os_w32exeg.o: os_w32exe.c $(INCL)
|
||||||
$(CC) -c $(CFLAGS) os_w32exe.c -o $@
|
$(CC) -c $(CFLAGS) -DUSE_OWNSTARTUP os_w32exe.c -o $@
|
||||||
|
|
||||||
$(OUTDIR)/os_win32.o: os_win32.c $(INCL) $(MZSCHEME_INCL)
|
$(OUTDIR)/os_win32.o: os_win32.c $(INCL) $(MZSCHEME_INCL)
|
||||||
$(CC) -c $(CFLAGS) os_win32.c -o $@
|
$(CC) -c $(CFLAGS) os_win32.c -o $@
|
||||||
|
@@ -1302,11 +1302,11 @@ $(NETBEANS_OBJ) $(CHANNEL_OBJ) $(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
|
|||||||
|
|
||||||
$(GVIM).exe: $(OUTDIR) $(EXEOBJG) $(VIMDLLBASE).dll
|
$(GVIM).exe: $(OUTDIR) $(EXEOBJG) $(VIMDLLBASE).dll
|
||||||
$(LINK) $(LINKARGS1) /subsystem:$(SUBSYSTEM) -out:$(GVIM).exe \
|
$(LINK) $(LINKARGS1) /subsystem:$(SUBSYSTEM) -out:$(GVIM).exe \
|
||||||
$(EXEOBJG) $(VIMDLLBASE).lib $(LIBC)
|
$(EXEOBJG) $(VIMDLLBASE).lib
|
||||||
|
|
||||||
$(VIM).exe: $(OUTDIR) $(EXEOBJC) $(VIMDLLBASE).dll
|
$(VIM).exe: $(OUTDIR) $(EXEOBJC) $(VIMDLLBASE).dll
|
||||||
$(LINK) $(LINKARGS1) /subsystem:$(SUBSYSTEM_CON) -out:$(VIM).exe \
|
$(LINK) $(LINKARGS1) /subsystem:$(SUBSYSTEM_CON) -out:$(VIM).exe \
|
||||||
$(EXEOBJC) $(VIMDLLBASE).lib $(LIBC)
|
$(EXEOBJC) $(VIMDLLBASE).lib
|
||||||
|
|
||||||
!else
|
!else
|
||||||
|
|
||||||
@@ -1715,10 +1715,10 @@ $(OUTDIR)/os_w32dll.obj: $(OUTDIR) os_w32dll.c
|
|||||||
$(OUTDIR)/os_w32exe.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
$(OUTDIR)/os_w32exe.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
||||||
|
|
||||||
$(OUTDIR)/os_w32exec.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
$(OUTDIR)/os_w32exec.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
||||||
$(CC) $(CFLAGS:-DFEAT_GUI_MSWIN=) /Fo$@ os_w32exe.c
|
$(CC) $(CFLAGS:-DFEAT_GUI_MSWIN=) /DUSE_OWNSTARTUP /GS- /Fo$@ os_w32exe.c
|
||||||
|
|
||||||
$(OUTDIR)/os_w32exeg.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
$(OUTDIR)/os_w32exeg.obj: $(OUTDIR) os_w32exe.c $(INCL)
|
||||||
$(CC) $(CFLAGS) /Fo$@ os_w32exe.c
|
$(CC) $(CFLAGS) /DUSE_OWNSTARTUP /GS- /Fo$@ os_w32exe.c
|
||||||
|
|
||||||
$(OUTDIR)/pathdef.obj: $(OUTDIR) $(PATHDEF_SRC) $(INCL)
|
$(OUTDIR)/pathdef.obj: $(OUTDIR) $(PATHDEF_SRC) $(INCL)
|
||||||
$(CC) $(CFLAGS_OUTDIR) $(PATHDEF_SRC)
|
$(CC) $(CFLAGS_OUTDIR) $(PATHDEF_SRC)
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
* See README.txt for an overview of the Vim source code.
|
* See README.txt for an overview of the Vim source code.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Windows GUI: main program (DLL) entry point:
|
* Windows GUI/Console: main program (DLL) entry point:
|
||||||
*
|
*
|
||||||
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
||||||
* Adapted by Ken Takata.
|
* Adapted by Ken Takata.
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
* See README.txt for an overview of the Vim source code.
|
* See README.txt for an overview of the Vim source code.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Windows GUI: main program (EXE) entry point:
|
* Windows GUI/Console: main program (EXE) entry point:
|
||||||
*
|
*
|
||||||
* Ron Aaron <ronaharon@yahoo.com> wrote this and the (now deleted) DLL support
|
* Ron Aaron <ronaharon@yahoo.com> wrote this and the DLL support code.
|
||||||
* code.
|
* Adapted by Ken Takata.
|
||||||
*/
|
*/
|
||||||
#include "vim.h"
|
#include "vim.h"
|
||||||
|
|
||||||
@@ -20,11 +20,13 @@
|
|||||||
__declspec(dllimport)
|
__declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
int VimMain(int argc, char **argv);
|
int VimMain(int argc, char **argv);
|
||||||
#ifndef VIMDLL
|
|
||||||
|
#ifdef VIMDLL
|
||||||
|
# define SaveInst(hInst) // Do nothing
|
||||||
|
#else
|
||||||
void SaveInst(HINSTANCE hInst);
|
void SaveInst(HINSTANCE hInst);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PROTO
|
|
||||||
#ifdef FEAT_GUI
|
#ifdef FEAT_GUI
|
||||||
int WINAPI
|
int WINAPI
|
||||||
wWinMain(
|
wWinMain(
|
||||||
@@ -32,20 +34,39 @@ wWinMain(
|
|||||||
HINSTANCE hPrevInst UNUSED,
|
HINSTANCE hPrevInst UNUSED,
|
||||||
LPWSTR lpszCmdLine UNUSED,
|
LPWSTR lpszCmdLine UNUSED,
|
||||||
int nCmdShow UNUSED)
|
int nCmdShow UNUSED)
|
||||||
|
{
|
||||||
|
SaveInst(hInstance);
|
||||||
|
return VimMain(0, NULL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
wmain(int argc UNUSED, wchar_t **argv UNUSED)
|
wmain(int argc UNUSED, wchar_t **argv UNUSED)
|
||||||
# endif
|
|
||||||
{
|
{
|
||||||
# ifndef VIMDLL
|
|
||||||
# ifdef FEAT_GUI
|
|
||||||
SaveInst(hInstance);
|
|
||||||
# else
|
|
||||||
SaveInst(GetModuleHandleW(NULL));
|
SaveInst(GetModuleHandleW(NULL));
|
||||||
# endif
|
return VimMain(0, NULL);
|
||||||
# endif
|
|
||||||
VimMain(0, NULL);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_OWNSTARTUP
|
||||||
|
// Use our own entry point and don't use the default CRT startup code to
|
||||||
|
// reduce the size of (g)vim.exe. This works only when VIMDLL is defined.
|
||||||
|
//
|
||||||
|
// For MSVC, the /GS- compiler option is needed to avoid the undefined symbol
|
||||||
|
// error. (It disables the security check. However, it affects only this
|
||||||
|
// function and doesn't have any effect on Vim itself.)
|
||||||
|
// For MinGW, the -nostdlib compiler option and the --entry linker option are
|
||||||
|
// needed.
|
||||||
|
# ifdef FEAT_GUI
|
||||||
|
void WINAPI
|
||||||
|
wWinMainCRTStartup(void)
|
||||||
|
{
|
||||||
|
VimMain(0, NULL);
|
||||||
|
}
|
||||||
|
# else
|
||||||
|
void
|
||||||
|
wmainCRTStartup(void)
|
||||||
|
{
|
||||||
|
VimMain(0, NULL);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#endif // USE_OWNSTARTUP
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
621,
|
||||||
/**/
|
/**/
|
||||||
620,
|
620,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user