Skip to content

Commit 6527820

Browse files
committed
Merge branch 'master' into go-to-instance
2 parents 9914b4c + 948eba4 commit 6527820

File tree

802 files changed

+438897
-439385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

802 files changed

+438897
-439385
lines changed

.github/workflows/ci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,17 @@ jobs:
157157
# open nix-shell once for initial setup
158158
true
159159
if: matrix.os == 'ubuntu-latest'
160+
- name: Set up core dumps
161+
run: |
162+
mkdir -p $PWD/coredumps
163+
# store in current directory, for easy uploading together with binary
164+
echo $PWD/coredumps/%e.%p.%t | sudo tee /proc/sys/kernel/core_pattern
165+
if: matrix.os == 'ubuntu-latest'
160166
- name: Build
161167
run: |
162168
mkdir build
163169
cd build
170+
ulimit -c unlimited # coredumps
164171
OPTIONS=()
165172
if [[ -n '${{ matrix.prepare-llvm }}' ]]; then
166173
wget -q ${{ matrix.llvm-url }}
@@ -203,6 +210,7 @@ jobs:
203210
- name: Test
204211
run: |
205212
cd build/stage1
213+
ulimit -c unlimited # coredumps
206214
# exclude nonreproducible test
207215
ctest -j4 --output-on-failure -E leanlaketest_git ${{ matrix.CTEST_OPTIONS }} < /dev/null
208216
if: ${{ !matrix.cross }}
@@ -212,11 +220,13 @@ jobs:
212220
- name: Build Stage 2
213221
run: |
214222
cd build
223+
ulimit -c unlimited # coredumps
215224
make -j4 stage2
216225
if: matrix.build-stage2 || matrix.check-stage3
217226
- name: Check Stage 3
218227
run: |
219228
cd build
229+
ulimit -c unlimited # coredumps
220230
make -j4 check-stage3
221231
if: matrix.check-stage3
222232
- name: Test Speedcenter Benchmarks
@@ -229,10 +239,31 @@ jobs:
229239
- name: Check rebootstrap
230240
run: |
231241
cd build
242+
ulimit -c unlimited # coredumps
232243
make update-stage0 && make -j4
233244
if: matrix.name == 'Linux'
234245
- name: CCache stats
235246
run: ccache -s
247+
- name: Show stacktrace for coredumps
248+
if: ${{ failure() }} && matrix.os == 'ubuntu-latest'
249+
run: |
250+
for c in coredumps/*; do
251+
progbin="$(file $c | sed "s/.*execfn: '\([^']*\)'.*/\1/")"
252+
echo bt | $GDB/bin/gdb -q $progbin $c || true
253+
done
254+
- name: Upload coredumps
255+
uses: actions/upload-artifact@v3
256+
if: ${{ failure() }} && matrix.os == 'ubuntu-latest'
257+
with:
258+
name: coredumps-${{ matrix.name }}
259+
path: |
260+
./coredumps
261+
./build/stage0/bin/lean
262+
./build/stage0/lib/lean/libleanshared.so
263+
./build/stage1/bin/lean
264+
./build/stage1/lib/lean/libleanshared.so
265+
./build/stage2/bin/lean
266+
./build/stage2/lib/lean/libleanshared.so
236267
237268
release:
238269
if: startsWith(github.ref, 'refs/tags/')

.github/workflows/nix-ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,13 @@ jobs:
8181
skipPush: true # we push specific outputs only
8282
- name: Build
8383
run: |
84-
# .o files are not a runtime dependency on macOS because of lack of thin archives
85-
nix build $NIX_BUILD_ARGS .#stage0 .#stage1.lean-all .#Lean.oTree .#iTree .#modDepsFiles -o push-build
84+
nix build $NIX_BUILD_ARGS .#cacheRoots -o push-build
8685
- name: Test
8786
run: |
8887
nix build $NIX_BUILD_ARGS .#test -o push-test
8988
- name: Build manual
9089
run: |
91-
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc#{lean-mdbook,leanInk,alectryon,test} -o push-doc
90+
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc#{lean-mdbook,leanInk,alectryon,test,inked} -o push-doc
9291
nix build $NIX_BUILD_ARGS --update-input lean --no-write-lock-file ./doc
9392
if: matrix.name == 'Nix Linux'
9493
- name: Push to Cachix

RELEASES.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased
22
---------
33

