Developing x86 apps on ARM with VS Code

Using Visual Studio Code remotes to develop on a different CPU architecture

Image credits: James Harrison
  • A number of Chromebook laptops
  • Devices running Windows 10 on ARM, like the Surface Pro X

The issues

I primarily build web applications with back-end services that are designed to run on a x86 Linux server, mostly within a Docker container. Chances are that you’re doing the same: in fact, Linux running on x86 chips is one of the most popular target platforms for server-side applications, if not the most popular.

  • Debugging: Regardless of how you end up compiling your application (maybe you have a Continuous Integration server that does the builds on Linux/x86 for you), the production binaries or Docker containers won’t run on your development box, so you won’t be able to debug them locally.
    Of course, you can always set up your CI server to generate builds for multiple architectures, but that means a more complex setup (if you’ve ever had to set up a multi-arch Docker build pipeline, I feel your pain) and double build times, so your Pull Requests take longer to be reviewed.
    Even if you do end up building multi-arch binaries, however, that complicates debugging because the different architecture can, in some cases, introduce variability in your app’s behavior. Your app might show bugs in one architecture only!
  • Dependencies: Even if your app is written in a language that runs on an interpreter, such as JavaScript/Node.js or Python, it’s not uncommon to have dependencies on native modules.
    While the amount of libraries that work on ARM has been growing steadily, there are still many that support only x86 architectures.
  • Tooling and services: Just like with libraries, the number of tools and services (including databases) that’s available for ARM is growing steadily, but it still lags behind what’s available for x86.
    Some examples that come to mind of popular tools that are currently only available for Linux/x86 include: Minio, Microsoft SQL Server, Couchbase… As another example: as of writing, on Docker Hub there are 3,971,370 images for x86–64, and only 47,352 images for ARM64, or just over 1% of the x86–64 ones.

Using VS Code remote extensions

The good news is that Visual Studio Code can help, thanks to the extensions for remote development that allow you to work connected to remote machines which can be using any CPU.

  • Remote — Containers allows you to code within a Docker container, which could be hosted locally (in which case it would probably be running on ARM64) but also remotely, on any server you can connect to via SSH

Developing via SSH

Using SSH to connect to a remote server is perhaps the simplest of the two approaches. This way, you tell VS Code to connect to any server (for example, a Linux box), keep your code there, and run every operation on the remote machine: this includes launching and debugging your code, installing dependencies, executing extensions, etc.

Using the VS Code command palette to run Remote-SSH: Connect to host
Using the VS Code command palette to run Remote-SSH: Connect to host
Adding SSH connection
Adding SSH connection
Indicator that there’s a remote session active
Indicator that there’s a remote session active
Open a folder in the remote host
Open a folder in the remote host

Developing with containers

Another extension of VS Code for remote development is the Remote — Containers one, which allows you to develop inside a Docker container.

  • It allows you to choose for each app or project what runtimes, libraries, frameworks, etc need to be available, and which version of those. For example, if one of your apps requires Java 8 and the other one is built for Java 13, using containers allows you to get each app its own isolated environment, with the correct version of the runtime for that project. Also, if everyone on your team uses the same environment, with the same dependencies, the “works on my machine” problem should hopefully be a thing of the past!
  1. You also need to be able to connect to the remote server via SSH using key-based authentication, with a key that is imported in your local SSH agent. The Remote — Containers extension currently doesn’t support asking for a password for the SSH server or for the SSH key.
  2. Lastly, you need to have the Docker CLI installed on your laptop. You don’t need to have Docker running (i.e. the Docker daemon or the Docker VM), but you need the CLI.
Setting docker.host in the VS Code settings
Setting docker.host in the VS Code settings
Viewing Docker containers running on the remote host
Viewing Docker containers running on the remote host

GitHub Codespaces

The last option is to leverage GitHub Codespaces, which is a development environment in the cloud that is fully-managed and works within VS Code too.

A codespace running in VS Code
A codespace running in VS Code
A codespace running in the browser
A codespace running in the browser

Cooker of great risotto. Sometimes tech nerd. Driving dev tools, @code & open source @Microsoft @Azure ☁️ Opinions are mine 🇮🇹🇨🇦🇺🇸

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store