Skip to content

Commit af4c6c2

Browse files
committed
Squashed 'ocaml/' changes from bcae5ff..ea89813
ea89813 Merge pull request #154 from ocaml-flambda/merge-flambda-backend 23cf5a5 Merge flambda-backend changes b3af0c4 Unboxed types version 3 tests (#82) 1282d16 Functions with no clauses aren't local-returning (#149) 15d38c0 `make install` puts ocamlc at workspace root (#152) b4928ee Remove -absname to improve build errors (#151) f5b5e49 Remove `type_unpacks` (#150) 50d54db Remove arity-interrupting elaboration of module patterns (#146) 4382869 Remove the need to manually update the `tools/debug_printers` file (#148) 06a1d91 Add `promote-failed` targets to the Makefiles (#144) d04eb58 Cleanup of comprehensions and immutable arrays (#127) a45df79 Add a Module_strengthening extension (#142) 163c4b9 Add support for extensions in module types (#141) 74aa974 Some small patch-ups around matching on extensions (#140) 07127fe Remove raw_body from modular extensions setup (#137) 3f9bd64 Don't copy when resolving aliases in try_modtypes (#143) aba6294 Immediacy rework (#122) cf4eeef Add no-stack-allocation variant of some tests that print lambda (#133) 8f22438 Fully switch over Jane Street Merlin support to `.local-*` (#136) 5482a8d Remove `Lev_module_definition` from lambda (#135) 261e016 Change modular extensions to produce `AST_desc` types (#132) 0760c82 Disable module patterns in comprehensions (#131) 6acac80 Add Ctype global state debug printers (#130) bc32037 Enable support for Jane Street's internal Merlin configuration (#64) d1a8d03 Split out `Clflags.Extension` into a new file, `Language_extension` (#125) 435de6d Fix bootstrap and add legacy CI (#126) 7e5a626 Improve the API of language extensions to better support upstream compatibility (and also tooling) (#13) c4e17b0 Replace var with local for faster mode checking (#53) 6d477d8 Merge pull request #124 from riaqn/merge-backend d737533 minor fixes after merge f1710d6 Merge flambda-backend changes cc18534 Just run make boostrap (#123) git-subtree-dir: ocaml git-subtree-split: ea89813
1 parent 2376a0b commit af4c6c2

File tree

156 files changed

+4606
-1837
lines changed

Some content is hidden

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

156 files changed

+4606
-1837
lines changed

.depend

Lines changed: 50 additions & 60 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
ocamlrunparam: "v=0,V=1"
2323

2424
- name: i386
25-
config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
25+
config: --enable-stack-allocation=no CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'
2626
os: ubuntu-20.04
2727
ocamlparam: ''
2828
boot_config: CC='cc32' AS='as --32' ASPP='gcc -m32 -c' -host i386-linux PARTIALLD='ld -r -melf_i386'

.github/workflows/legacy-build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: build-legacy
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
full-flambda:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Packages
12+
run: |
13+
sudo apt-get update -y && sudo apt-get install -y texlive-latex-extra texlive-fonts-recommended
14+
# Ensure that make distclean can be run from an empty tree
15+
- name: distclean
16+
run: |
17+
MAKE_ARG=-j make distclean
18+
- name: configure tree
19+
run: |
20+
MAKE_ARG=-j XARCH=x64 CONFIG_ARG='--enable-flambda --enable-dependency-generation' OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh configure
21+
- name: Build
22+
run: |
23+
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh build
24+
- name: Run the testsuite
25+
run: |
26+
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test
27+
full-flambda-local:
28+
runs-on: ubuntu-latest
29+
env:
30+
OCAMLPARAM: "_,extension=local"
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
- name: Packages
35+
run: |
36+
sudo apt-get update -y && sudo apt-get install -y texlive-latex-extra texlive-fonts-recommended
37+
# Ensure that make distclean can be run from an empty tree
38+
- name: distclean
39+
run: |
40+
MAKE_ARG=-j make distclean
41+
- name: configure tree
42+
run: |
43+
MAKE_ARG=-j XARCH=x64 CONFIG_ARG='--enable-flambda --enable-dependency-generation' OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh configure
44+
- name: Build
45+
run: |
46+
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh build
47+
- name: Run the testsuite
48+
run: |
49+
MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ _build
273273
/tools/make_opcodes.ml
274274
/tools/caml-tex
275275
/tools/eventlog_metadata
276+
/tools/debug_printers
276277

277278
/toplevel/byte/topeval.mli
278279
/toplevel/byte/trace.mli
@@ -291,3 +292,6 @@ _build
291292

292293
/otherlibs/dynlink/natdynlinkops
293294

