Skip to content

Building on Windows

Hernán Morales Durand edited this page Feb 17, 2023 · 10 revisions

This page explain several variants to build the VM on Windows and their nuances.

Table of Contents

Building in Windows (Using Cygwin)

This tool should be installed, and the following Cygwin packages are needed:

  • cmake
  • mingw64-x86_64-clang
  • zip
  • unzip
  • wget
  • curl
  • make
  • git
  • libtool

To automate the Cygwin installation process there is scripts\installCygwin.ps1 which downloads and installs a chosen version of cygwin and mingw for a given architecture. For example the following installs the latest Cygwin (64 bit) and mingw64-x86_64-clang compiler:

.\scripts\installCygwin.ps1 setup-x86_64.exe x86_64

Do not forget to set the execution policy to Unrestricted (from the Admin PowerShell) in order to being able run the ps1 script:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Bulding the VM:

$ cmake .
$ make install

The VM is built from generated code and code written by hand. The generated code is the result of converting Smalltalk code into C. This conversion is performed during the cmake process.

This will generate the VM in build/dist/

Building in Windows (using Visual Studio)

  • All the builds in this page have been tested by using pre-generated sources.
  • Sources were generated on a *nix or osx environment by doing cmake -S . -B build -DFLAVOUR=SOME_FLAVOUR and cmake --build build --target generate-sources, and using the corresponding flavour.

TODO: document better how to generate sources in another page.

Building with Visual Studio 16 (2019) and CMake

Disclaimer: Windows Builds using clang-cl and MSVC have only been tested without FFI support nor Networking support. Also, we have only tested on Windows ARM64 support the non-JIT build. ARM64 support is already in beta for Unix Systems These will be added in a next iterations

Compiling on windows is as easy as importing the project in visual studio. The VM repository contains already the CMakeSettings.json file with base configurations to build (for msvc and clang-cl compilers).

You just need to select your desired configuration

image

And hit Build > Build All.

image

If everything went ok, you can build the Pharo VM package by clicking on Build > Install Pharo VM. This will generate the package in the build directory, inside build\dist\Debug.

Configure the Build

The build has many options and configurations that can be changed visually from the Visual Studio IDE. Go to the Manage Configurations option, and edit the CMake variables with your options.

image image

For a detailed explanation about the options, see Pharo CMake Configuration Options.

Microsoft's Clang-cl vs MSVC compiler

When using Windows nowadays, there is kind of a salad of compilers and build systems. We use CMake to try to standarize this a bit, as CMake is a pretty mature and portable build system, with good support in many systems and IDEs.

The question that remains is that one of what compiler to use in Windows, now supporting the traditional MSVC, clang-cl and gcc. GCC on windows is mostly used for its linux subsystem and MinGW support. Clang-cl is, as explained in here:

clang-cl, a driver program for clang that attempts to be compatible with MSVC’s cl.exe.

Clang-cl builds do work with the standard CMake configuration.

MSVC requires to enable FEATURE_COMPILE_INLINE_MEMORY_ACCESSORS because of a pre-processor error we hit MSVC when defining the longAt & family macros. The option FEATURE_COMPILE_INLINE_MEMORY_ACCESSORS forces the definition of longAt & friends as normal functions instead of macros to make it work. It is still an open question whether this has an impact on performance or not.

Building for ARM64 on the Surface Pro X using Windows x86 emulation

Disclaimer: all this has been tested from a Surface Pro X Windows 10 machine, using Visual Studio 16

Windows has by default support for compiling for ARM devices using MSVC-arm and MSVC-arm64 compilers. For more details on ARM64 support for windows, check out: https://blogs.windows.com/windowsdeveloper/2018/11/15/official-support-for-windows-10-on-arm-development/

As for the moment I'm writing this document, Visual Studio lacks still support to manage configurations for ARM64, although CMake does support it. Compiling for ARM64 can be done from the command line as follows:

$ cmake path\to\project\ -G "Visual Studio 16 2019" -A ARM64 -DFEATURE_SOCKETS=FALSE -DWITHOUT_DEPENDENCIES=TRUE -DGENERATE_SOURCES=FALSE -DFEATURE_FFI=FALSE -DGENERATED_SOURCE_DIR=Stack64 -DFEATURE_COMPILE_GNUISATION=FALSE -DFLAVOUR=StackVM
$ cmake --build . --config Release

Notice also that running the ARM64 VM needs to be compiled in Release mode. Somehow, Visual Studio on the Surface Pro X does seem to have some problem with the Debug builds, linking the VM with dlls that cannot be found at runtime. Several "workarounds" are posted on forums online, but I did not want to pollute this documentation with them, with the hope of having them resolved as soon as Visual Studio ARM64 support evolves.

Clone this wiki locally