4+
* [Pretty-print signatures in hover and `#check <ident>`](https://github.com/leanprover/lean4/pull/1943).
5+
46
* [Update Lake to latest prerelease](https://github.com/leanprover/lean4/pull/1879).
57

68
* [Introduce parser memoization to avoid exponentional behavior](https://github.com/leanprover/lean4/pull/1799).

doc/examples/widgets.lean

+13-14
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ as seen in the goal view. We will use it to implement our custom `#check` displa
126126
⚠️ WARNING: Like the other widget APIs, the infoview JS API is **unstable** and subject to breaking changes.
127127
128128
The code below demonstrates useful parts of the API. To make RPC method calls, we use the `RpcContext`.
129-
The `useAsync` helper packs the results of a call into a `status` enum, the returned `val`ue in case
130-
the call was successful, and otherwise an `err`or. Based on the `status` we either display
131-
an `InteractiveCode`, or `mapRpcError` the error in order to turn it into a readable message.
129+
The `useAsync` helper packs the results of a call into an `AsyncState` structure which indicates
130+
whether the call has resolved successfully, has returned an error, or is still in-flight. Based
131+
on this we either display an `InteractiveCode` with the type, `mapRpcError` the error in order
132+
to turn it into a readable message, or show a `Loading..` message, respectively.
132133
-/
133134

134135
@[widget]
@@ -137,21 +138,21 @@ def checkWidget : UserWidgetDefinition where
137138
javascript := "
138139
import * as React from 'react';
139140
const e = React.createElement;
140-
import { RpcContext, InteractiveCode } from '@leanprover/infoview';
141+
import { RpcContext, InteractiveCode, useAsync, mapRpcError } from '@leanprover/infoview';
141142
142143
export default function(props) {
143144
const rs = React.useContext(RpcContext)
144145
const [name, setName] = React.useState('getType')
145-
const [value, setValue] = React.useState(undefined)
146146
147-
function run() {
148-
rs.call('getType', { name, pos: props.pos }).then(setValue)
149-
}
147+
const st = useAsync(() =>
148+
rs.call('getType', { name, pos: props.pos }), [name, rs, props.pos])
150149
151-
React.useEffect(() => run(), [name])
152-
const type = value && e(InteractiveCode, {fmt: value})
150+
const type = st.state === 'resolved' ? st.value && e(InteractiveCode, {fmt: st.value})
151+
: st.state === 'rejected' ? e('p', null, mapRpcError(st.error).message)
152+
: e('p', null, 'Loading..')
153153
const onChange = (event) => { setName(event.target.value) }
154-
return e('div', null, e('input', { value: name, onChange }), ' : ', type)
154+
return e('div', null,
155+
e('input', { value: name, onChange }), ' : ', type)
155156
}
156157
"
157158

@@ -189,11 +190,9 @@ To do this, use the `React.useContext(EditorContext)` React context.
189190
This will return an `EditorConnection` whose `api` field contains a number of methods to
190191
interact with the text editor.
191192
192-
You can see the full API for this [here](https://github.com/leanprover/vscode-lean4/blob/1edd92230c7630627f18dbe76cd139903a4cbcee/lean4-infoview-api/src/infoviewApi.ts#L52)
193-
193+
You can see the full API for this [here](https://github.com/leanprover/vscode-lean4/blob/master/lean4-infoview-api/src/infoviewApi.ts#L52)
194194
-/
195195

196-
197196
@[widget]
198197
def insertTextWidget : UserWidgetDefinition where
199198
name := "textInserter"

doc/flake.lock

+4-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/flake.nix

+24-16
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,30 @@
7878
(with python3Packages; [ pygments dominate beautifulsoup4 docutils ]);
7979
doCheck = false;
8080
};
81-
renderLean = name: file: runCommandNoCC "${name}.md" { buildInputs = [ alectryon ]; } ''
82-
mkdir -p $(basename $out/${name})
83-
alectryon --frontend lean4+markup ${file} --backend webpage -o $out/${name}.md
84-
'';
85-
listFilesRecursiveRel = root: dir: lib.flatten (lib.mapAttrsToList (name: type:
86-
if type == "directory" then
87-
listFilesRecursiveRel root ("${dir}/${name}")
88-
else
89-
dir + "/${name}"
90-
) (builtins.readDir "${root}/${dir}"));
91-
renderDir = dir: let
92-
inputs = builtins.filter (n: builtins.match ".*\.lean" n != null) (listFilesRecursiveRel dir ".");
93-
outputs = lib.genAttrs inputs (n: renderLean n "${dir}/${n}");
94-
in
95-
outputs // symlinkJoin { inherit name; paths = lib.attrValues outputs; };
96-
inked = renderDir ./.;
81+
renderLeanMod = mod: mod.overrideAttrs (final: prev: {
82+
name = "${prev.name}.md";
83+
buildInputs = prev.buildInputs ++ [ alectryon ];
84+
outputs = [ "out" ];
85+
buildCommand = ''
86+
dir=$(dirname $relpath)
87+
mkdir -p $dir out/$dir
88+
if [ -d $src ]; then cp -r $src/. $dir/; else cp $src $leanPath; fi
89+
alectryon --frontend lean4+markup $leanPath --backend webpage -o $out/$leanPath.md
90+
'';
91+
});
92+
renderPackage = pkg: symlinkJoin {
93+
name = "${pkg.name}-mds";
94+
paths = map renderLeanMod (lib.attrValues pkg.mods);
95+
};
96+
literate = buildLeanPackage {
97+
name = "literate";
98+
src = ./.;
99+
roots = [
100+
{ mod = "examples"; glob = "submodules"; }
101+
{ mod = "monads"; glob = "submodules"; }
102+
];
103+
};
104+
inked = renderPackage literate;
97105
doc = book;
98106
};
99107
defaultPackage = self.packages.${system}.doc;

doc/monads/intro.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Now that you have an intuition for how abstract structures work, you'll examine
3232
that functors and applicative functors don't help you solve. Then you'll learn the specifics of how
3333
to actually use monads with some examples using the `Option` monad and the all important `IO` monad.
3434

35-
## [Reader Monads](readers.lean.md)
35+
## [Reader Monad](readers.lean.md)
3636
Now that you understand the details of what makes a monadic structure work, in this section, you'll
3737
learn about one of the most useful built in monads `ReaderM`, which gives your programs a
3838
global read-only context.

nix/bootstrap.nix

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{ debug ? false, stage0debug ? false, extraCMakeFlags ? [],
2-
stdenv, lib, cmake, gmp, gnumake, bash, buildLeanPackage, writeShellScriptBin, runCommand, symlinkJoin, lndir, perl, gnused, darwin, llvmPackages,
2+
stdenv, lib, cmake, gmp, gnumake, bash, buildLeanPackage, writeShellScriptBin, runCommand, symlinkJoin, lndir, perl, gnused, darwin, llvmPackages, linkFarmFromDrvs,
33
... } @ args:
44
with builtins;
55
rec {
66
inherit stdenv;
7+
sourceByRegex = p: rs: lib.sourceByRegex p (map (r: "(/src/)?${r}") rs);
78
buildCMake = args: stdenv.mkDerivation ({
89
nativeBuildInputs = [ cmake ];
910
buildInputs = [ gmp llvmPackages.llvm ];
@@ -15,8 +16,8 @@ rec {
1516
patchShebangs .
1617
'';
1718
} // args // {
18-
src = args.realSrc or (lib.sourceByRegex args.src [ "[a-z].*" "CMakeLists\.txt" ]);
19-
cmakeFlags = (args.cmakeFlags or [ "-DSTAGE=1" "-DLLVM=ON" "-DPREV_STAGE=./faux-prev-stage" "-DUSE_GITHASH=OFF" ]) ++ (args.extraCMakeFlags or extraCMakeFlags) ++ lib.optional (args.debug or debug) [ "-DCMAKE_BUILD_TYPE=Debug" ];
19+
src = args.realSrc or (sourceByRegex args.src [ "[a-z].*" "CMakeLists\.txt" ]);
20+
cmakeFlags = (args.cmakeFlags or [ "-DSTAGE=1" "-DPREV_STAGE=./faux-prev-stage" "-DUSE_GITHASH=OFF" ]) ++ (args.extraCMakeFlags or extraCMakeFlags) ++ lib.optional (args.debug or debug) [ "-DCMAKE_BUILD_TYPE=Debug" ];
2021
preConfigure = args.preConfigure or "" + ''
2122
# ignore absence of submodule
2223
sed -i 's!lake/Lake.lean!!' CMakeLists.txt
@@ -25,7 +26,7 @@ rec {
2526
lean-bin-tools-unwrapped = buildCMake {
2627
name = "lean-bin-tools";
2728
outputs = [ "out" "leanc_src" ];
28-
realSrc = lib.sourceByRegex ../src [ "CMakeLists\.txt" "cmake.*" "bin.*" "include.*" ".*\.in" "Leanc\.lean" ];
29+
realSrc = sourceByRegex ../src [ "CMakeLists\.txt" "cmake.*" "bin.*" "include.*" ".*\.in" "Leanc\.lean" ];
2930
preConfigure = ''
3031
touch empty.cpp
3132
sed -i 's/add_subdirectory.*//;s/set(LEAN_OBJS.*/set(LEAN_OBJS empty.cpp)/' CMakeLists.txt
@@ -44,19 +45,15 @@ rec {
4445
leancpp = buildCMake {
4546
name = "leancpp";
4647
src = ../src;
47-
buildFlags = [ "leancpp" "leanrt" "leanrt_initial-exec" "shell" "runtime_bc" ];
48+
buildFlags = [ "leancpp" "leanrt" "leanrt_initial-exec" "shell" ];
4849
installPhase = ''
4950
mkdir -p $out
5051
mv lib/ $out/
5152
mv shell/CMakeFiles/shell.dir/lean.cpp.o $out/lib
52-
mv runtime/libleanrt_initial-exec.a runtime/lean.h.bc $out/lib
53+
mv runtime/libleanrt_initial-exec.a $out/lib
5354
'';
5455
};
55-
# rename derivation so `nix run` uses the right executable name but we still see the stage in the build log
56-
wrapStage = stage: runCommand "lean" {} ''
57-
ln -s ${stage} $out
58-
'';
59-
stage0 = wrapStage (args.stage0 or (buildCMake {
56+
stage0 = args.stage0 or (buildCMake {
6057
name = "lean-stage0";
6158
realSrc = ../stage0/src;
6259
debug = stage0debug;
@@ -75,7 +72,8 @@ rec {
7572
done
7673
otool -L $out/bin/lean
7774
'';
78-
}));
75+
meta.mainProgram = "lean";
76+
});
7977
stage = { stage, prevStage, self }:
8078
let
8179
desc = "stage${toString stage}";
@@ -105,6 +103,7 @@ rec {
105103
Lean = attachSharedLib leanshared Lean' // { allExternalDeps = [ Init ]; };
106104
stdlib = [ Init Lean ];
107105
modDepsFiles = symlinkJoin { name = "modDepsFiles"; paths = map (l: l.modDepsFile) (stdlib ++ [ Leanc ]); };
106+
depRoots = symlinkJoin { name = "depRoots"; paths = map (l: l.depRoots) stdlib; };
108107
iTree = symlinkJoin { name = "ileans"; paths = map (l: l.iTree) stdlib; };
109108
extlib = stdlib; # TODO: add Lake
110109
Leanc = build { name = "Leanc"; src = lean-bin-tools-unwrapped.leanc_src; deps = stdlib; roots = [ "Leanc" ]; };
@@ -119,14 +118,14 @@ rec {
119118
'';
120119
mods = Init.mods // Lean.mods;
121120
leanc = writeShellScriptBin "leanc" ''
122-
LEAN_CC=${stdenv.cc}/bin/cc ${Leanc.executable.override { withSharedStdlib = true; }}/bin/leanc -I${lean-bin-tools-unwrapped}/include ${stdlibLinkFlags} -L${leanshared} "$@"
121+
LEAN_CC=${stdenv.cc}/bin/cc ${Leanc.executable}/bin/leanc -I${lean-bin-tools-unwrapped}/include ${stdlibLinkFlags} -L${leanshared} "$@"
123122
'';
124123
lean = runCommand "lean" { buildInputs = lib.optional stdenv.isDarwin darwin.cctools; } ''
125124
mkdir -p $out/bin
126125
${leanc}/bin/leanc ${leancpp}/lib/lean.cpp.o ${leanshared}/* -o $out/bin/lean
127126
'';
128127
# derivation following the directory layout of the "basic" setup, mostly useful for running tests
129-
lean-all = wrapStage(stdenv.mkDerivation {
128+
lean-all = stdenv.mkDerivation {
130129
name = "lean-${desc}";
131130
buildCommand = ''
132131
mkdir -p $out/bin $out/lib/lean
@@ -136,7 +135,13 @@ rec {
136135
# NOTE: `lndir` will not override existing `bin/leanc`
137136
${lndir}/bin/lndir -silent ${lean-bin-tools-unwrapped} $out
138137
'';
139-
});
138+
meta.mainProgram = "lean";
139+
};
140+
cacheRoots = linkFarmFromDrvs "cacheRoots" [
141+
stage0 lean leanc lean-all iTree modDepsFiles depRoots Leanc.src
142+
# .o files are not a runtime dependency on macOS because of lack of thin archives
143+
Lean.oTree
144+
];
140145
test = buildCMake {
141146
name = "lean-test-${desc}";
142147
realSrc = lib.sourceByRegex ../. [ "src.*" "tests.*" ];

0 commit comments

Comments
 (0)