Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds ARM64 support to VS Code Snap packages by updating the build infrastructure, snapcraft configuration, and Azure CI/CD pipelines. The changes address long-standing feature requests (#125120, #269552) for ARM64 snap packages on Linux systems.
Changes:
- Updated snapcraft.yaml to support multi-architecture builds (x64 and arm64) and upgraded from Ubuntu 20.04 (core20) to 24.04 (core24) base
- Modified build scripts to generate architecture-specific snapcraft configurations with appropriate multiarch library paths
- Extended Azure pipeline to build and publish ARM64 snap packages alongside existing x64 packages
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| resources/linux/snap/snapcraft.yaml | Added architecture template variables, upgraded to core24 base, updated dependencies and library paths for multiarch support |
| build/gulpfile.vscode.linux.ts | Added BUILD_ARCHITECTURE and DEB_ARCHITECTURE template variable replacements for architecture-specific snap builds |
| build/azure-pipelines/product-build.yml | Propagated VSCODE_BUILD_LINUX_SNAP parameter to arm64 build job |
| build/azure-pipelines/linux/steps/product-build-linux-compile.yml | Extended snap build condition to include arm64 architecture and updated docker image reference to be architecture-specific |
| // Possible run-on/build-on values https://snapcraft.io/docs/architectures | ||
| .pipe(replace('@@ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch)) | ||
| .pipe(replace('@@BUILD_ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch)) | ||
| .pipe(replace('@@DEB_ARCHITECTURE@@', arch === 'x64' ? 'x86_64' : 'aarch64')) |
There was a problem hiding this comment.
The DEB_ARCHITECTURE mapping logic is incorrect because it only handles x64 and arm64 architectures. When arch is 'armhf', this ternary expression will incorrectly map it to 'aarch64' instead of the correct 'arm-linux-gnueabihf'.
This will cause the patchelf command in snapcraft.yaml to use the wrong library path for armhf builds, potentially breaking the snap package.
The mapping should handle all three architectures (x64, arm64, armhf) correctly. Looking at the rest of the codebase (e.g., build/linux/debian/calculate-deps.ts:51-54), armhf should map to 'arm-linux-gnueabihf', arm64 to 'aarch64-linux-gnu', and x64 to 'x86_64-linux-gnu'.
See below for a potential fix:
const debArchitecture =
arch === 'x64' ? 'x86_64-linux-gnu' :
arch === 'arm64' ? 'aarch64-linux-gnu' :
arch === 'armhf' ? 'arm-linux-gnueabihf' :
arch;
const snapcraft = gulp.src('resources/linux/snap/snapcraft.yaml', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@VERSION@@', commit!.substr(0, 8)))
// Possible run-on/build-on values https://snapcraft.io/docs/architectures
.pipe(replace('@@ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch))
.pipe(replace('@@BUILD_ARCHITECTURE@@', arch === 'x64' ? 'amd64' : arch))
.pipe(replace('@@DEB_ARCHITECTURE@@', debArchitecture))
| snapcraftctl build | ||
| patchelf --force-rpath --set-rpath '$ORIGIN/../../lib/x86_64-linux-gnu:$ORIGIN:/snap/core20/current/lib/x86_64-linux-gnu' $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome_crashpad_handler | ||
| craftctl default | ||
| patchelf --force-rpath --set-rpath '$ORIGIN/../../lib/@@DEB_ARCHITECTURE@@-linux-gnu:$ORIGIN:/snap/core24/current/lib/@@DEB_ARCHITECTURE@@-linux-gnu' $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome_crashpad_handler |
There was a problem hiding this comment.
The patchelf path construction in snapcraft.yaml assumes a uniform multiarch triplet format by hardcoding '-linux-gnu' after the DEB_ARCHITECTURE variable. However, this doesn't work for all architectures:
- x64: x86_64-linux-gnu ✓
- arm64: aarch64-linux-gnu ✓
- armhf: arm-linux-gnueabihf ✗ (would become arm-linux-gnu, which is incorrect)
For armhf, the correct multiarch triplet is 'arm-linux-gnueabihf', not 'arm-linux-gnu'. This means either:
- The DEB_ARCHITECTURE variable should contain the full triplet (x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf), OR
- A separate template variable should be used for the full multiarch triplet
The same issue exists in the gulpfile.vscode.linux.ts mapping on line 268, which would need to be updated accordingly.
| patchelf --force-rpath --set-rpath '$ORIGIN/../../lib/@@DEB_ARCHITECTURE@@-linux-gnu:$ORIGIN:/snap/core24/current/lib/@@DEB_ARCHITECTURE@@-linux-gnu' $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome_crashpad_handler | |
| patchelf --force-rpath --set-rpath '$ORIGIN/../../lib/@@DEB_MULTIARCH@@:$ORIGIN:/snap/core24/current/lib/@@DEB_MULTIARCH@@' $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome_crashpad_handler |
Fixes #125120
Fixes #269552