Skip to content

Commit 4982836

Browse files
build: add ARM64 architecture support to devcontainer
PR-URL: #14008 Reviewed-by: Athan Reines <kgryte@gmail.com> Closes: stdlib-js/metr-issue-tracker#1123 Closes: #4934
1 parent 1c2449f commit 4982836

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

.devcontainer/post-create

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,31 @@
1818

1919
# Script to set up a development environment.
2020

21-
make install
22-
make init
21+
arch="$(uname -m)"
2322

2423
sudo apt-get update
25-
sudo apt-get install -y gfortran
24+
25+
# On ARM64, pin gcc/g++/gfortran to version 12 to avoid a GCC 16 and binutils version mismatch:
26+
if [ "${arch}" = "aarch64" ]; then
27+
sudo apt-get install -y gfortran-12
28+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
29+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100
30+
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 100
31+
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-12 100
32+
else
33+
sudo apt-get install -y gfortran
34+
fi
35+
36+
make install
37+
make init
2638

2739
make install-deps-r
40+
41+
# On ARM64, replace the wrong-architecture shellcheck binary with the correct one:
42+
if [ "${arch}" = "aarch64" ]; then
43+
sc_version="$(shellcheck --version 2>/dev/null | grep '^version:' | awk '{print $2}')"
44+
if [ -n "${sc_version}" ]; then
45+
curl -sL "https://github.com/koalaman/shellcheck/releases/download/v${sc_version}/shellcheck-v${sc_version}.linux.aarch64.tar.xz" \
46+
| sudo tar xJ --strip-components=1 -C /usr/local/bin "shellcheck-v${sc_version}/shellcheck"
47+
fi
48+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9f47bbff5624babfa712eb9d64ece14c6c46327122d0c54983f627ae3a30a4ac

docs/contributing/FAQ.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ There are primarily two options for setting up your development environment to c
6464
1. [Manually setting up the development environment][manual-setup]
6565
2. [Setting up the dev container][devcontainer-setup]
6666

67-
Note: The dev container does not yet support ARM64 architectures. For more information, or if you're interested in adding ARM64 support, you can visit this [issue][devcontainer-issue].
67+
Note: The dev container supports both x86-64 and ARM64 architectures (including Apple Silicon).
6868

6969
<a name="install-cppcheck"></a>
7070

@@ -403,8 +403,6 @@ For more `make` commands, refer to the [documentation][benchmark] on running ben
403403
404404
[devcontainer-setup]: https://github.com/stdlib-js/stdlib/blob/87cbd67623892f90ddeea94e1d4e01eeada417b5/docs/devcontainer_setup.md
405405
406-
[devcontainer-issue]: https://github.com/stdlib-js/stdlib/issues/4934
407-
408406
[install-link]: https://github.com/stdlib-js/stdlib/tree/develop/tools/make/lib/install#install
409407
410408
[ref-discussion]: https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205

docs/contributing/setting_up_a_devcontainer.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ We appreciate your interest in contributing to stdlib! Below, we've provided a s
2828

2929
Dev containers are Docker containers that are specifically configured to provide a fully featured development environment with the right tooling, extensions, linting and formatting. They allow you to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set.
3030

31-
The stdlib repository includes a preconfigured dev container, making it the easiest way to set up your development environment. It ensures proper linting, EditorConfig, and tooling are configured right from the start.
32-
33-
**Note:** The dev container does not yet support ARM64 architectures. For more information, or if you're interested in adding ARM64 support, you can visit this [issue][devcontainer-issue].
31+
The stdlib repository includes a preconfigured dev container, making it the easiest way to set up your development environment. It ensures proper linting, EditorConfig, and tooling are configured right from the start. The dev container supports both x86-64 and ARM64 architectures (including Apple Silicon).
3432

3533
### Prerequisites
3634

@@ -121,8 +119,6 @@ If you see this when you open the terminal, then the dev container installation
121119

122120
[vscode]: https://code.visualstudio.com/
123121

124-
[devcontainer-issue]: https://github.com/stdlib-js/stdlib/issues/4934
125-
126122
[github-fork]: https://help.github.com/articles/fork-a-repo/
127123

128124
</section>

tools/make/lib/install/shellcheck.mk

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ ifeq ($(OS), WINNT)
2323
DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).zip
2424
else
2525
ifeq ($(DEPS_SHELLCHECK_PLATFORM), darwin)
26-
# TODO: handle arm64; currently, binaries for M1/M2 are not provided. See https://github.com/koalaman/shellcheck/issues/2714
26+
# TODO: handle arm64; currently, darwin.aarch64 binaries are not provided for v0.8.0. See https://github.com/koalaman/shellcheck/issues/2714
2727
DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).darwin.x86_64.tar.xz
28+
else
29+
ifeq ($(DEPS_SHELLCHECK_ARCH), arm64)
30+
DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).linux.aarch64.tar.xz
2831
else
2932
DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).linux.x86_64.tar.xz
3033
endif
3134
endif
35+
endif
3236

3337
# Determine the basename for the download:
3438
deps_shellcheck_basename := $(notdir $(DEPS_SHELLCHECK_URL))
@@ -48,7 +52,7 @@ ifeq ($(DEPS_SHELLCHECK_PLATFORM), win32)
4852
else
4953
ifeq ($(DEPS_SHELLCHECK_PLATFORM), darwin)
5054
ifeq ($(DEPS_SHELLCHECK_ARCH), arm64)
51-
# FIXME: this is a temporary workaround until M1/M2 shellcheck binaries can be installed locally
55+
# FIXME: darwin.aarch64 binaries are not available for v0.8.0; fall back to system shellcheck
5256
SHELLCHECK ?= shellcheck
5357
else
5458
SHELLCHECK ?= $(DEPS_SHELLCHECK_BUILD_OUT)/shellcheck

0 commit comments

Comments
 (0)