Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ steps:
echo "##vso[task.setvariable variable=RPM_PACKAGE_NAME]$(basename $(ls .build/linux/rpm/*.rpm))"
displayName: Build rpm package

- ${{ if eq(parameters.VSCODE_ARCH, 'x64') }}:
- ${{ if or(eq(parameters.VSCODE_ARCH, 'x64'), eq(parameters.VSCODE_ARCH, 'arm64')) }}:
- task: Docker@1
inputs:
azureSubscriptionEndpoint: vscode
Expand All @@ -323,7 +323,7 @@ steps:
- script: |
set -e
npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-snap"
sudo -E docker run -e VSCODE_ARCH -e VSCODE_QUALITY -v $(pwd):/work -w /work vscodehub.azurecr.io/vscode-linux-build-agent:snapcraft-x64 /bin/bash -c "./build/azure-pipelines/linux/build-snap.sh"
sudo -E docker run -e VSCODE_ARCH -e VSCODE_QUALITY -v $(pwd):/work -w /work vscodehub.azurecr.io/vscode-linux-build-agent:snapcraft-$(VSCODE_ARCH) /bin/bash -c "./build/azure-pipelines/linux/build-snap.sh"

SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)"
SNAP_EXTRACTED_PATH=$(find $SNAP_ROOT -maxdepth 1 -type d -name 'code-*')
Expand Down
1 change: 1 addition & 0 deletions build/azure-pipelines/product-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ extends:
VSCODE_ARCH: arm64
VSCODE_QUALITY: ${{ variables.VSCODE_QUALITY }}
VSCODE_CIBUILD: ${{ variables.VSCODE_CIBUILD }}
VSCODE_BUILD_LINUX_SNAP: ${{ parameters.VSCODE_BUILD_LINUX_SNAP }}

- ${{ if and(eq(variables['VSCODE_CIBUILD'], false), eq(parameters.VSCODE_COMPILE_ONLY, false), eq(variables['VSCODE_BUILD_STAGE_ALPINE'], true)) }}:
- stage: Alpine
Expand Down
4 changes: 3 additions & 1 deletion build/gulpfile.vscode.linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ function prepareSnapPackage(arch: string) {
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 values https://snapcraft.io/docs/architectures
// 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'))
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))

Copilot uses AI. Check for mistakes.
.pipe(rename('snap/snapcraft.yaml'));

const electronLaunch = gulp.src('resources/linux/snap/electron-launch', { base: '.' })
Expand Down
16 changes: 7 additions & 9 deletions resources/linux/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ description: |
edit-build-debug cycle.

architectures:
- build-on: amd64
- build-on: @@BUILD_ARCHITECTURE@@
run-on: @@ARCHITECTURE@@

grade: stable
confinement: classic
base: core20
base: core24
compression: lzo

parts:
Expand All @@ -27,9 +27,7 @@ parts:
- libatspi2.0-0
- libcairo2
- libcanberra-gtk3-module
- libcurl3-gnutls
- libcurl3-nss
- libcurl4
- libcurl4t64
- libegl1
- libdrm2
- libgbm1
Expand Down Expand Up @@ -59,18 +57,18 @@ parts:
- -usr/share/lintian
- -usr/share/man
override-build: |
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
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. The DEB_ARCHITECTURE variable should contain the full triplet (x86_64-linux-gnu, aarch64-linux-gnu, arm-linux-gnueabihf), OR
  2. 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.

Suggested change
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

Copilot uses AI. Check for mistakes.
chmod 0755 $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome-sandbox
cleanup:
after:
- code
plugin: nil
build-snaps:
- core20
- core24
override-prime: |
set -eux
for snap in "core20"; do
for snap in "core24"; do
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
done
patchelf --print-rpath $SNAPCRAFT_PRIME/usr/share/@@NAME@@/chrome_crashpad_handler
Expand Down
Loading