Windows 64bit build in 32bit command prompt

186 views
Skip to first unread message

Mike Williams

unread,
Nov 29, 2015, 6:06:42 AM11/29/15
to vim_dev
Hi,

Just done my first build of VIM on an old Windows 7 32bit machine
upgraded to Windows 10 using VC. The link stage was failing due to
mixed machine targets being used in the make file - 32 and 64 bit! I
tracked this down to some fun with the PROCESSOR_ARCHITECTURE in a 32bit
prompt on a 64bit machine, see -

http://blogs.msdn.com/b/david.wang/archive/2006/03/26/howto-detect-process-bitness.aspx

I guess no one has ever tried to do this until now. It seems reasonable
to default to the host processor architecture and not the architecture
of the process being used to run the build. The following diff solves
the build issue for me:

diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -217,7 +217,11 @@ ASSEMBLY_ARCHITECTURE=$(CPU)
ASSEMBLY_ARCHITECTURE = x86
! endif
! else
+! ifdef PROCESSOR_ARCHITEW6432
+CPU = $(PROCESSOR_ARCHITEW6432)
+! else
CPU = $(PROCESSOR_ARCHITECTURE)
+! endif
ASSEMBLY_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
! if ("$(CPU)" == "x86") || ("$(CPU)" == "X86")
CPU = i386


HTH - TTFN

Mike
--
Accept that some days you're the pigeon, and some days you're the statue.

Taro MURAOKA

unread,
Nov 29, 2015, 10:07:11 AM11/29/15
to vim_dev
Mike Williams wrote

> Hi,
>
> Just done my first build of VIM on an old Windows 7 32bit machine
> upgraded to Windows 10 using VC. The link stage was failing due to
> mixed machine targets being used in the make file - 32 and 64 bit! I
> tracked this down to some fun with the PROCESSOR_ARCHITECTURE in a 32bit
> prompt on a 64bit machine, see -

Sorry but I disapprove this.

Because PROCESSOR_ARCHITEW6432 is set "AMD64" on 64bit OS
when using 32bit compiler.
Therefore, we never be able to build 32bit binary on 64bit OS,
if this patch would be applied.

So we should try/find another way.

Ken Takata

unread,
Nov 29, 2015, 10:13:23 AM11/29/15
to vim_dev
Hi Mike,

I currently build 32-bit and 64-bit Vim on 64-bit Win10 without changing the
Makefile. I use 32-bit compiler for 32-bit target and 64-bit compiler for
64-bit target, but you seem to use 32-bit cross compiler targeting 64-bit.
The current makefile assume that the bitness of nmake.exe is the same as the
target, and it doesn't support cross compiling.
We need another approach to support cross compiling.

Regards,
Ken Takata

Taro MURAOKA

unread,
Nov 29, 2015, 10:40:45 AM11/29/15
to vim_dev
I wrote:
> So we should try/find another way.

We may be able to use "Platform" environment variable for this purpose.
It get one of values: "x64", "X64", "X86" or "ARM" as cross compiling target,
in all of VS10, 11, 12, 14 environments.

You can see these variables at VC\bin\**\vcvars*.bat in each VS.

Taro MURAOKA

unread,
Nov 29, 2015, 11:57:10 AM11/29/15
to vim_dev
I wrote:
> We may be able to use "Platform" environment variable for this purpose.
> It get one of values: "x64", "X64", "X86" or "ARM" as cross compiling target,
> in all of VS10, 11, 12, 14 environments.


Hi Mike and Ken.


I have wrote a patch to use PLATFORM for this purpose.
Please try https://gist.github.com/koron/c51efe584d0b4e5686a4

Best.

Mike Williams

unread,
Nov 29, 2015, 12:04:36 PM11/29/15
to vim...@googlegroups.com
Hi Ken (and Taro),
I agree that my patch is the wrong solution. As Taro points out using
the Platform environment var should take into account the cross
compilation target. However it does not seem to be set for every
architecture passed to vcvarsall.bat. I'll try a few things and see
where they leads.