295+
# Jane Street Merlin support
296+
/.local-merlin-binaries
297+
/.local-ocaml-lib

HACKING.jst.adoc

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,29 @@ where the test file or test dir are specified with respect to the
5656

5757
## Debugging
5858

59-
OCaml 4.14 makes `type_expr` abstract, and thus normal debug printing
60-
of types no longer works. However, there is now an installable printer
61-
for types, which we can use to see the types. Here are the instructions:
59+
We make several custom printers available so that we can print more values in
60+
`ocamldebug`. Notable examples:
61+
62+
* OCaml 4.14 makes `type_expr` abstract, and thus normal debug printing
63+
of types no longer works without a custom printer.
64+
* The debug printer for `Ctypes.global_state` lets you see the global mutable state maintained within the `Ctypes` module.
65+
66+
Here's how to install the custom printers for a run of `ocamldebug`:
6267

6368
1. Use the old `Makefile`, not the new `Makefile.jst`. This is an infelicity
6469
we hope to fix.
6570

66-
2. In the `tools` directory, run `make debug_printers.cmo`.
71+
2. In the `tools` directory, run `make debug_printers`.
6772

6873
3. In the debugger, execute some instructions, with e.g. `run` or `step`. This forces
6974
the debugger to load the compiler code, required for the next
7075
step.
7176

72-
4. Execute `source tools/debug_printers` to install the printers.
77+
4. From your debugging session, run `source tools/debug_printers` to install the printers.
78+
79+
To add a new printer, simply add a line of the form
80+
81+
let name = Some.Compiler.printer
82+
83+
to `tools/debug_printers.ml`, and then run `make debug_printers` in the `tools`
84+
directory to regenerate the printing script.

Makefile.common-jst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Build rules common to ocaml-jst and flambda-backend
33
#
44

5+
# Get Merlin along with any Dune command
6+
dune := '$(CURDIR)/jane-street-merlin-setup.sh' ; '$(dune)'
7+
58
ws_boot = --root=. --workspace=duneconf/boot.ws
69
ws_runstd = --root=. --workspace=duneconf/runtime_stdlib.ws
710
ws_main = --root=. --workspace=duneconf/main.ws
@@ -163,10 +166,16 @@ _install: compiler
163166
-or -name "flambda2*.cmti" -or -name "flambda2*.cmt" \) \
164167
-exec cp -f {} _install/lib/ocaml/compiler-libs \;
165168

166-
# Copy _install to the final install directory (no-op if they are the same)
169+
# Copy _install to the final install directory (no-op if they are the same).
170+
# Also generate ocamlc at the root of the repo, as this is convenient to use
171+
# with ocamldebug: ocamldebug inherits the pwd of the file passed as argument,
172+
# so breakpoints bring you to the less-convenient _build source file if you use
173+
# the ocamlc.byte in $prefix/bin.
167174
install: _install
168175
mkdir -p '$(prefix)'
169176
rsync --chmod=u+rw,go+r -rl _install/ '$(prefix)'
177+
rm -f ocamlc
178+
ln -s '$(prefix)'/bin/ocamlc.byte ocamlc
170179

171180
# Same as above, but relies on a successfull earlier _install
172181
install_for_opam:
@@ -292,6 +301,14 @@ test: install_for_test
292301
fi \
293302
fi)
294303

304+
promote-failed:
305+
(export OCAMLSRCDIR=$$(pwd)/_runtest; \
306+
export CAML_LD_LIBRARY_PATH=$$(pwd)/_runtest/lib/ocaml/stublibs; \
307+
if $$(which gfortran > /dev/null 2>&1); then \
308+
export LIBRARY_PATH=$$(dirname $$(gfortran -print-file-name=libgfortran.a)); \
309+
fi; \
310+
cd _runtest/testsuite && make promote-failed)
311+
295312
runtest-upstream: test
296313

297314
test-one: install_for_test

boot/menhir/parser.ml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,9 @@ module Generic_array = struct
556556
end
557557

558558
let ppat_iarray loc elts =
559-
(Extensions.Immutable_arrays.pat_of
560-
~loc:(make_loc loc)
561-
(Iapat_immutable_array elts)).ppat_desc
559+
Extensions.Immutable_arrays.pat_of
560+
~loc:(make_loc loc)
561+
(Iapat_immutable_array elts)
562562

