Vim developers,

I am trying to build 32-bit Vim using a mingw compiler that generates 64-bit output files by default. I specify ARCH=i686 on the make command line. Compilation fails with the first file because -m64 is the compiler default. This problem would not occur if the makefile src/Make_cyg_ming.mak included the -m32 compiler option but, as of patch 942, it does not.

Assuming this change is made, the next problem occurs when Windows resource files are created. Now I don't claim to understand such things very well but apparently there are 64-bit versions and 32-bit versions and they are specified through the --target option: "--target=pe-x86-64" for 64-bit builds and "--target=pe-i386" for 32-bit builds (this took some investigation). A review of the makefile suggests that this parameter should be defined in the WINDRES_FLAGS make variable. Setting this parameter as indicated solves the remaining build problem.

So, here are the makefiles that I had to modify:

        src/Make_ming.mak
        src/Make_cyg_ming.mak
        GvimExt/Make_ming.mak
        xxd/Make_ming.mak

The lines below show my diffs relative to patch 942. I purposely organized the changes so that they affect mingw builds exclusively.

Mike

-----------------------------------------------------------------------------------------------------------------------------------------

diff --git a/src/Make_ming.mak b/src/Make_ming.mak
index 9ed1a70..a760302 100644
--- a/src/Make_ming.mak
+++ b/src/Make_ming.mak
@@ -43,6 +43,21 @@
 # uncomment 'RUBY' if you want a Ruby-enabled version
 #RUBY=c:/ruby

+# To build 32-bit Vim using a mingw that generates 64-bit code by default,
+# some extra flags need to be set.  I've defined these flags using the new
+# make variables "CFLAGS_EXTRA" and "WINDRES_FLAGS_EXTRA" and added references
+# to them in the file "make_cyg_ming.mak".  In this way, only the mingw
+# build is affected.
+#
+# Similar changes also must be made to Make_ming.mak in GvimExt and xxd.
+#
+ifeq ($(ARCH),x86-64)
+    CFLAGS_EXTRA = -m64
+    WINDRES_FLAGS_EXTRA = --target=pe-x86-64
+else
+    CFLAGS_EXTRA = -m32
+    WINDRES_FLAGS_EXTRA = --target=pe-i386
+endif

 # Do not change this.
 UNDER_CYGWIN = no

diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index d10817a..646ac22 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -723,6 +723,13 @@ LIB += -lstdc++
 endif
 endif

+# The following two statements allow the caller to override any of the above
+# defaults even though they are in the "do not modify" section of this
+# Makefile.
+#
+CFLAGS += $(CFLAGS_EXTRA)
+WINDRES_FLAGS += $(WINDRES_FLAGS_EXTRA)
+
all: $(TARGET) vimrun.exe xxd/xxd.exe install.exe uninstal.exe GvimExt/gvimext.dll

 vimrun.exe: vimrun.c

diff --git a/src/GvimExt/Make_ming.mak b/src/GvimExt/Make_ming.mak
index d1d060b..8ce5943 100644
--- a/src/GvimExt/Make_ming.mak
+++ b/src/GvimExt/Make_ming.mak
@@ -47,6 +47,18 @@ CXX := $(CROSS_COMPILE)g++
 WINDRES := $(CROSS_COMPILE)windres
 WINDRES_CXX = $(CXX)
 WINDRES_FLAGS = --preprocessor="$(WINDRES_CXX) -E -xc" -DRC_INVOKED
+
+# Set flags to support either 32-bit or 64-bit build as appropriate.
+#
+CXXFLAGS := $(CXXFLAGS) -march=$(ARCH)
+ifeq ($(ARCH),x86-64)
+    CXXFLAGS := $(CXXFLAGS) -m64
+    WINDRES_FLAGS += --target=pe-x86-64
+else
+    CXXFLAGS := $(CXXFLAGS) -m32
+    WINDRES_FLAGS += --target=pe-i386
+endif
+
 LIBS :=  -luuid -lgdi32
 RES  := gvimext.res
 DEFFILE = gvimext_ming.def

diff --git a/src/xxd/Make_ming.mak b/src/xxd/Make_ming.mak
index 5147e89..442a9ea 100644
--- a/src/xxd/Make_ming.mak
+++ b/src/xxd/Make_ming.mak
@@ -15,6 +15,12 @@ endif
 CC = gcc
 CFLAGS = -O2 -Wall -DWIN32 $(DEFINES)

+ifeq ($(ARCH),x86-64)
+    CFLAGS += -march=$(ARCH) -m64
+else
+    CFLAGS += -march=$(ARCH) -m32
+endif
+
 ifneq (sh.exe, $(SHELL))
 DEL = rm
 else

--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui