mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 11:06:11 -10:00
Since #4160 (10-29) the game's allocator is mimalloc v3, from libmimalloc-sys 0.1.49. Built by MSVC, its mi_popcount is `__popcnt64`, which MSVC turns into the POPCNT instruction whatever the target. mimalloc runs before main, so on a Core 2 (no POPCNT) the Windows game died at once with 0xc000001d and no log (#7264). v0.2.97 had no POPCNT at all; nightlies 2026-10-31 and 11-01 have 9. third_party/libmimalloc-sys is the published crate with one change: on MSVC x86/x64, mi_popcount takes mimalloc's portable count, as the GCC builds without -mpopcnt already do. Only arena bitmaps count bits, never malloc's fast path. [patch.crates-io] points at it until a release carries microsoft/mimalloc#1291. tools/check_cpu_baseline.py disassembles the Windows and Linux programs in the game build and fails on any POPCNT or LZCNT: it flags 2026-11-01's horizon-client.exe and passes v0.2.97's and the Linux builds. Fixes #7264 Co-Authored-By: Claude Opus 5.5 <[email protected]>
34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
import unittest
|
|
|
|
from tools import check_cpu_baseline as baseline
|
|
|
|
# llvm-objdump -d --no-show-raw-insn output: a stripped Windows program (only section labels) and an ELF one.
|
|
DISASSEMBLY = """
|
|
/tmp/horizon-client.exe:\tfile format coff-x86-64
|
|
|
|
Disassembly of section .text:
|
|
|
|
0000000140001000 <.text>:
|
|
140001000: \tpopcntq\t%rdx, %rax
|
|
140001005: \ttzcntl\t%ecx, %eax
|
|
14000100a: \tvpaddd\t%ymm0, %ymm1, %ymm2
|
|
0000000140002000 <mi_bitmap_popcount>:
|
|
140002000: \tlzcntq\t%r8, %r9
|
|
140002005: \tmovq\t%rax, %rbx
|
|
140002008: \tpopcnt\trax, rcx
|
|
"""
|
|
|
|
|
|
class ForbiddenUsesTests(unittest.TestCase):
|
|
def test_reports_popcnt_and_lzcnt_with_their_symbol_and_nothing_else(self):
|
|
uses = list(baseline.forbidden_uses(DISASSEMBLY.splitlines(keepends=True)))
|
|
self.assertEqual(uses, [
|
|
("140001000", ".text", "popcnt"),
|
|
("140002000", "mi_bitmap_popcount", "lzcnt"),
|
|
("140002008", "mi_bitmap_popcount", "popcnt"),
|
|
])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|