563563
let expecting loc nonterm =
564564
raise Syntaxerr.(Error(Expecting(make_loc loc, nonterm)))
@@ -42309,9 +42309,9 @@ module Tables = struct
4230942309
( Generic_array.expression
4231042310
"[:" ":]"
4231142311
(fun elts ->
42312-
(Extensions.Immutable_arrays.expr_of
42312+
Extensions.Immutable_arrays.expr_of
4231342313
~loc:(make_loc _sloc)
42314-
(Iaexp_immutable_array elts)).pexp_desc)
42314+
(Iaexp_immutable_array elts))
4231542315
_1 )
4231642316
# 42317 "parsing/parser.ml"
4231742317

@@ -42397,9 +42397,9 @@ module Tables = struct
4239742397
( Generic_array.expression
4239842398
"[:" ":]"
4239942399
(fun elts ->
42400-
(Extensions.Immutable_arrays.expr_of
42400+
Extensions.Immutable_arrays.expr_of
4240142401
~loc:(make_loc _sloc)
42402-
(Iaexp_immutable_array elts)).pexp_desc)
42402+
(Iaexp_immutable_array elts))
4240342403
_1 )
4240442404
# 42405 "parsing/parser.ml"
4240542405

@@ -42469,9 +42469,9 @@ module Tables = struct
4246942469
( Generic_array.expression
4247042470
"[:" ":]"
4247142471
(fun elts ->
42472-
(Extensions.Immutable_arrays.expr_of
42472+
Extensions.Immutable_arrays.expr_of
4247342473
~loc:(make_loc _sloc)
42474-
(Iaexp_immutable_array elts)).pexp_desc)
42474+
(Iaexp_immutable_array elts))
4247542475
_1 )
4247642476
# 42477 "parsing/parser.ml"
4247742477

@@ -42583,9 +42583,9 @@ module Tables = struct
4258342583
( Generic_array.expression
4258442584
"[:" ":]"
4258542585
(fun elts ->
42586-
(Extensions.Immutable_arrays.expr_of
42586+
Extensions.Immutable_arrays.expr_of
4258742587
~loc:(make_loc _sloc)
42588-
(Iaexp_immutable_array elts)).pexp_desc)
42588+
(Iaexp_immutable_array elts))
4258942589
_1 )
4259042590
# 42591 "parsing/parser.ml"
4259142591

@@ -42686,9 +42686,9 @@ module Tables = struct
4268642686
( Generic_array.expression
4268742687
"[:" ":]"
4268842688
(fun elts ->
42689-
(Extensions.Immutable_arrays.expr_of
42689+
Extensions.Immutable_arrays.expr_of
4269042690
~loc:(make_loc _sloc)
42691-
(Iaexp_immutable_array elts)).pexp_desc)
42691+
(Iaexp_immutable_array elts))
4269242692
_1 )
4269342693
# 42694 "parsing/parser.ml"
4269442694

@@ -42781,9 +42781,9 @@ module Tables = struct
4278142781
( Generic_array.expression
4278242782
"[:" ":]"
4278342783
(fun elts ->
42784-
(Extensions.Immutable_arrays.expr_of
42784+
Extensions.Immutable_arrays.expr_of
4278542785
~loc:(make_loc _sloc)
42786-
(Iaexp_immutable_array elts)).pexp_desc)
42786+
(Iaexp_immutable_array elts))
4278742787
_1 )
4278842788
# 42789 "parsing/parser.ml"
4278942789

@@ -43006,7 +43006,7 @@ module Tables = struct
4300643006
let _sloc = (_symbolstartpos, _endpos) in
4300743007

4300843008
# 2603 "parsing/parser.mly"
43009-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43009+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4301043010
# 43011 "parsing/parser.ml"
4301143011

4301243012
in
@@ -43107,7 +43107,7 @@ module Tables = struct
4310743107
let _sloc = (_symbolstartpos, _endpos) in
4310843108

4310943109
# 2603 "parsing/parser.mly"
43110-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43110+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4311143111
# 43112 "parsing/parser.ml"
4311243112

4311343113
in
@@ -43208,7 +43208,7 @@ module Tables = struct
4320843208
let _sloc = (_symbolstartpos, _endpos) in
4320943209

4321043210
# 2603 "parsing/parser.mly"
43211-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43211+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4321243212
# 43213 "parsing/parser.ml"
4321343213

4321443214
in
@@ -43324,7 +43324,7 @@ module Tables = struct
4332443324
let _sloc = (_symbolstartpos, _endpos) in
4332543325

4332643326
# 2603 "parsing/parser.mly"
43327-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43327+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4332843328
# 43329 "parsing/parser.ml"
4332943329

4333043330
in
@@ -43462,7 +43462,7 @@ module Tables = struct
4346243462
let _sloc = (_symbolstartpos, _endpos) in
4346343463

