Skip to content

Commit 65b037b

Browse files
committed
Merge branch 'fstar1' of github.com:FStarLang/pulse into everparse-fstar1
2 parents 47722f8 + ac0a698 commit 65b037b

36 files changed

Lines changed: 384 additions & 82 deletions

.github/windows/cygwin-packages

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
git
2+
curl
3+
wget
4+
unzip
5+
zip
6+
time
7+
pkg-config
8+
mingw64-x86_64-gmp
9+
mingw64-x86_64-libffi
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# Install the Cygwin packages needed to build F*, karamel and Pulse into
4+
# the Cygwin root managed by opam (ocaml/setup-ocaml@v3). Adapted from
5+
# EverParse's src/package/windows/install-cygwin-packages.sh.
6+
#
7+
# The list of packages lives in the `cygwin-packages` file next to this
8+
# script. Set CYGWIN_ROOT to install into a specific root (e.g. opam's
9+
# internal Cygwin) and CYGWIN_MIRROR to pick a mirror.
10+
11+
set -e
12+
set -x
13+
14+
unset CDPATH
15+
cd "$( dirname "${BASH_SOURCE[0]}" )"
16+
17+
cygsetup="setup-x86_64.exe"
18+
cygsetup_args="--no-desktop --no-shortcuts --no-startmenu --wait --quiet-mode"
19+
20+
if [ -n "${CYGWIN_ROOT:-}" ]; then
21+
cygsetup_args="$cygsetup_args --root $CYGWIN_ROOT"
22+
fi
23+
24+
if [ -n "${CYGWIN_MIRROR:-}" ]; then
25+
cygsetup_args="$cygsetup_args --only-site --site $CYGWIN_MIRROR"
26+
fi
27+
28+
# Find Cygwin's setup utility, or download it from the internet.
29+
# Success: writes the path to Cygwin's setup in $cygsetup
30+
# Failure: aborts.
31+
found=false
32+
if cygsetup="$(which $cygsetup)" ; then
33+
found=true
34+
fi
35+
36+
if ! $found ; then
37+
for s in "$USERPROFILE/Desktop/setup-x86_64.exe" "$USERPROFILE/Downloads/setup-x86_64.exe" "./setup-x86_64.exe" "c:/cygwin64/setup-x86_64.exe" "c:/cygwin/setup-x86_64.exe"; do
38+
if [ -x "$s" ]; then
39+
echo "Found $s"
40+
found=true
41+
cygsetup="$s"
42+
fi
43+
done
44+
fi
45+
46+
if ! $found; then
47+
echo "Cygwin setup not found, downloading it"
48+
cygsetup=./setup-x86_64.exe
49+
curl --output $cygsetup "https://cygwin.com/setup-x86_64.exe"
50+
fi
51+
52+
chmod a+x "$cygsetup"
53+
exec "$cygsetup" $cygsetup_args --packages=$(cat cygwin-packages | tr '\n' ,)

.github/workflows/ci.yml

Lines changed: 165 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ defaults:
1212
shell: bash
1313

