Softfloat on riscv64 - #38
Draft
maximmenshikov wants to merge 9 commits into
Draft
Conversation
Seed the rv64gc baseline (base, d, c, a) for riscv64 in ConfigureInstructionSetSupport - previously no baseline was declared, so with a runtime that models F/D/C/A as instruction sets every riscv64 build would look like a no-F target and silently flip to the soft-float ABI. For the zisk/zisk_sim flavors append -c,-a,-f,-d to --targetisa: dropping C/A stops compressed/atomic emission through the same instruction-set mechanism as the EnableRiscV64* knobs, and dropping F/D switches ilc and the JIT into the lp64 soft-float ABI and soft-float lowering (dotnet-riscv fixup patches 26-28). Explicit --targetisa values keep working - the reduction is appended on top. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
The nofp module models the FP-free contract: every soft-float builtin traps and the whole libm surface is wrapped to traps. With the JIT now lowering FP into soft-float calls (dotnet-riscv fixups 26-28) a no-F build needs those symbols to work instead: - modules/softfloat: vendored compiler-rt builtins (llvmorg-18.1.8, Apache-2.0 WITH LLVM-exception) compiled strictly for rv64im via the new multi-file module mechanism (module_srcs.lst + module_cflags in build.sh: plain ELF objects merged with ld -r, no LTO so the builtins are never re-codegenned with the common rv64imad flags), plus soft replacements for the hard-float runtime conversion helpers (RhpDbl2Lng family, .NET saturating semantics) and vendored musl fmod/fmodf (MIT, pure bit manipulation), all diverted with --wrap. - BuildCommand: a riscv64 target without the F instruction set links softfloat.o instead of nofp.o and drops the nofp libm wraps. The libm surface itself still resolves to hard-float musl members and remains guarded by --error-on-float-binary until a soft-float libm ships. - bflat.variant.props: pin the .NET 11 min variant to the v11.0.0.x11-sf runtime release, which carries the soft-float runtime patches and the RiscV64_F instruction set in the compiler package. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
…shutdown Two fixes found while bringing up soft-float execution on ziskemu: 1. patch_elf writes its output to Path.ChangeExtension(output, .patched) and bflat never moved it back, nor checked the exit code. Guest recipes historically passed -o <name>.patched, which made ChangeExtension a no-op and the script overwrite its input in place - with any other output name the user received the RAW linker output, which does not boot on the zkVM (unfixed .tdata flags/init_array type/bss layout make the loader jump through a zero slot at __libc_start_init). Move the result over the requested output and fail the build on postprocess errors. 2. The zkVM decodes only base rv64im: extend the zisk instruction-set reduction with -zba,-zbb,-zbs,-zicond and force the corresponding EnableRiscV64* JIT knobs (plus F/D for hygiene) off. The cross-JIT resolves ISAs through the altjit path where every knob defaults to on, independent of ilc instruction-set support - Zicond notably turned GT_SELECT into czero.* encodings. Also: BFLAT_NO_ZK_ISA_REDUCTION / BFLAT_NO_RISCV_BASELINE env escape hatches used for bisection, kept for diagnostics. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
… pin x13-sf The libziskos nupkg places its manifest under contentFiles/any/any/ while runtimes/<rid>/native/ sits at the package root, so the manifest-relative static-library path missed it. Walk up towards the extraction root and take the first match. Pin the .NET 11 min variant to v11.0.0.x13-sf (soft-float runtime with the ReturnTypeDesc FP-struct-return gate). Keep the bisection env hatches (BFLAT_NO_ZK_ISA_REDUCTION / BFLAT_NO_RISCV_BASELINE) documented in-line. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
The compiler package for the .NET 10 variants has no RiscV64_F enum member and its instruction-set tables know nothing of f/d/c/a, so the zisk ISA reduction and the soft-float switch must not assume them. Probe a throwaway InstructionSetSupportBuilder for "f" support and resolve the enum member reflectively; on older packages the reduction is skipped and the classic nofp path is linked, exactly as before the soft-float work. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Review feedback: module_cflags was a second ad-hoc side file next to module_params.yml. Fold it into the existing declarative params as an options.cc section (same '- value:' entry style as options.ld) and read it in build.sh with yq like the other module options. The softfloat module is the only consumer; behavior is unchanged. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
…ms.yml Review feedback: module_cflags and module_srcs.lst were ad-hoc side files next to the module's declarative params. Fold both into module_params.yml as options.sources / options.cc sections (same '- value:' entry style as options.ld) and read them in build.sh with yq like the other module options. The softfloat module is the only consumer; behavior is unchanged. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
The ACSL gate requires every defined function in a C module to carry a contract. Annotate the .NET conversion semantics (NaN -> 0, saturation bounds) on the Rhp wrappers and put declaration specs on the renamed musl fmod/fmodf definitions; Frama-C attaches a declaration contract to the definition the include pulls in. Locally: check_acsl.py reports softfloat 8/8 ok. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
The compiler package now models the lp64 (soft-float) calling convention as TargetAbi.NativeAotRiscV64SoftFloat (dotnet-riscv fixup 27): the JIT flag and the ELF float-ABI marker follow the ABI rather than the F instruction set. Select it whenever the target lacks F or D, resolving the member reflectively so that older packages keep building. Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.