relinker, libkernel: let --to-avx output run on Linux and Windows by recording the CPU features it still needs #22530
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by SchmashinPrunes on 2026-11-17T19:10:33Z.
--to-avxlowers instructions that hosts with AVX but without AVX2 lack, such as Sandy and Ivy Bridge, but it is limited to--macos(CliArgs.cpp: "--to-avx requires --macos";Conversion.cppchecks the same). On Linux and Windows,CheckHostCpuinlibkernel/System/src/HostCpu.cppstops at start-up when the host lacks LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA or F16C. It does not know which of them the conversion lowered, so--to-avxoutput could not start there even if the CLI allowed it.The host side is not in the way. The project builds without
-marchor ISA flags, and the host code that uses AVX2 or FMA checks first with__builtin_cpu_supports(Bessel.cpp,GuestArena.cpp). The start-up check is what blocks these hosts.Proposal
Relinker: record what the output still needs. A classifier in codegen maps a decoded instruction to the checked extensions it requires: LZCNT, BMI1, BMI2, MOVBE, AVX2, FMA, F16C. After conversion, the relinker takes the union over the instructions that were not lowered in the executable and in the bundled modules it converts in the same run, and writes it into the main executable:
PT_NOTEin a loaded segment.procparThe runtime already reads the main image this way for process parameters (
ApplicationProcessParameters.cpp).libkernel: check only what is recorded. When the record is present,
CheckHostCpurequires the baseline (SSE through SSE4.2, POPCNT, CMPXCHG16B, LAHF/SAHF, AVX) plus the recorded extensions. Without a record it behaves as it does now, so existing conversions are unchanged. The error names the missing features and, when--to-avxwould remove them, says so.CLI: drop the
--macosrequirement of--to-avxonce both parts are in.A title whose code contains only instructions that
--to-avxlowers then starts on a Sandy or Ivy Bridge host. A title that still uses, for example, PDEP or a gather is still refused at start-up with a clear message, rather than raising an illegal instruction later.Questions
PT_NOTE(ownerAnyPS5) and a new 8-byte-named PE section the right place, or is another existing channel preferred?DynamicLoaderloads it?--to-avx? Writing it for every conversion makes the start-up check exact for all output, but a linear scan can decode data in a code segment as an instruction, so the record can only err toward requiring more.I'd like to implement this and wanted agreement on the design first. Related lowerings that make
--to-avxcover more titles, F16C and single-precision FMA, are prepared and will follow as separate pull requests.This issue was written and posted by Claude Code, an AI assistant, at my request.
🤖 Generated with Claude Code