Mike Williams

unread,
Nov 29, 2015, 12:16:42 PM11/29/15
to vim...@googlegroups.com
There is still a problem when building 32bit when PROCESSOR_ARCHITECTURE
is amd64. I think that if PLATFORM is not defined it should default CPU
to i386 and not use PROCESSOR_ARCHITECTURE.

Mike Williams

unread,
Nov 29, 2015, 12:17:14 PM11/29/15
to vim...@googlegroups.com
My bad, too many command prompts with too many environments - Taro is on
the right track.

Mike Williams

unread,
Dec 6, 2015, 5:32:52 AM12/6/15
to vim...@googlegroups.com
Hi,

Another week, another diff. After some discussion with Ken and Taro I
offer up the following diff to cope with and (attempt to) tidy up cross
compilation across architectures with Visual Studio.


diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -209,22 +209,25 @@ OBJDIR = $(OBJDIR)d
!ifdef PROCESSOR_ARCHITECTURE
# We're on Windows NT or using VC 6+
! ifdef CPU
-ASSEMBLY_ARCHITECTURE=$(CPU)
# Using I386 for $ASSEMBLY_ARCHITECTURE doesn't work for VC7.
-! if ("$(ASSEMBLY_ARCHITECTURE)" == "i386") ||
("$(ASSEMBLY_ARCHITECTURE)" == "I386")
-ASSEMBLY_ARCHITECTURE = x86
-! endif
-! else
-CPU = $(PROCESSOR_ARCHITECTURE)
-ASSEMBLY_ARCHITECTURE = $(PROCESSOR_ARCHITECTURE)
-! if ("$(CPU)" == "x86") || ("$(CPU)" == "X86")
+! if "$(CPU)" == "I386"
CPU = i386
! endif
+! else # !CPU
+CPU = i386
+! ifdef PLATFORM
+! if ("$(PLATFORM)" == "x64") || ("$(PLATFORM)" == "X64")
+CPU = AMD64
+! elseif ("$(PLATFORM)" != "x86") && ("$(PLATFORM)" != "X86")
+! error *** ERROR Unknown target platform "$(PLATFORM)". Make aborted.
+! endif
+! endif # !PLATFORM
! endif
!else # !PROCESSOR_ARCHITECTURE
# We're on Windows 95
CPU = i386
!endif # !PROCESSOR_ARCHITECTURE
+ASSEMBLY_ARCHITECTURE=$(CPU)
OBJDIR = $(OBJDIR)$(CPU)

# Build a retail version by default
@@ -415,7 +418,7 @@ CPUARG =
!endif
!else
# VC8/9/10 only allows specifying SSE architecture but only for 32bit
-!if "$(ASSEMBLY_ARCHITECTURE)" == "x86" && "$(CPUNR)" == "pentium4"
+!if "$(ASSEMBLY_ARCHITECTURE)" == "i386" && "$(CPUNR)" == "pentium4"
CPUARG = /arch:SSE2
!endif
!endif


In theory you can target ARM from Intel host but I don't a system to
test that so I haven't tried to guess at the right code for it.

TTFN

Mike
--
Life is unfair but remember: sometimes it is unfair in your favour.

Bram Moolenaar

unread,
Dec 11, 2015, 1:39:17 PM12/11/15
to Mike Williams, vim...@googlegroups.com

Mike Williams wrote:

> Another week, another diff. After some discussion with Ken and Taro I
> offer up the following diff to cope with and (attempt to) tidy up cross
> compilation across architectures with Visual Studio.

[...]

> In theory you can target ARM from Intel host but I don't a system to
> test that so I haven't tried to guess at the right code for it.

Thanks, I'll include it. I hope I got it right (patch didn't manage to
do it, had to apply it manually).


--
You can tune a file system, but you can't tuna fish
-- man tunefs

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages