Skip to content

Commit

Permalink
[nix] set precise march for compiling cases
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL authored and sequencer committed May 21, 2024
1 parent 91e1ea6 commit 84c93bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
30 changes: 19 additions & 11 deletions tests/builder.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# args from scope `casesSelf`
{ stdenv
, lib
, jq
, elaborateConfig
, isFp
, vLen
}:

# args from makeBuilder
Expand All @@ -24,17 +27,22 @@ stdenv.mkDerivation (self: rec {

CC = "${stdenv.targetPlatform.config}-cc";

NIX_CFLAGS_COMPILE = [
"-mabi=ilp32f"
"-march=rv32gcv"
"-mno-relax"
"-static"
"-mcmodel=medany"
"-fvisibility=hidden"
"-fno-PIC"
"-g"
"-O3"
];
NIX_CFLAGS_COMPILE =
let
march = (if isFp then "rv32gc_zve32f" else "rv32gc_zve32x")
+ "_zvl${toString (lib.min 1024 vLen)}b";
in
[
"-mabi=ilp32f"
"-march=${march}"
"-mno-relax"
"-static"
"-mcmodel=medany"
"-fvisibility=hidden"
"-fno-PIC"
"-g"
"-O3"
];

installPhase = ''
runHook preInstall
Expand Down
5 changes: 4 additions & 1 deletion tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ let
extension = lib.head elaborateConfig.parameter.extensions;
xLen = if lib.hasInfix "ve32" extension then 32 else 64;
isFp = lib.hasInfix "f" extension;
vLen = elaborateConfig.parameter.vLen;
vLen = let vLen = elaborateConfig.parameter.vLen; in
assert builtins.bitAnd vLen (vLen - 1) == 0; # vLen should be power of 2
assert vLen >= 32;
vLen;

scope = lib.recurseIntoAttrs (lib.makeScope newScope (casesSelf: {
makeBuilder = casesSelf.callPackage ./builder.nix { };
Expand Down

0 comments on commit 84c93bc

Please sign in to comment.