lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

quick-lint-js: support cross compiling

quick-lint-js' build system supports cross compiling, but it's not
automatic.

Prior to quick-lint-js version 2.13, cross compiling with Nix works
because some build-time tools are optional. These build-time tools need
a compiler from buildPackages.stdenv. Version 2.13 made these build-time
tools required.

Refactor the quick-lint-js package to use quick-lint-js' cross
compilation support. This fixes cross compilation with Nix.

Upstream documentation for cross compiling:
https://quick-lint-js.com/contribute/build-from-source/cross-compiling/

Testing:

# Test Linux x86_64 cross compiling for Linux AArch64:
x86$ uname -a
Linux strapurp 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
x86$ nix-shell -p pkgsCross.aarch64-multiplatform.quick-lint-js --run 'file $(which quick-lint-js)'
/nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/bin/quick-lint-js: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /nix/store/5gdh4mp8rwliq4s33gwcpwzqvsb2xpzr-glibc-aarch64-unknown-linux-gnu-2.38-23/lib/ld-linux-aarch64.so.1, for GNU/Linux 3.10.0, not stripped

# Test the binary on a Linux AArch64 machine:
x86$ nix --extra-experimental-features nix-command copy --to ssh-ng://parallels@192.168.4.144 /nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/
arm$ /nix/store/3rdxhjxdmiwz1zg2mi477ysc9nb7jsqx-quick-lint-js-aarch64-unknown-linux-gnu-2.17.0/bin/quick-lint-js --version
quick-lint-js version 2.17.0

+69 -6
+32
pkgs/development/tools/quick-lint-js/build-tools-install.patch
··· 1 + From 3923f0df76d24b73d57f15eec61ab190ea048093 Mon Sep 17 00:00:00 2001 2 + From: "Matthew \"strager\" Glazar" <strager.nds@gmail.com> 3 + Date: Thu, 26 Oct 2023 18:08:30 -0400 4 + Subject: [PATCH] fix(build): fix installing build tools for cross-compilation 5 + 6 + 'cmake --install . --component build-tools' copies no files [1]. This 7 + was caused by commit 1f2e1a47 where the code calling install() became 8 + dead code on accident. Call install() so that 'cmake --install' copies 9 + the build artifacts as intended. 10 + 11 + [1] https://github.com/quick-lint/quick-lint-js/issues/1099 12 + 13 + Refs: 1f2e1a4701793cac24eaac44d7af81a8b820b1bc 14 + --- 15 + docs/CHANGELOG.md | 7 +++++++ 16 + tools/CMakeLists.txt | 1 - 17 + 2 files changed, 7 insertions(+), 1 deletion(-) 18 + 19 + (docs/CHANGELOG.md changes omitted to reduce conflicts.) 20 + 21 + diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt 22 + index 71ccbdf1b..b541afb52 100644 23 + --- a/tools/CMakeLists.txt 24 + +++ b/tools/CMakeLists.txt 25 + @@ -68,7 +68,6 @@ if (QUICK_LINT_JS_ENABLE_BUILD_TOOLS) 26 + COMMENT "Building all quick-lint-js build-time tools" 27 + DEPENDS ${QUICK_LINT_JS_BUILD_TOOL_TARGETS} 28 + ) 29 + -elseif (QUICK_LINT_JS_ENABLE_BUILD_TOOLS) 30 + install( 31 + TARGETS ${QUICK_LINT_JS_BUILD_TOOL_TARGETS} 32 + COMPONENT build-tools
+37 -6
pkgs/development/tools/quick-lint-js/default.nix
··· 1 - { cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }: 2 - 1 + { buildPackages, cmake, fetchFromGitHub, lib, ninja, stdenv, testers, quick-lint-js }: 3 2 4 - stdenv.mkDerivation rec { 5 - pname = "quick-lint-js"; 3 + let 6 4 version = "2.17.0"; 7 5 8 6 src = fetchFromGitHub { ··· 12 10 sha256 = "sha256-5+Cyw1cLgBkTePNNFoNAF2oHnLQDHr4vHiaZHJrewug="; 13 11 }; 14 12 13 + quick-lint-js-build-tools = buildPackages.stdenv.mkDerivation { 14 + pname = "quick-lint-js-build-tools"; 15 + inherit version src; 16 + 17 + patches = [ ./build-tools-install.patch ]; 18 + 19 + nativeBuildInputs = [ cmake ninja ]; 20 + doCheck = false; 21 + 22 + cmakeFlags = [ 23 + "-DQUICK_LINT_JS_ENABLE_BUILD_TOOLS=ON" 24 + # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379 25 + "-DCMAKE_SKIP_BUILD_RPATH=ON" 26 + ]; 27 + ninjaFlags = "quick-lint-js-build-tools"; 28 + 29 + installPhase = '' 30 + runHook preInstall 31 + cmake --install . --component build-tools 32 + runHook postInstall 33 + ''; 34 + }; 35 + in 36 + stdenv.mkDerivation rec { 37 + pname = "quick-lint-js"; 38 + inherit version src; 39 + 15 40 nativeBuildInputs = [ cmake ninja ]; 16 41 doCheck = true; 17 42 18 - # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379 19 - cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=ON" ]; 43 + cmakeFlags = [ 44 + "-DQUICK_LINT_JS_USE_BUILD_TOOLS=${quick-lint-js-build-tools}/bin" 45 + # Temporary workaround for https://github.com/NixOS/nixpkgs/pull/108496#issuecomment-1192083379 46 + "-DCMAKE_SKIP_BUILD_RPATH=ON" 47 + ]; 20 48 21 49 passthru.tests = { 22 50 version = testers.testVersion { package = quick-lint-js; }; ··· 29 57 maintainers = with maintainers; [ ratsclub ]; 30 58 platforms = platforms.all; 31 59 }; 60 + 61 + # Expose quick-lint-js-build-tools to nix repl as quick-lint-js.build-tools. 62 + passthru.build-tools = quick-lint-js-build-tools; 32 63 }