Skip to content

Commit d5c8cb1

Browse files
committed
checkpoint commit
Switched from overrideDerivation to overrideAttrs because overrideDerivation was not working on Russell's new PDF derivation -- see BlockstreamResearch/simplicity#145 Russell explained on Rocket that overrideDerivation is "old school" and soft-deprecated and that overrideAttrs is to be prefered. See https://nixos.org/manual/nixpkgs/stable/#sec-pkg-overrideDerivation (It references "the overrideAttrs documentation". To find this, scroll up.)
1 parent 3a6d011 commit d5c8cb1

16 files changed

+333
-119
lines changed

BlockstreamResearch.Simplicity.check-pr.nix

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
, stdenv ? pkgs.stdenv
88
, jsonConfigFile
99
, prNum
10+
# Only used by checkHEad, not checkPr
11+
, singleRev ? prNum
1012
}:
1113
let
1214
utils = import ./andrew-utils.nix { };
@@ -31,7 +33,7 @@ let
3133
srcName = self: self.src.commitId;
3234
mtxName = self: "${self.src.shortId}-${self.attr}";
3335

34-
attr = [ "coq" "haskell" "compcert" "vst" ];
36+
attr = [ "coq" "haskell" "compcert" "vst" "pdf" ];
3537
doCheck = null;
3638
wideMultiply = null;
3739
withCoverage = null;
@@ -105,7 +107,7 @@ let
105107
'';
106108
})
107109
else drv;
108-
taggedDrv = diffDrv.overrideDerivation (drv: {
110+
taggedDrv = diffDrv.overrideAttrs (drv: {
109111
# Add a bunch of stuff just to make the derivation easier to grok
110112
checkPrProjectName = "Simplicity";
111113
checkPrAttr = attr;
@@ -127,7 +129,7 @@ in
127129
src = builtins.fetchGit {
128130
allRefs = true;
129131
url = jsonConfig.gitDir;
130-
rev = prNum;
132+
rev = singleRev;
131133
};
132134
name = builtins.toString prNum;
133135
shortId = name;

BlockstreamResearch.rust-simplicity.check-pr.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
, stdenv ? pkgs.stdenv
88
, jsonConfigFile
99
, prNum
10+
# Only used by checkHEad, not checkPr
11+
, singleRev ? prNum
1012
}:
1113
let
1214
utils = import ./andrew-utils.nix { };
@@ -16,7 +18,7 @@ let
1618
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default))
1719
pkgs.rust-bin.stable.latest.default
1820
pkgs.rust-bin.beta.latest.default
19-
pkgs.rust-bin.stable."1.41.0".default
21+
pkgs.rust-bin.stable."1.48.0".default
2022
];
2123
isNightly = rustc: rustc == builtins.head allRustcs;
2224
gitCommits = utils.githubPrSrcs {
@@ -152,7 +154,7 @@ in
152154
gitSrc = builtins.fetchGit {
153155
allRefs = true;
154156
url = jsonConfig.gitDir;
155-
rev = prNum;
157+
rev = singleRev;
156158
};
157159
in rec {
158160
src = if isSys

BlockstreamResearch.secp256k1-zkp.check-pr.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
, stdenv ? pkgs.stdenv
55
, jsonConfigFile
66
, prNum
7+
# Only used by checkHEad, not checkPr
8+
, singleRev ? prNum
79
}:
810
let
911
utils = import ./andrew-utils.nix { };
@@ -137,7 +139,7 @@ in
137139
src = builtins.fetchGit {
138140
allRefs = true;
139141
url = jsonConfig.gitDir;
140-
rev = prNum;
142+
rev = singleRev;
141143
};
142144
name = builtins.toString prNum;
143145
shortId = name;

ElementsProject.elements-miniscript.check-pr.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
, stdenv ? pkgs.stdenv
88
, jsonConfigFile
99
, prNum
10+
# Only used by checkHEad, not checkPr
11+
, singleRev ? prNum
1012
}:
1113
let
1214
utils = import ./andrew-utils.nix { };
@@ -15,7 +17,7 @@ let
1517
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default))
1618
pkgs.rust-bin.stable.latest.default
1719
pkgs.rust-bin.beta.latest.default
18-
pkgs.rust-bin.stable."1.41.0".default
20+
pkgs.rust-bin.stable."1.48.0".default
1921
];
2022
isNightly = rustc: rustc == builtins.head allRustcs;
2123
gitCommits = utils.githubPrSrcs {
@@ -120,7 +122,7 @@ in
120122
src = builtins.fetchGit {
121123
allRefs = true;
122124
url = jsonConfig.gitDir;
123-
rev = prNum;
125+
rev = singleRev;
124126
};
125127
name = builtins.toString prNum;
126128
shortId = name;

ElementsProject.rust-elements.check-pr.nix

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
, stdenv ? pkgs.stdenv
88
, jsonConfigFile
99
, prNum
10+
# Only used by checkHEad, not checkPr
11+
, singleRev ? prNum
1012
}:
1113
let
1214
utils = import ./andrew-utils.nix { };
@@ -15,7 +17,7 @@ let
1517
(pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default))
1618
pkgs.rust-bin.stable.latest.default
1719
pkgs.rust-bin.beta.latest.default
18-
pkgs.rust-bin.stable."1.41.0".default
20+
pkgs.rust-bin.stable."1.48.0".default
1921
];
2022
isNightly = rustc: rustc == builtins.head allRustcs;
2123
gitCommits = utils.githubPrSrcs {
@@ -107,6 +109,7 @@ let
107109
pushd ${nixes.generated}/crate
108110
#cargo clippy --locked -- -D warnings
109111
#cargo fmt --all -- --check
112+
#RUSTDOCFLAGS="--cfg docsrs -D warnings -D rustdoc::broken-intra-doc-links" cargo doc --all-features
110113
popd
111114
''
112115
else "";
@@ -134,7 +137,7 @@ in
134137
src = builtins.fetchGit {
135138
allRefs = true;
136139
url = jsonConfig.gitDir;
137-
rev = prNum;
140+
rev = singleRev;
138141
};
139142
name = builtins.toString prNum;
140143
shortId = name;

andrew-utils.nix

+77-3
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,15 @@ rec {
195195
# Cargo.nix as the key, and the result of calling it as the value.
196196
#
197197
# Assumes that your matrix has entries projectName, prNum, rustc, lockFile, src.
198+
#
199+
# Note that EVERY INPUT TO THIS FUNCTION MUST BE ADDED TO generatedCargoNix. If it is
200+
# not, the memoization logic will collapse all the different values for that input
201+
# into one.
198202
crate2nixSingleCheckMemo =
199203
{ projectName
200204
, prNum
201205
, rustc
202206
, lockFile
203-
, features ? []
204207
, src
205208
, ...
206209
}:
@@ -211,7 +214,7 @@ rec {
211214
}) ];
212215
};
213216
generatedCargoNix = tools-nix.generatedCargoNix {
214-
name = "${projectName}-generated-cargo-nix-${builtins.toString prNum}-${src.shortId}";
217+
name = "${projectName}-generated-cargo-nix-${builtins.toString prNum}-${src.shortId}-${builtins.toString rustc}";
215218
src = src.src;
216219
overrideLockFile = lockFile;
217220
};
@@ -235,7 +238,6 @@ rec {
235238
echo "rustc: ${builtins.toString rustc}"
236239
echo "lockFile: ${lockFile}"
237240
echo "Source: ${builtins.toJSON src}"
238-
echo "Features: ${builtins.toJSON features}"
239241
'';
240242
}
241243
else pkgs.buildRustCrate crate;
@@ -258,6 +260,78 @@ rec {
258260
called = calledCargoNix;
259261
};
260262
};
263+
264+
cargoFuzzDrv = {
265+
normalDrv
266+
, projectName
267+
, src
268+
, nixes
269+
, fuzzTargets
270+
}: let
271+
overlaidPkgs = import <nixpkgs> {
272+
overlays = [
273+
(import (fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"))
274+
];
275+
};
276+
singleFuzzDrv = fuzzTarget: stdenv.mkDerivation {
277+
name = "fuzz-${fuzzTarget}";
278+
src = src.src;
279+
buildInputs = [
280+
overlaidPkgs.rust-bin.stable."1.58.0".default
281+
(import ./honggfuzz-rs.nix { })
282+
# Pinned version because of breaking change in args to init_disassemble_info
283+
nixpkgs.libopcodes_2_38 # for dis-asm.h and bfd.h
284+
nixpkgs.libunwind # for libunwind-ptrace.h
285+
];
286+
phases = [ "unpackPhase" "buildPhase" ];
287+
288+
buildPhase = ''
289+
set -x
290+
export CARGO_HOME=$PWD/cargo
291+
export HFUZZ_RUN_ARGS="--run_time 300 --exit_upon_crash"
292+
293+
cargo -V
294+
cargo hfuzz version
295+
echo "Source: ${builtins.toJSON src}"
296+
echo "Fuzz target: ${fuzzTarget}"
297+
298+
# honggfuzz rebuilds the world, including itself for some reason, and
299+
# it expects to be able to build itself in-place. So we need a read/write
300+
# copy.
301+
cp -r ${nixes.generated}/cargo .
302+
chmod -R +w cargo
303+
304+
DEP_DIR=$(grep 'directory =' $CARGO_HOME/config | sed 's/directory = "\(.*\)"/\1/')
305+
cp -r "$DEP_DIR" vendor-copy/
306+
chmod +w vendor-copy/
307+
rm vendor-copy/*honggfuzz*
308+
cp -rL "$DEP_DIR/"*honggfuzz* vendor-copy/ # -L means copy soft-links as real files
309+
chmod -R +w vendor-copy/
310+
# These two lines are just a search-and-replace ... but trying to get sed to replace
311+
# one string full of slashes with another is an unreadable mess, so easier to just
312+
# erase the line completely then recreate it with echo.
313+
sed -i "s/directory = \".*\"//" "$CARGO_HOME/config"
314+
echo "directory = \"$PWD/vendor-copy\"" >> "$CARGO_HOME/config"
315+
cat "$CARGO_HOME/config"
316+
# Done crazy honggfuzz shit
317+
318+
pushd fuzz/
319+
cargo hfuzz run "${fuzzTarget}"
320+
popd
321+
322+
touch $out
323+
'';
324+
};
325+
fuzzDrv = overlaidPkgs.linkFarm
326+
"${projectName}-${src.shortId}-fuzz"
327+
((map (x: rec {
328+
name = "fuzz-${path.name}";
329+
path = singleFuzzDrv x;
330+
}) fuzzTargets) ++ [{
331+
name = "fuzz-normal-tests";
332+
path = normalDrv;
333+
}]);
334+
in fuzzDrv;
261335
}
262336

263337

bitcoin.secp256k1.check-pr.nix

+14-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
, stdenv ? pkgs.stdenv
55
, jsonConfigFile
66
, prNum
7+
# Only used by checkHEad, not checkPr
8+
, singleRev ? prNum
79
}:
810
let
911
utils = import ./andrew-utils.nix { };
@@ -30,15 +32,16 @@ let
3032
["recovery"]
3133
];
3234
ecmultGenPrecision = [ 2 4 8 ];
33-
ecmultWindow = [
35+
# z-prefix this to try to spread out the 24-bit instances in the matrix
36+
zecmultWindow = [
3437
2 10 15
3538
# Frustratingly my system OOMs when dealing with more than one commit
3639
# at 24-bit ecmult windows. Even with 1TB of RAM. So throttle it in
3740
# the multi-commit case but leave it be for the "just testing HEAD"
3841
# case.
39-
if builtins.length gitCommits > 1
42+
(if builtins.length gitCommits > 1
4043
then 21
41-
else 24
44+
else 24)
4245
];
4346
withAsm = [ "no" "x86_64" ];
4447
withMsan = [ true false ];
@@ -53,7 +56,7 @@ let
5356
mtxName,
5457
extraModules,
5558
ecmultGenPrecision,
56-
ecmultWindow,
59+
zecmultWindow,
5760
withAsm,
5861
withMsan,
5962
widemul,
@@ -79,17 +82,17 @@ let
7982
fi
8083
'';
8184
# clang can't seem to handle ecmult windows > 20 :(
82-
adjEcmultWindow = if withMsan && ecmultWindow > 20
83-
then ecmultWindow - 4
84-
else ecmultWindow;
85+
adjEcmultWindow = if withMsan && zecmultWindow > 20
86+
then zecmultWindow - 4
87+
else zecmultWindow;
8588
drv = stdenv.mkDerivation {
8689
name = "${projectName}-${src.shortId}";
8790
src = src.src;
8891

8992
nativeBuildInputs = [ pkgs.pkgconfig pkgs.autoreconfHook pkgs.valgrind ]
9093
++ lib.optionals withMsan [
91-
pkgs.llvmPackages_15.llvm # to get llvm-symbolizer when clang blows up
92-
pkgs.clang_15
94+
pkgs.llvmPackages_16.llvm # to get llvm-symbolizer when clang blows up
95+
pkgs.clang_16
9396
];
9497
buildInputs = [];
9598

@@ -145,12 +148,13 @@ in
145148
src = builtins.fetchGit {
146149
allRefs = true;
147150
url = jsonConfig.gitDir;
148-
rev = prNum;
151+
rev = singleRev;
149152
};
150153
name = builtins.toString prNum;
151154
shortId = name;
152155
commitId = shortId;
153156
};
157+
zecmultWindow = [2 10 15 23]; # fixme drop this when we sort out OOM issues
154158
})
155159
checkData.argsMatrices;
156160
});

0 commit comments

Comments
 (0)