Skip to content

Windows

Michael Grossniklaus edited this page Apr 5, 2024 · 6 revisions

This page provides a tutorial on how to build the LLVM frontend for the Oberon programming language on Windows. Since this project uses CMake to manage its build process, it is recommended to use the latest version of Visual Studio Community Edition. Starting with Visual Studio 2019, Visual Studio provides full support for CMake projects. Furthermore, the Microsoft toolchain (CL) is assumed to be used to compile the frontend.

[[TOC]]

Prerequisites

Before the Oberon LLVM frontend can be built, the Boost libraries (algorithm, convert, filesystem, and program-options components) and the LLVM Compiler Infrastructure (core libraries and tools) need to be installed. Using the Microsoft C++ Library Manager vcpkg for Windows is recommended to accomplish these tasks. Note that this tutorial assumes that standard build tools such as git, nmake, and cmake are available to build the frontend. Most of these tools are included in the path, if the commands given below are launched from the Native Tools Command Prompt for VS.

Installing vcpkg

Starting with Visual Studio 2022, a version of vcpkg is bundled with the Visual Studio installation. Even so, the installation of a stand-alone version by following the steps below is recommended.

  1. Download and bootstrap vcpkg.

    git clone https://github.com/Microsoft/vcpkg.git
    
    cd vcpkg
    
    .\bootstrap-vcpkg.bat
    
  2. If Visual Studio is used, configure automatic, user-wide integration of libraries managed by vcpkg.

    .\vcpkg integrate install
    

Installing Boost

.\vcpkg install boost-algorithm:x64-windows
.\vcpkg install boost-convert:x64-windows
.\vcpkg install boost-filesystem:x64-windows
.\vcpkg install boost-program-options:x64-windows

Installing LLVM

.\vcpkg install llvm[target-x86]:x64-windows

Note that vpkg will build and install the Debug and RelWithDebInfo version of LLVM. Since both builds contain debug information, this required a significant amount of free hard-disk space (typically around 100-150 GB) during compilation. Refer to the tutorial Building LLVM from Sources if that space is not available or if a later version of LLVM than the one provided by vcpkg is required.

A Note on Windows on Arm

To build and install Boost on LLVM use the platform triple arm64-windows instead of x64-windows in the commands above. Additionally, the command to build and install LLVM needs to include the option --allow-unsupported and target-aarch64 instead of target-x86 as shown below.

> .\vcpkg --allow-unsupported install llvm[target-aarch64]:arm64-windows

Building the Frontend

The LLVM frontend for the Oberon programming language on Windows can be built from the command line or using an IDE that supports CMake projects such as Visual Studio 2019 (or later).

Command Line

  1. Navigate to the oberon-lang directory and create a new build directory. Then, navigate to the newly created build directory.

    cd oberon-lang
    
    mkdir build
    
    cd build
    
  2. Invoke CMake to set up the build toolchain and generate the required build files.

    cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="%vcpkg_home%/scripts/buildsystems/vcpkg.cmake"
    
  3. As a result, CMake will generate Makefiles that can be used to build the frontend.

    nmake
    

After the build successfully terminates, the oberon-lang binary can be found in the oberon-lang/build/src subdirectory.

Visual Studio

In order to build the LLVM frontend for the Oberon programming language on Windows (x64), follow the steps below.

  1. Clone the project repository from GitLab.

    git clone https://gitlab.inf.uni-konstanz.de/michael.grossniklaus/oberon-lang.git
    
  2. Start Visual Studio and select FileOpenFolder... from the menu or press Ctrl+Shift+Alt+O.

  3. Navigate to the oberon-lang folder to which you cloned the project repository and click Select Folder.

  4. Visual Studio will now run CMake to set up the project. Make sure that the build configuration in the tool bar of Visual Studio matches the build type specified earlier. For example, if LLVM was compiled in Release mode, Visual Studio's build configuration has to be x64-Release or arm64-Release, depending on the hardware platform.

  5. Start the build using the BuildBuild All menu or press Ctrl+Shift+B.

Once the build successfully terminates, the oberon-lang.exe executable can be found in the oberon-lang\out\build\x64-Debug\src or oberon-lang\out\build\x64-Release\src directory. On Windows on Arm, the directories are oberon-lang\out\build\arm64-Debug\src or oberon-lang\out\build\arm64-Release\src, respectively.