Patch 8.2.5087

33 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 14, 2022, 7:31:14 AM6/14/22
to vim...@googlegroups.com

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 -- Br...@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 ///

John Marriott

unread,
Jun 14, 2022, 3:26:43 PM6/14/22
to vim...@googlegroups.com

On 14-June-2022 21:31, Bram Moolenaar wrote:
> 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
>
>
After this patch mingw64 (gcc 12.1) is spitting out lots of errors, one
for each source file:
<snip>
make
--directory=D:/Users/John/Documents/software/Utility/Vim/git/vim/src
FEATURES=NORMAL OPTIMIZE=MAXSPEED DIRECTX=no ICONV= GETTEXT= IME=no
DYNAMIC_IME=no POSTSCRIPT=no OLE=no WINVER=0x0603 CSCOPE=no NETBEANS=no
CHANNEL=no TERMINAL=no SOUND=no ARCH=native XPM=no GUI=yes CFLAGS=-I.
-Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF
-DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe
-march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return -fpie
-fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD
LFLAGS=-Wl,-nxcompat,-dynamicbase -municode -s -mwindows
--environment-overrides --jobs=9 --keep-going --output-sync
--no-print-directory --makefile=Make_ming.mak gvim.exe
process_begin: CreateProcess(NULL, cc -c -I. -Iproto -DWIN32
-DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL
-DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -march=native -Wall -O3
-fomit-frame-pointer -freg-struct-return -fpie -fPIE -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD alloc.c -o gobjnative/alloc.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Make_cyg_ming.mak:1215: gobjnative/alloc.o] Error 2
cc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD alloc.c -o gobjnative/alloc.o
process_begin: CreateProcess(NULL, cc -c -I. -Iproto -DWIN32
-DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL
-DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -march=native -Wall -O3
-fomit-frame-pointer -freg-struct-return -fpie -fPIE -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD arabic.c -o gobjnative/arabic.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Make_cyg_ming.mak:1215: gobjnative/arabic.o] Error 2
cc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
-pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return
-fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD arabic.c -o
gobjnative/arabic.o
process_begin: CreateProcess(NULL, cc -c -I. -Iproto -DWIN32
-DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL
-DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -march=native -Wall -O3
-fomit-frame-pointer -freg-struct-return -fpie -fPIE -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD arglist.c -o gobjnative/arglist.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Make_cyg_ming.mak:1215: gobjnative/arglist.o] Error 2
...
</snip>

I don't have the command "cc", only gcc.

I think line problem is in lines 220 to 222 in Make_cyg_ming.mak:
<snip>
ifeq ($(CC),)
CC := $(CROSS_COMPILE)gcc
endif
</snip>

Checking if $CC is empty won't work for gnu make because it predefines
it to have the value "cc". So for me, $CC remains with the value "cc"
and not "gcc".

Cheers
John

Christian J. Robinson

unread,
Jun 14, 2022, 3:34:40 PM6/14/22
to vim_dev
This is related to my problem. I temporarily fixed the problem with this command-line:
CC='' CXX='' make ...

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/69fba827-41da-68d8-9e4f-044e75f431e8%40internode.on.net.


--
Christian J. Robinson <hep...@gmail.com>

John Marriott

unread,
Jun 14, 2022, 3:41:49 PM6/14/22
to vim...@googlegroups.com


On 15-June-2022 05:34, Christian J. Robinson wrote:
> This is related to my problem. I temporarily fixed the problem with
> this command-line:
> CC='' CXX='' make ...
>
Thanks :-)

Yegappan Lakshmanan

unread,
Jun 14, 2022, 3:57:18 PM6/14/22
to vim_dev
Hi,
Can you try the attached patch and see whether you can build Vim?

Thanks,
Yegappan
mingw.diff

Bram Moolenaar

unread,
Jun 14, 2022, 4:25:38 PM6/14/22
to vim...@googlegroups.com, Yegappan Lakshmanan
It looks like this checks that $CC is not set to "clang".
A better check would be if $CC is not empty and not "cc".
Since "cc" appears to be the default value, and it doesn't work.

--
"Software is like sex... it's better when it's free."
-- Linus Torvalds, initiator of the free Linux OS
Makes me wonder what FSF stands for...?

John Marriott

unread,
Jun 14, 2022, 4:46:31 PM6/14/22
to vim...@googlegroups.com
Hi Yegappan,

This patch works for me.

Christian J. Robinson

unread,
Jun 14, 2022, 4:52:26 PM6/14/22
to vim_dev
It works for me as well.

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.

Yegappan Lakshmanan

unread,
Jun 15, 2022, 9:56:56 AM6/15/22
to Bram Moolenaar, vim_dev
Hi Bram,

On Tue, Jun 14, 2022 at 1:25 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Yegappan wrote:
>
> > On Tue, Jun 14, 2022 at 12:41 PM John Marriott
> > <basi...@internode.on.net> wrote:
> > >
> > > On 15-June-2022 05:34, Christian J. Robinson wrote:
> > > > This is related to my problem. I temporarily fixed the problem with
> > > > this command-line:
> > > > CC='' CXX='' make ...
> > > >
> > > Thanks :-)
> >
> > Can you try the attached patch and see whether you can build Vim?
>
> It looks like this checks that $CC is not set to "clang".
> A better check would be if $CC is not empty and not "cc".
> Since "cc" appears to be the default value, and it doesn't work.
>

If $CC is empty or if it is set to "cc", then CC should be set to
"$(CROSS_COMPILE)gcc".
Otherwise, the current value should be used. Before the clang related change,
$CC was unconditionally always set to "$(CROSS_COMPILE)gcc". To minimize
breaking other build combinations, I added the check only for clang.

- Yegappan

Bram Moolenaar

unread,
Jun 15, 2022, 1:33:21 PM6/15/22
to vim...@googlegroups.com, Yegappan Lakshmanan
OK, it's a step in the right direction. It might still overrule a
user's preferred compiler though.

--
JOHN CLEESE PLAYED: SECOND SOLDIER WITH A KEEN INTEREST IN BIRDS, LARGE MAN
WITH DEAD BODY, BLACK KNIGHT, MR NEWT (A VILLAGE
BLACKSMITH INTERESTED IN BURNING WITCHES), A QUITE
EXTRAORDINARILY RUDE FRENCHMAN, TIM THE WIZARD, SIR
LAUNCELOT
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Reply all
Reply to author
Forward
0 new messages