To: vim_dev@googlegroups.com Subject: Patch 8.2.5087 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5087 Problem: Cannot build with clang on MS-Windows. Solution: Add support for building with clang. (Yegappan Lakshmanan, closes #10557) Files: src/GvimExt/Make_ming.mak, src/INSTALLpc.txt, src/Make_cyg_ming.mak *** ../vim-8.2.5086/src/GvimExt/Make_ming.mak 2021-01-25 18:17:58.817907495 +0000 --- src/GvimExt/Make_ming.mak 2022-06-14 12:28:13.894718355 +0100 *************** *** 53,59 **** --- 53,61 ---- WINDRES_FLAGS = LIBS := -luuid -lgdi32 RES := gvimext.res + ifeq ($(findstring clang++,$(CXX)),) DEFFILE = gvimext_ming.def + endif OBJ := gvimext.o DLL := gvimext.dll *** ../vim-8.2.5086/src/INSTALLpc.txt 2022-03-07 15:16:11.461689545 +0000 --- src/INSTALLpc.txt 2022-06-14 12:28:13.894718355 +0100 *************** *** 282,287 **** --- 282,310 ---- If you have msys64 in another location you will need to adjust the paths for 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 ======== *** ../vim-8.2.5086/src/Make_cyg_ming.mak 2022-03-07 15:16:11.461689545 +0000 --- src/Make_cyg_ming.mak 2022-06-14 12:28:13.894718355 +0100 *************** *** 217,224 **** --- 217,228 ---- DIRSLASH = \\ endif endif + ifeq ($(CC),) CC := $(CROSS_COMPILE)gcc + endif + ifeq ($(CXX),) CXX := $(CROSS_COMPILE)g++ + endif ifeq ($(UNDER_CYGWIN),yes) WINDRES := $(CROSS_COMPILE)windres else *************** *** 520,525 **** --- 524,531 ---- ########################################################################### CFLAGS = -I. -Iproto $(DEFINES) -pipe -march=$(ARCH) -Wall + # To get additional compiler warnings + #CFLAGS += -Wextra -pedantic CXXFLAGS = -std=gnu++11 # This used to have --preprocessor, but it's no longer supported WINDRES_FLAGS = *************** *** 722,728 **** CFLAGS += -Os else ifeq ($(OPTIMIZE), MAXSPEED) CFLAGS += -O3 ! CFLAGS += -fomit-frame-pointer -freg-struct-return else # SPEED CFLAGS += -O2 endif --- 728,738 ---- CFLAGS += -Os else ifeq ($(OPTIMIZE), MAXSPEED) CFLAGS += -O3 ! 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 CFLAGS += -O2 endif *************** *** 734,739 **** --- 744,760 ---- LFLAGS += --coverage 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 GUIOBJ = $(OUTDIR)/gui.o $(OUTDIR)/gui_w32.o $(OUTDIR)/gui_beval.o CUIOBJ = $(OUTDIR)/iscygpty.o *************** *** 1076,1081 **** --- 1097,1109 ---- LFLAGS += -Wl,-Map=$(TARGET).map 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 vimrun.exe: vimrun.c *** ../vim-8.2.5086/src/version.c 2022-06-14 11:35:15.792489805 +0100 --- src/version.c 2022-06-14 12:29:50.601917306 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5087, /**/ -- Why don't cannibals eat clowns? Because they taste funny. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///