1414
jobs:
15-
ci:
15+
ci_ubuntu:
1616
runs-on: ubuntu-latest
1717
container: mtzguido/dev-base
1818
steps:
@@ -88,3 +88,167 @@ jobs:
8888
- name: Pulse CI
8989
id: cistep
9090
run: . $HOME/.cargo/env && make -C pulse ci -skj$(nproc)
91+
92+
# Build (and cache) an F* source package on Linux, to be consumed by the
93+
# Windows job below. F* cannot be built directly from a git checkout on
94+
# Windows, so we ship an OCaml source package instead, exactly as
95+
# EverParse's package-windows workflow does.
96+
fstar_src:
97+
runs-on: ubuntu-22.04
98+
# Slightly older Ubuntu, so the produced package works on more systems.
99+
steps:
100+
- uses: actions/checkout@master
101+
id: checkout-fstar
102+
with:
103+
repository: FStarLang/FStar
104+
ref: fstar1
105+
106+
- name: Try fetch built F* source package
107+
id: check-cache
108+
uses: actions/cache/restore@v4
109+
with:
110+
path: fstar-src.tar.gz
111+
key: FStar-src-${{ steps.checkout-fstar.outputs.commit }}
112+
113+
- uses: ocaml/setup-ocaml@v3
114+
if: steps.check-cache.outputs.cache-hit != 'true'
115+
with:
116+
ocaml-compiler: 4.14.2
117+
118+
- name: Prepare
119+
if: steps.check-cache.outputs.cache-hit != 'true'
120+
run: |
121+
./.scripts/get_fstar_z3.sh $HOME/bin
122+
echo "PATH=$HOME/bin:$PATH" >> $GITHUB_ENV
123+
opam install --deps-only ./fstar.opam
124+
125+
- name: Set F* version
126+
if: steps.check-cache.outputs.cache-hit != 'true'
127+
run: echo FSTAR_VERSION="$(git describe --tags --always --dirty 2>/dev/null || echo unknown)" >> $GITHUB_ENV
128+
129+
- name: Build the F* source package
130+
if: steps.check-cache.outputs.cache-hit != 'true'
131+
run: |
132+
eval $(opam env)
133+
export FSTAR_TAG=
134+
# ^ no tag in the source package: produces fstar-src.tar.gz
135+
make -skj$(nproc) package-src ADMIT=1
136+
137+
- name: Save built F* source package
138+
if: steps.check-cache.outputs.cache-hit != 'true'
139+
uses: actions/cache/save@v4
140+
with:
141+
path: fstar-src.tar.gz
142+
key: FStar-src-${{ steps.checkout-fstar.outputs.commit }}
143+
144+
- uses: actions/upload-artifact@v4
145+
with:
146+
path: fstar-src.tar.gz
147+
name: fstar-src
148+
149+
# Windows CI: build F* from the source package above, build karamel from
150+
# source, then run the full Pulse `ci` rule under Cygwin. This is what
151+
# exercises the symlink-free build on a platform without symlink support.
152+
ci_windows:
153+
needs: fstar_src
154+
runs-on: windows-2025
155+
steps:
156+
- name: Use LF checkouts
157+
run: git config --global core.autocrlf input
158+
159+
- uses: actions/checkout@v4
160+
with:
161+
path: pulse
162+
163+
- uses: actions/checkout@v4
164+
with:
165+
repository: FStarLang/karamel
166+
ref: d6607b99477640cb1e5d423d5cbe709d76da61f7
167+
path: karamel
168+
169+
- name: Set up OCaml (also installs Cygwin)
170+
uses: ocaml/setup-ocaml@v3
171+
with:
172+
ocaml-compiler: 5.3.0
173+
174+
- name: Install Cygwin packages
175+
shell: C:\.opam\.cygwin\root\bin\bash.exe --login '{0}'
176+
env:
177+
CYGWIN_ROOT: C:\.opam\.cygwin\root
178+
CYGWIN_MIRROR: https://mirrors.kernel.org/sourceware/cygwin/
179+
run: >-
180+
"$GITHUB_WORKSPACE"/pulse/.github/windows/install-cygwin-packages.sh
181+
182+
- name: Download F* source package
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: fstar-src
186+
187+
- name: Build F* from the source package
188+
shell: C:\.opam\.cygwin\root\bin\bash.exe --login '{0}'
189+
run: |
190+
cd "$GITHUB_WORKSPACE"
191+
tar xzf fstar-src.tar.gz
192+
cd fstar
193+
./get_fstar_z3.sh "$HOME/bin"
194+
export PATH="$HOME/bin:$PATH"
195+
eval $(opam env)
196+
opam install --deps-only --yes ./fstar.opam
197+
make -j$(nproc)
198+
199+
- name: Build karamel
200+
shell: C:\.opam\.cygwin\root\bin\bash.exe --login '{0}'
201+
run: |
202+
cd "$GITHUB_WORKSPACE"
203+
export FSTAR_EXE="$(pwd)/fstar/out/bin/fstar.exe"
204+
export PATH="$HOME/bin:$PATH"
205+
eval $(opam env)
206+
cd karamel
207+
# karamel.opam lists fstar as a dependency, but we build F*
208+
# ourselves above, so drop it before installing the rest.
209+
grep -v '"fstar"' karamel.opam > karamel-deps.opam
210+
opam install --deps-only --yes ./karamel-deps.opam
211+
make -j$(nproc)
212+
213+
- name: Install domainslib (for the task pool test)
214+
shell: C:\.opam\.cygwin\root\bin\bash.exe --login '{0}'
215+
run: |
216+
cd "$GITHUB_WORKSPACE"
217+
eval $(opam env)
218+
opam install --yes domainslib
219+
220+
- name: Pulse CI
221+
shell: C:\.opam\.cygwin\root\bin\bash.exe --login '{0}'
222+
run: |
223+
cd "$GITHUB_WORKSPACE"
224+
# Use Windows/mixed ("D:/...") paths for KRML_HOME (and FSTAR_EXE): the
225+
# C compiler KaRaMeL drives is native mingw gcc and `krml` is a native
226+
# Windows binary, neither of which understands Cygwin ("/cygdrive/...")
227+
# paths. Without this, krml passes "-I /cygdrive/.../karamel/include" to
228+
# mingw cc and krmllib.h is not found.
229+
workspace_w="$(cygpath -m "$(pwd)")"
230+
export FSTAR_EXE="$workspace_w/fstar/out/bin/fstar.exe"
231+
export KRML_HOME="$workspace_w/karamel"
232+
export PATH="$HOME/bin:$PATH"
233+
eval $(opam env)
234+
cd pulse
235+
# PULSE_NO_RUST=1: skip the pulse2rust tool and its tests, which are
236+
# the only parts of `ci` that need a Rust toolchain.
237+
make -j$(nproc) -k ci PULSE_NO_RUST=1
238+
239+
ci:
240+
name: CI success
241+
if: always()
242+
needs: [ci_ubuntu, ci_windows]
243+
runs-on: ubuntu-latest
244+
steps:
245+
- name: Verify all jobs succeeded
246+
run: |
247+
echo "Ubuntu: ${{ needs.ci_ubuntu.result }}"
248+
echo "Windows: ${{ needs.ci_windows.result }}"
249+
if [ "${{ needs.ci_ubuntu.result }}" != "success" ] || [ "${{ needs.ci_windows.result }}" != "success" ]
250+
then
251+
echo "One or more CI jobs failed."
252+
exit 1
253+
fi
254+
echo "All CI jobs passed."

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,30 @@ extraction.src: .force
3838
syntax_extension.src: .force
3939
$(MAKE) -f mk/syntax_extension.mk
4040