4346443464
# 2603 "parsing/parser.mly"
43465-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43465+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4346643466
# 43467 "parsing/parser.ml"
4346743467

4346843468
in
@@ -43600,7 +43600,7 @@ module Tables = struct
4360043600
let _sloc = (_symbolstartpos, _endpos) in
4360143601

4360243602
# 2603 "parsing/parser.mly"
43603-
( (Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1).pexp_desc )
43603+
( Extensions.Comprehensions.expr_of ~loc:(make_loc _sloc) _1 )
4360443604
# 43605 "parsing/parser.ml"
4360543605

4360643606
in

boot/ocamlc

6.92 KB
Binary file not shown.

boot/ocamllex

10 Bytes
Binary file not shown.

bytecomp/bytegen.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ let preserve_tailcall_for_prim = function
112112
Popaque _ | Psequor | Psequand
113113
| Pobj_magic _ ->
114114
true
115-
| Pbytes_to_string | Pbytes_of_string | Pignore
115+
| Pbytes_to_string | Pbytes_of_string
116+
| Parray_to_iarray | Parray_of_iarray
117+
| Pignore
116118
| Pgetglobal _ | Psetglobal _ | Pgetpredef _
117119
| Pmakeblock _ | Pmakefloatblock _
118120
| Pfield _ | Pfield_computed _ | Psetfield _
@@ -519,6 +521,8 @@ let comp_primitive p args =
519521
| Pint_as_pointer -> Kccall("caml_int_as_pointer", 1)
520522
| Pbytes_to_string -> Kccall("caml_string_of_bytes", 1)
521523
| Pbytes_of_string -> Kccall("caml_bytes_of_string", 1)
524+
| Parray_to_iarray -> Kccall("caml_iarray_of_array", 1)
525+
| Parray_of_iarray -> Kccall("caml_array_of_iarray", 1)
522526
| Pobj_dup -> Kccall("caml_obj_dup", 1)
523527
(* The cases below are handled in [comp_expr] before the [comp_primitive] call
524528
(in the order in which they appear below),
@@ -1020,8 +1024,6 @@ let rec comp_expr env exp sz cont =
10201024
let cont1 = add_event ev cont in
10211025
comp_expr env lam sz cont1
10221026
end
1023-
| Lev_module_definition _ ->
1024-
comp_expr env lam sz cont
10251027
end
10261028
| Lifused (_, exp) ->
10271029
comp_expr env exp sz cont

compilerlibs/Makefile.compilerlibs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ UTILS = \
3434
utils/local_store.cmo \
3535
utils/load_path.cmo \
3636
utils/clflags.cmo \
37+
utils/language_extension.cmo \
3738
utils/profile.cmo \
3839
utils/terminfo.cmo \
3940
utils/ccomp.cmo \
@@ -114,8 +115,6 @@ TYPING = \
114115
typing/parmatch.cmo \
115116
typing/typedecl_properties.cmo \
116117
typing/typedecl_variance.cmo \
117-
typing/typedecl_unboxed.cmo \
118-
typing/typedecl_immediacy.cmo \
119118
typing/typedecl_separability.cmo \
120119
lambda/debuginfo.cmo lambda/lambda.cmo \
121120
typing/typedecl.cmo \

configure

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,8 +2037,11 @@ AS_IF([test x"$DEFAULT_STRING" = "xunsafe"],
20372037

20382038
AS_IF([test x"$enable_stack_allocation" = "xno"],
20392039
[stack_allocation=false],
2040-
[AC_DEFINE([STACK_ALLOCATION])
2041-
stack_allocation=true])
2040+
[AS_IF([$arch64],
2041+
[AC_DEFINE([STACK_ALLOCATION])
2042+
stack_allocation=true],
2043+
[AC_MSG_ERROR([Stack allocation is only supported on 64-bit platforms. \
2044+
Please pass '--enable-stack-allocation=no'.])])])
20422045

20432046
AS_IF([test x"$enable_poll_insertion" = "xyes"],
20442047
[AC_DEFINE([POLL_INSERTION])

driver/compenv.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,9 @@ let read_one_param ppf position name v =
489489
| "dump-into-file" -> Clflags.dump_into_file := true
490490
| "dump-dir" -> Clflags.dump_dir := Some v
491491

492-
| "extension" -> Clflags.Extension.enable v
492+
| "extension" -> Language_extension.(enable (of_string_exn v))
493493
| "disable-all-extensions" ->
494-
if check_bool ppf name v then Clflags.Extension.disable_all ()
494+
if check_bool ppf name v then Language_extension.disallow_extensions ()
495495

496496
| _ ->
497497
if !warnings_for_discarded_params &&

0 commit comments

Comments
 (0)