verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
2.0 KiB
The EmitC dialect allows to convert operations from other MLIR dialects to EmitC ops. Those can be translated to C/C++ via the Cpp emitter.
The following convention is followed:
- If template arguments are passed to an
emitc.call_opaqueoperation, C++ is generated. - If tensors are used, C++ is generated.
- If multiple return values are used within in a functions or an
emitc.call_opaqueoperation, C++11 is required. - If floating-point type template arguments are passed to an
emitc.call_opaqueoperation, C++20 is required. - If
ssize_tis used, then the code requires the POSIX headersys/types.hor any of the C++ headers in which the type is defined. - If
_Float16is used, the code requires the support of C additional floating types. - If
__bf16is used, the code requires a compiler that supports it, such as GCC or Clang. - If
emitc.arraywith a dimension of size zero is used, then the code requires a GCC extension. - Else the generated code is compatible with C99.
These restrictions are neither inherent to the EmitC dialect itself nor to the Cpp emitter and therefore need to be considered while implementing conversions.
Type conversions are provided for the MLIR type index into the unsigned size_t
type and its signed counterpart ptrdiff_t. Conversions between these two types
are only valid if the index-typed values are within
[PTRDIFF_MIN, PTRDIFF_MAX].
After the conversion, C/C++ code can be emitted with mlir-translate. The tool
supports translating MLIR to C/C++ by passing -mlir-to-cpp. Furthermore, code
with variables declared at top can be generated by passing the additional
argument -declare-variables-at-top.
Besides operations part of the EmitC dialect, the Cpp targets supports translating the following operations:
- 'cf' Dialect
cf.brcf.cond_br
- 'func' Dialect
func.callfunc.funcfunc.return