From c3689f9f64e5f1fc0e2594e4bfcb6b08a25cca2b Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 25 Aug 2026 08:04:25 +0530 Subject: [PATCH 1/2] Skip Claude and Pi on CPUs without SSE4.2/POPCNT Bun's linux-x64 natives SIGILL on x86-64-v1 (Core 2 Duo and similar). Detect the baseline before install, print a reason, and hide those menu entries. ARM/aarch64, including Apple Silicon and Asahi, still installs. --- bin/omarchy-default-agent | 5 ++++ bin/omarchy-hw-cpu-sse4_2 | 47 ++++++++++++++++++++++++++++++ bin/omarchy-mise-install-bun | 19 ++++++++++++ default/omarchy/omarchy-menu.jsonc | 4 +-- install/user/mise.sh | 4 +-- 5 files changed, 75 insertions(+), 4 deletions(-) create mode 100755 bin/omarchy-hw-cpu-sse4_2 create mode 100755 bin/omarchy-mise-install-bun diff --git a/bin/omarchy-default-agent b/bin/omarchy-default-agent index 1f89b7652bfd..9f00c8ec4f17 100755 --- a/bin/omarchy-default-agent +++ b/bin/omarchy-default-agent @@ -42,6 +42,11 @@ esac agent_package=${agent_package:-$agent} +if [[ $agent == claude || $agent == pi ]] && ! omarchy-hw-cpu-sse4_2; then + echo "Cannot install $name: this CPU lacks SSE4.2/POPCNT, which Bun's linux-x64 builds need" >&2 + exit 1 +fi + if [[ $installing == "false" ]] && ! mise where "$agent_package" &>/dev/null; then exec omarchy-launch-floating-terminal-with-presentation omarchy-default-agent --install "$agent" fi diff --git a/bin/omarchy-hw-cpu-sse4_2 b/bin/omarchy-hw-cpu-sse4_2 new file mode 100755 index 000000000000..a7b75e31e1aa --- /dev/null +++ b/bin/omarchy-hw-cpu-sse4_2 @@ -0,0 +1,47 @@ +#!/bin/bash + +# omarchy:summary=Returns true when the CPU has SSE4.2 and POPCNT, or is not x86_64. + +# Bun's linux-x64 target needs SSE4.2 and POPCNT. x86-64-v1 CPUs (Core 2 Duo, +# first-gen Atom, …) install the natives then SIGILL. ARM/aarch64 — including +# Apple Silicon and Asahi — uses a different build and should still install. +# +# OMARCHY_CPUINFO and OMARCHY_ARCH override /proc/cpuinfo and uname for tests. + +cpuinfo=${OMARCHY_CPUINFO:-/proc/cpuinfo} +arch=${OMARCHY_ARCH:-} + +cpu_has_bun_x64_flags() { + local flags=$1 + + [[ " $flags " == *" sse4_2 "* && " $flags " == *" popcnt "* ]] +} + +if [[ -z $arch && -r $cpuinfo ]]; then + if grep -q '^flags[[:space:]]*:' "$cpuinfo"; then + arch=x86_64 + elif grep -qiE '^(features|cpu architecture)[[:space:]]*:' "$cpuinfo"; then + arch=aarch64 + fi +fi + +if [[ -z $arch ]]; then + arch=$(uname -m) +fi + +case $arch in +aarch64 | arm64) + exit 0 + ;; +esac + +flags="" +if [[ -r $cpuinfo ]]; then + flags=$(awk -F: '/^flags[[:space:]]*:/{print $2; exit}' "$cpuinfo") +fi + +if [[ -z $flags ]] && command -v lscpu >/dev/null; then + flags=$(lscpu 2>/dev/null | awk -F: '/^Flags:/{print $2; exit}') +fi + +cpu_has_bun_x64_flags "$flags" diff --git a/bin/omarchy-mise-install-bun b/bin/omarchy-mise-install-bun new file mode 100755 index 000000000000..9ff64c8e57a2 --- /dev/null +++ b/bin/omarchy-mise-install-bun @@ -0,0 +1,19 @@ +#!/bin/bash + +# omarchy:summary=Install a Bun linux-x64 agent when the CPU can run it. +# omarchy:args= [command-name [bin-name]] +# omarchy:hidden=true + +# Claude and Pi ship Bun linux-x64 natives that SIGILL without SSE4.2/POPCNT. +# Skip (don't install) on incompatible x86; ARM/aarch64 still installs. + +if [[ -z $1 ]]; then + echo "Usage: omarchy-mise-install-bun [command-name [bin-name]]" + exit 1 +fi + +if omarchy-hw-cpu-sse4_2; then + omarchy-mise-install "$@" +else + echo "Skipping $1: this CPU lacks SSE4.2/POPCNT, which Bun's linux-x64 builds need" +fi diff --git a/default/omarchy/omarchy-menu.jsonc b/default/omarchy/omarchy-menu.jsonc index 59582db73457..693cecd3a6f7 100644 --- a/default/omarchy/omarchy-menu.jsonc +++ b/default/omarchy/omarchy-menu.jsonc @@ -136,7 +136,7 @@ "setup.default": {"icon":"","label":"Defaults","aliases":["default","defaults"]}, "setup.default.agent": {"icon":"󰚩","label":"Agent","title":"Default Agent"}, "setup.default.agent.agy": {"icon":"󰫢","label":"Antigravity","checked":"[[ \"$(omarchy-default-agent)\" == \"agy\" ]]","action":"omarchy-default-agent agy"}, - "setup.default.agent.claude": {"icon":"󰛄","label":"Claude","checked":"[[ \"$(omarchy-default-agent)\" == \"claude\" ]]","action":"omarchy-default-agent claude"}, + "setup.default.agent.claude": {"icon":"󰛄","label":"Claude","when":"omarchy-hw-cpu-sse4_2","checked":"[[ \"$(omarchy-default-agent)\" == \"claude\" ]]","action":"omarchy-default-agent claude"}, "setup.default.agent.codex": {"icon":"","iconFont":"omarchy","label":"Codex","checked":"[[ \"$(omarchy-default-agent)\" == \"codex\" ]]","action":"omarchy-default-agent codex"}, "setup.default.agent.copilot": {"icon":"","label":"Copilot","checked":"[[ \"$(omarchy-default-agent)\" == \"copilot\" ]]","action":"omarchy-default-agent copilot"}, "setup.default.agent.crush": {"icon":"󰋑","label":"Crush","checked":"[[ \"$(omarchy-default-agent)\" == \"crush\" ]]","action":"omarchy-default-agent crush"}, @@ -144,7 +144,7 @@ "setup.default.agent.omp": {"icon":"","iconFont":"omarchy","label":"omp","checked":"[[ \"$(omarchy-default-agent)\" == \"omp\" ]]","action":"omarchy-default-agent omp"}, "setup.default.agent.opencode": {"icon":"","iconFont":"omarchy","label":"OpenCode","checked":"[[ \"$(omarchy-default-agent)\" == \"opencode\" ]]","action":"omarchy-default-agent opencode"}, "setup.default.agent.ori": {"icon":"","iconFont":"omarchy","label":"Ori","checked":"[[ \"$(omarchy-default-agent)\" == \"ori\" ]]","action":"omarchy-default-agent ori"}, - "setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, + "setup.default.agent.pi": {"icon":"","iconFont":"omarchy","label":"Pi","when":"omarchy-hw-cpu-sse4_2","checked":"[[ \"$(omarchy-default-agent)\" == \"pi\" ]]","action":"omarchy-default-agent pi"}, "setup.default.browser": {"icon":"","label":"Browser","title":"Default Browser"}, "setup.default.browser.chromium": {"icon":"","label":"Chromium","checked":"[[ \"$(omarchy-default-browser)\" == \"chromium\" ]]","action":"omarchy-default-browser chromium"}, "setup.default.browser.chrome": {"icon":"󰊯","label":"Chrome","checked":"[[ \"$(omarchy-default-browser)\" == \"chrome\" ]]","action":"omarchy-default-browser chrome"}, diff --git a/install/user/mise.sh b/install/user/mise.sh index 0c8ab99b18b0..22481cf1f965 100644 --- a/install/user/mise.sh +++ b/install/user/mise.sh @@ -1,12 +1,12 @@ omarchy-mise-install codex -omarchy-mise-install claude +omarchy-mise-install-bun claude omarchy-mise-install crush omarchy-mise-install antigravity-cli agy omarchy-mise-install gh omarchy-mise-install copilot omarchy-mise-install opencode omarchy-mise-install npm:playwright playwright -omarchy-mise-install pi +omarchy-mise-install-bun pi omarchy-mise-install github:can1357/oh-my-pi omp omarchy-mise-install npm:@xai-official/grok grok omarchy-mise-install npm:@kitlangton/ghui ghui From 7649372f3405a98aea163f37d99c68e74aeef16f Mon Sep 17 00:00:00 2001 From: Taksh Date: Tue, 25 Aug 2026 08:04:28 +0530 Subject: [PATCH 2/2] Test Bun agent skips on CPUs without SSE4.2/POPCNT Stub cpuinfo via OMARCHY_CPUINFO: missing sse4_2 skips install, sse4_2+popcnt and aarch64 still install. --- test/shell.d/bun-agent-cpu-test.sh | 170 +++++++++++++++++++++++++++++ test/shell.d/menu-test.sh | 7 +- 2 files changed, 174 insertions(+), 3 deletions(-) create mode 100755 test/shell.d/bun-agent-cpu-test.sh diff --git a/test/shell.d/bun-agent-cpu-test.sh b/test/shell.d/bun-agent-cpu-test.sh new file mode 100755 index 000000000000..ca9322958697 --- /dev/null +++ b/test/shell.d/bun-agent-cpu-test.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +mock_bin="$test_tmp/bin" +test_home="$test_tmp/home" +cpuinfo_dir="$test_tmp/cpuinfo" +mise_log="$test_tmp/mise" +skip_log="$test_tmp/skip" +mkdir -p "$mock_bin" "$test_home" "$cpuinfo_dir" + +cat >"$mock_bin/omarchy-mise-install" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_LOG" +SH +chmod +x "$mock_bin/omarchy-mise-install" + +cat >"$cpuinfo_dir/core2duo" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 23 +model name : Intel(R) Core(TM)2 Duo CPU E7600 @ 3.06GHz +stepping : 10 +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc art arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow vnmi flexpriority +EOF + +cat >"$cpuinfo_dir/haswell" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 60 +model name : Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz +stepping : 3 +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts md_clear flush_l1d +EOF + +cat >"$cpuinfo_dir/aarch64" <<'EOF' +processor : 0 +BogoMIPS : 48.00 +Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop +CPU implementer : 0x41 +CPU architecture: 8 +CPU variant : 0x4 +CPU part : 0xd0b +CPU revision : 1 +EOF + +cat >"$cpuinfo_dir/sse4_2-only" <<'EOF' +processor : 0 +vendor_id : GenuineIntel +flags : fpu sse sse2 sse3 ssse3 sse4_1 sse4_2 +EOF + +export PATH="$mock_bin:$ROOT/bin:$PATH" +export HOME="$test_home" +export OMARCHY_PATH="$ROOT" +export OMARCHY_TEST_MISE_LOG="$mise_log" + +hw_cpu() { + "$ROOT/bin/omarchy-hw-cpu-sse4_2" +} + +assert_hw() { + local description=$1 expected=$2 + local actual=no + + hw_cpu && actual=yes + [[ $actual == "$expected" ]] || fail "$description" "expected $expected, got $actual" + pass "$description" +} + +OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "x86 without sse4_2 is not Bun linux-x64 compatible" no +OMARCHY_CPUINFO="$cpuinfo_dir/sse4_2-only" assert_hw "x86 with sse4_2 but no popcnt is not Bun linux-x64 compatible" no +OMARCHY_CPUINFO="$cpuinfo_dir/haswell" assert_hw "x86 with sse4_2 and popcnt is Bun linux-x64 compatible" yes +OMARCHY_CPUINFO="$cpuinfo_dir/aarch64" assert_hw "aarch64 cpuinfo is Bun linux-x64 compatible" yes +OMARCHY_ARCH=aarch64 OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" assert_hw "OMARCHY_ARCH=aarch64 still installs even with x86 cpuinfo" yes + +run_mise() { + : >"$mise_log" + OMARCHY_CPUINFO=$1 source "$ROOT/install/user/mise.sh" >"$skip_log" 2>&1 +} + +assert_skipped() { + if grep -qx 'claude' "$mise_log"; then + fail "$1 still installs claude" + fi + if grep -qx 'pi' "$mise_log"; then + fail "$1 still installs pi" + fi + grep -q 'Skipping claude:' "$skip_log" || fail "$1 does not explain skipping claude" + grep -q 'Skipping pi:' "$skip_log" || fail "$1 does not explain skipping pi" + grep -qx 'codex' "$mise_log" || fail "$1 still installs other mise tools" +} + +assert_installed() { + grep -qx 'claude' "$mise_log" || fail "$1 does not install claude" + grep -qx 'pi' "$mise_log" || fail "$1 does not install pi" + if grep -q 'Skipping' "$skip_log"; then + fail "$1 skips bun agents on a compatible CPU" + fi +} + +run_mise "$cpuinfo_dir/core2duo" +assert_skipped "missing sse4_2" +pass "user setup skips claude and pi when SSE4.2 is missing" + +run_mise "$cpuinfo_dir/haswell" +assert_installed "sse4_2+popcnt" +pass "user setup installs claude and pi when SSE4.2 and POPCNT are present" + +run_mise "$cpuinfo_dir/aarch64" +assert_installed "aarch64" +pass "user setup installs claude and pi on aarch64" + +cat >"$mock_bin/mise" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_MISE_LOG" +if [[ $1 == "where" ]]; then + [[ ${OMARCHY_TEST_AGENT_INSTALLED:-false} == "true" ]] + exit +fi +exit 0 +SH + +cat >"$mock_bin/omarchy-launch-floating-terminal-with-presentation" <<'SH' +#!/bin/bash +printf '%s\n' "$*" >>"$OMARCHY_TEST_TERMINAL_LOG" +SH + +cat >"$mock_bin/omarchy-agent" <<'SH' +#!/bin/bash +exit 0 +SH +chmod +x "$mock_bin"/* + +terminal_log="$test_tmp/terminal" +export OMARCHY_TEST_TERMINAL_LOG="$terminal_log" + +: >"$mise_log" +: >"$terminal_log" +mkdir -p "$test_home/.config/omarchy/defaults" +if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent claude >"$skip_log" 2>&1; then + fail "default agent installs claude on a CPU without SSE4.2" +fi +grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why claude cannot be installed" +[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible claude" +[[ ! -s $terminal_log ]] || fail "default agent does not open an install terminal for incompatible claude" +[[ ! -f $test_home/.config/omarchy/defaults/agent ]] || fail "default agent does not record an incompatible claude" +pass "default agent refuses claude on a CPU without SSE4.2" + +: >"$mise_log" +: >"$skip_log" +if OMARCHY_CPUINFO="$cpuinfo_dir/core2duo" omarchy-default-agent pi >"$skip_log" 2>&1; then + fail "default agent installs pi on a CPU without SSE4.2" +fi +grep -q 'SSE4.2' "$skip_log" || fail "default agent explains why pi cannot be installed" +[[ ! -s $mise_log ]] || fail "default agent does not invoke mise for an incompatible pi" +pass "default agent refuses pi on a CPU without SSE4.2" + +: >"$mise_log" +OMARCHY_CPUINFO="$cpuinfo_dir/haswell" OMARCHY_TEST_AGENT_INSTALLED=true omarchy-default-agent claude >/dev/null +grep -q 'use -g claude' "$mise_log" || fail "default agent still installs claude when the CPU can run Bun" +[[ $(<"$test_home/.config/omarchy/defaults/agent") == claude ]] || fail "default agent records claude on a compatible CPU" +pass "default agent still installs claude when SSE4.2 and POPCNT are present" diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index b3394678b331..f8bb95c6defe 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -215,13 +215,14 @@ assertEqual( 'setup.reset', 'menu lists Reset Computer last under Setup' ) +const bunX64When = 'omarchy-hw-cpu-sse4_2' const expectedAgents = { agy: { icon: '󰫢', label: 'Antigravity' }, - pi: { icon: '\ue901', iconFont: 'omarchy', label: 'Pi' }, + pi: { icon: '\ue901', iconFont: 'omarchy', label: 'Pi', when: bunX64When }, omp: { icon: '\ue903', iconFont: 'omarchy', label: 'omp' }, opencode: { icon: '\ue902', iconFont: 'omarchy', label: 'OpenCode' }, ori: { icon: '\ue909', iconFont: 'omarchy', label: 'Ori' }, - claude: { icon: '󰛄', label: 'Claude' }, + claude: { icon: '󰛄', label: 'Claude', when: bunX64When }, codex: { icon: '\ue905', iconFont: 'omarchy', label: 'Codex' }, grok: { icon: '\ue904', iconFont: 'omarchy', label: 'Grok' }, copilot: { icon: '', label: 'Copilot' }, @@ -235,7 +236,7 @@ assert( && entry.iconFont === (expected.iconFont || '') && entry.label === expected.label && entry.action === `omarchy-default-agent ${agent}` - && !entry.when + && entry.when === (expected.when || '') && entry.checked.includes(`== \"${agent}\"`) }), 'menu exposes every mise-installable coding agent with its own glyph under Defaults > Agent'