0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.5087: cannot build with clang on MS-Windows

Problem:    Cannot build with clang on MS-Windows.
Solution:   Add support for building with clang. (Yegappan Lakshmanan,
            closes #10557)
This commit is contained in:
Yegappan Lakshmanan 2022-06-14 12:30:25 +01:00 committed by Bram Moolenaar
parent 361f9d2da4
commit 1630bd980a
4 changed files with 56 additions and 1 deletions

View File

@ -53,7 +53,9 @@ WINDRES := $(CROSS_COMPILE)windres
WINDRES_FLAGS = WINDRES_FLAGS =
LIBS := -luuid -lgdi32 LIBS := -luuid -lgdi32
RES := gvimext.res RES := gvimext.res
ifeq ($(findstring clang++,$(CXX)),)
DEFFILE = gvimext_ming.def DEFFILE = gvimext_ming.def
endif
OBJ := gvimext.o OBJ := gvimext.o
DLL := gvimext.dll DLL := gvimext.dll

View File

@ -282,6 +282,29 @@ This command is in msys32.bat. Or for the 64 bit compiler use msys64.bat:
If you have msys64 in another location you will need to adjust the paths for If you have msys64 in another location you will need to adjust the paths for
that. that.
2.5. Build Vim with Clang
The following package group is required for building Vim with Clang:
* mingw-w64-clang-x86_64-clang
Use the following command to install it:
$ pacman -S mingw-w64-clang-x86_64-clang
Go to the source directory of Vim, then execute the make command. E.g.:
CC=clang
CXX=clang++
make -f Make_ming.mak
make -f Make_ming.mak GUI=no
make -f Make_ming.mak GUI=yes
To build Vim with the address sanitizer (ASAN), execute the following command:
CC=clang
CXX=clang++
make -f Make_ming.mak DEBUG=yes ASAN=yes
3. MinGW 3. MinGW
======== ========

View File

@ -217,8 +217,12 @@ MKDIR = mkdir
DIRSLASH = \\ DIRSLASH = \\
endif endif
endif endif
ifeq ($(CC),)
CC := $(CROSS_COMPILE)gcc CC := $(CROSS_COMPILE)gcc
endif
ifeq ($(CXX),)
CXX := $(CROSS_COMPILE)g++ CXX := $(CROSS_COMPILE)g++
endif
ifeq ($(UNDER_CYGWIN),yes) ifeq ($(UNDER_CYGWIN),yes)
WINDRES := $(CROSS_COMPILE)windres WINDRES := $(CROSS_COMPILE)windres
else else
@ -520,6 +524,8 @@ endif
########################################################################### ###########################################################################
CFLAGS = -I. -Iproto $(DEFINES) -pipe -march=$(ARCH) -Wall CFLAGS = -I. -Iproto $(DEFINES) -pipe -march=$(ARCH) -Wall
# To get additional compiler warnings
#CFLAGS += -Wextra -pedantic
CXXFLAGS = -std=gnu++11 CXXFLAGS = -std=gnu++11
# This used to have --preprocessor, but it's no longer supported # This used to have --preprocessor, but it's no longer supported
WINDRES_FLAGS = WINDRES_FLAGS =
@ -722,7 +728,11 @@ else
CFLAGS += -Os CFLAGS += -Os
else ifeq ($(OPTIMIZE), MAXSPEED) else ifeq ($(OPTIMIZE), MAXSPEED)
CFLAGS += -O3 CFLAGS += -O3
CFLAGS += -fomit-frame-pointer -freg-struct-return CFLAGS += -fomit-frame-pointer
ifeq ($(findstring clang,$(CC)),)
# Only GCC supports the "reg-struct-return" option. Clang doesn't support this.
CFLAGS += -freg-struct-return
endif
else # SPEED else # SPEED
CFLAGS += -O2 CFLAGS += -O2
endif endif
@ -734,6 +744,17 @@ CFLAGS += --coverage
LFLAGS += --coverage LFLAGS += --coverage
endif endif
# If the ASAN=yes argument is supplied, then compile Vim with the address
# sanitizer (asan). Only supported by MingW64 clang compiler.
# May make Vim twice as slow. Errors are reported on stderr.
# More at: https://code.google.com/p/address-sanitizer/
# Useful environment variable:
# set ASAN_OPTIONS=print_stacktrace=1 log_path=asan
ifeq ($(ASAN),yes)
#CFLAGS += -g -O0 -fsanitize-recover=all -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
CFLAGS += -g -O0 -fsanitize-recover=all -fsanitize=address -fno-omit-frame-pointer
endif
LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lnetapi32 -lversion LIB = -lkernel32 -luser32 -lgdi32 -ladvapi32 -lcomdlg32 -lcomctl32 -lnetapi32 -lversion
GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o
CUIOBJ = $(OUTDIR)/iscygpty.o CUIOBJ = $(OUTDIR)/iscygpty.o
@ -1076,6 +1097,13 @@ ifeq (yes, $(MAP))
LFLAGS += -Wl,-Map=$(TARGET).map LFLAGS += -Wl,-Map=$(TARGET).map
endif endif
# The default stack size on Windows is 2 MB. With the default stack size, the
# following tests fail with the clang address sanitizer:
# Test_listdict_compare, Test_listdict_compare_complex, Test_deep_recursion,
# Test_map_error, Test_recursive_define, Test_recursive_addstate
# To increase the stack size to 16MB, uncomment the following line:
#LFLAGS += -Wl,-stack -Wl,0x1000000
all: $(MAIN_TARGET) vimrun.exe xxd/xxd.exe tee/tee.exe install.exe uninstall.exe GvimExt/gvimext.dll all: $(MAIN_TARGET) vimrun.exe xxd/xxd.exe tee/tee.exe install.exe uninstall.exe GvimExt/gvimext.dll
vimrun.exe: vimrun.c vimrun.exe: vimrun.c

View File

@ -734,6 +734,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 */
/**/
5087,
/**/ /**/
5086, 5086,
/**/ /**/