41-
plugin.src: checker.src extraction.src syntax_extension.src
41+
# Copy the hand-written OCaml sources for the plugin into the dune tree.
42+
# We do this instead of a symlink so the build works on platforms without
43+
# symlink support (e.g. Windows). The canonical sources live in src/ml.
44+
plugin.mlsrc: .force
45+
mkdir -p build/ocaml/plugin/ml
46+
cp -p -R src/ml/. build/ocaml/plugin/ml/
47+
48+
plugin.src: checker.src extraction.src syntax_extension.src plugin.mlsrc
4249

4350
## Building the plugin with dune
4451
plugin.build: plugin.src .force
4552
$(FSTAR_EXE) --ocamlenv \
4653
dune build --no-print-directory --root=build/ocaml
4754

4855
## Installing the plugin into out/
56+
ifeq ($(OS),Windows_NT)
57+
plugin: plugin.build .force
58+
$(FSTAR_EXE) --ocamlenv \
59+
dune install --root=build/ocaml --prefix=$(shell cygpath -m $(abspath build/ocaml/installed))
60+
else
4961
plugin: plugin.build .force
5062
$(FSTAR_EXE) --ocamlenv \
5163
dune install --root=build/ocaml --prefix=$(abspath build/ocaml/installed)
64+
endif
5265

5366
# Checking the library. Modules in common are shared between core and pulse, but core
5467
# and pulse are independent otherwise.
@@ -61,7 +74,11 @@ lib-core: lib-common .force
6174
lib-pulse: plugin lib-common .force
6275
$(MAKE) -f mk/lib-pulse.mk
6376

77+
ifeq ($(OS),Windows_NT)
78+
local-install: override PREFIX=$(shell cygpath -m $(CURDIR))/out
79+
else
6480
local-install: override PREFIX=$(CURDIR)/out
81+
endif
6582
local-install: do-install
6683

6784
.PHONY: do-install
@@ -72,8 +89,13 @@ do-install: plugin lib-pulse
7289
mkdir -p $(PREFIX)/lib/pulse/lib
7390
mkdir -p $(PREFIX)/share/pulse
7491
# Install plugin.
92+
ifeq ($(OS),Windows_NT)
93+
$(FSTAR_EXE) --ocamlenv \
94+
dune install --root=build/ocaml --prefix=$(shell cygpath -m $(abspath $(PREFIX)))
95+
else
7596
$(FSTAR_EXE) --ocamlenv \
7697
dune install --root=build/ocaml --prefix=$(abspath $(PREFIX))
98+
endif
7799
# Install library (cp -p: preserve time/perms)
78100
# We install it flat. Note that lib/core is not included, but still some PulseCore
79101
# checked files make it in. We could add:
@@ -101,6 +123,7 @@ clean:
101123
$(MAKE) -f mk/lib-pulse.mk clean
102124
$(MAKE) -f mk/lib-core.mk clean
103125
$(MAKE) -f mk/lib-common.mk clean
126+
rm -rf build/ocaml/plugin/ml
104127

105128
.PHONY: test-pulse
106129
test-pulse: local-install

build/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
checker.checked
2-
checker.ml
32
extraction.checked
4-
extraction.ml
53
syntax_extension.checked
6-
syntax_extension.ml

build/ocaml/plugin/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/checker
2+
/extraction
3+
/syntax_extension
4+
/ml

build/ocaml/plugin/checker

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/ocaml/plugin/extraction

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/ocaml/plugin/ml

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/ocaml/plugin/syntax_extension

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)