From daebaee22f843a7cbb9a7006d6c15382c8cac270 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 7 Aug 2026 01:36:25 -0700 Subject: [PATCH] build: add ARM64 architecture support to devcontainer Closes: https://github.com/stdlib-js/stdlib/issues/4934 --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .devcontainer/post-create | 27 ++++++++++++++++--- .../sha256 | 1 + docs/contributing/FAQ.md | 4 +-- .../contributing/setting_up_a_devcontainer.md | 6 +---- tools/make/lib/install/shellcheck.mk | 8 ++++-- 5 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 deps/checksums/shellcheck_v0_8_0_linux_aarch64_tar_xz/sha256 diff --git a/.devcontainer/post-create b/.devcontainer/post-create index 4e146fa36d11..4031fc14793f 100755 --- a/.devcontainer/post-create +++ b/.devcontainer/post-create @@ -18,10 +18,31 @@ # Script to set up a development environment. -make install -make init +arch="$(uname -m)" sudo apt-get update -sudo apt-get install -y gfortran + +# On ARM64, pin gcc/g++/gfortran to version 12 to avoid a GCC 16 and binutils version mismatch: +if [ "${arch}" = "aarch64" ]; then + sudo apt-get install -y gfortran-12 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 100 + sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-12 100 +else + sudo apt-get install -y gfortran +fi + +make install +make init make install-deps-r + +# On ARM64, replace the wrong-architecture shellcheck binary with the correct one: +if [ "${arch}" = "aarch64" ]; then + sc_version="$(shellcheck --version 2>/dev/null | grep '^version:' | awk '{print $2}')" + if [ -n "${sc_version}" ]; then + curl -sL "https://github.com/koalaman/shellcheck/releases/download/v${sc_version}/shellcheck-v${sc_version}.linux.aarch64.tar.xz" \ + | sudo tar xJ --strip-components=1 -C /usr/local/bin "shellcheck-v${sc_version}/shellcheck" + fi +fi diff --git a/deps/checksums/shellcheck_v0_8_0_linux_aarch64_tar_xz/sha256 b/deps/checksums/shellcheck_v0_8_0_linux_aarch64_tar_xz/sha256 new file mode 100644 index 000000000000..172a948d1628 --- /dev/null +++ b/deps/checksums/shellcheck_v0_8_0_linux_aarch64_tar_xz/sha256 @@ -0,0 +1 @@ +9f47bbff5624babfa712eb9d64ece14c6c46327122d0c54983f627ae3a30a4ac diff --git a/docs/contributing/FAQ.md b/docs/contributing/FAQ.md index 716ce79979fb..351536b4430c 100644 --- a/docs/contributing/FAQ.md +++ b/docs/contributing/FAQ.md @@ -64,7 +64,7 @@ There are primarily two options for setting up your development environment to c 1. [Manually setting up the development environment][manual-setup] 2. [Setting up the dev container][devcontainer-setup] -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]. +Note: The dev container supports both x86-64 and ARM64 architectures (including Apple Silicon). @@ -403,8 +403,6 @@ For more `make` commands, refer to the [documentation][benchmark] on running ben [devcontainer-setup]: https://github.com/stdlib-js/stdlib/blob/87cbd67623892f90ddeea94e1d4e01eeada417b5/docs/devcontainer_setup.md -[devcontainer-issue]: https://github.com/stdlib-js/stdlib/issues/4934 - [install-link]: https://github.com/stdlib-js/stdlib/tree/develop/tools/make/lib/install#install [ref-discussion]: https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205 diff --git a/docs/contributing/setting_up_a_devcontainer.md b/docs/contributing/setting_up_a_devcontainer.md index c962ad658771..ef1c697df323 100644 --- a/docs/contributing/setting_up_a_devcontainer.md +++ b/docs/contributing/setting_up_a_devcontainer.md @@ -28,9 +28,7 @@ We appreciate your interest in contributing to stdlib! Below, we've provided a s 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. -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. - -**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]. +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). ### Prerequisites @@ -121,8 +119,6 @@ If you see this when you open the terminal, then the dev container installation [vscode]: https://code.visualstudio.com/ -[devcontainer-issue]: https://github.com/stdlib-js/stdlib/issues/4934 - [github-fork]: https://help.github.com/articles/fork-a-repo/ diff --git a/tools/make/lib/install/shellcheck.mk b/tools/make/lib/install/shellcheck.mk index fd05645095b7..1f4cabc9a881 100644 --- a/tools/make/lib/install/shellcheck.mk +++ b/tools/make/lib/install/shellcheck.mk @@ -23,12 +23,16 @@ ifeq ($(OS), WINNT) DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).zip else ifeq ($(DEPS_SHELLCHECK_PLATFORM), darwin) - # TODO: handle arm64; currently, binaries for M1/M2 are not provided. See https://github.com/koalaman/shellcheck/issues/2714 + # TODO: handle arm64; currently, darwin.aarch64 binaries are not provided for v0.8.0. See https://github.com/koalaman/shellcheck/issues/2714 DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).darwin.x86_64.tar.xz +else +ifeq ($(DEPS_SHELLCHECK_ARCH), arm64) + DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).linux.aarch64.tar.xz else DEPS_SHELLCHECK_URL ?= https://github.com/koalaman/shellcheck/releases/download/v$(DEPS_SHELLCHECK_VERSION)/shellcheck-v$(DEPS_SHELLCHECK_VERSION).linux.x86_64.tar.xz endif endif +endif # Determine the basename for the download: deps_shellcheck_basename := $(notdir $(DEPS_SHELLCHECK_URL)) @@ -48,7 +52,7 @@ ifeq ($(DEPS_SHELLCHECK_PLATFORM), win32) else ifeq ($(DEPS_SHELLCHECK_PLATFORM), darwin) ifeq ($(DEPS_SHELLCHECK_ARCH), arm64) - # FIXME: this is a temporary workaround until M1/M2 shellcheck binaries can be installed locally + # FIXME: darwin.aarch64 binaries are not available for v0.8.0; fall back to system shellcheck SHELLCHECK ?= shellcheck else SHELLCHECK ?= $(DEPS_SHELLCHECK_BUILD_OUT)/shellcheck