Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d5400eb
Prepare compiler requests for parallel in-process execution
cknitt Sep 24, 2026
a14ea0b
Compile OCaml rewatch jobs on parallel domains
cknitt Sep 24, 2026
07959d8
Format in-process and drop bsc subprocess plumbing in OCaml rewatch
cknitt Oct 10, 2026
1543e36
Remove the unused sequential in-process task kind from OCaml rewatch
cknitt Oct 10, 2026
4b19b4f
Keep Parmatch's fresh pattern names per compiler request
cknitt Oct 10, 2026
99aaae1
Reset leftover compiler state between in-process requests
cknitt Oct 10, 2026
120aec1
Capture in-process compiler output in text mode
cknitt Oct 11, 2026
ba629d0
Write bsc's captured output without a second CRLF translation
cknitt Oct 11, 2026
ed4154d
Expect native line endings from captured compiler output in tests
cknitt Oct 11, 2026
f0be2df
Don't share Js_analyzer's free-variable accumulator between domains
cknitt Oct 11, 2026
2bbdd16
Avoid shared printer state and formatters in compiler helpers
cknitt Oct 11, 2026
5be5f85
Give each in-process compiler request a single fresh state store
cknitt Oct 11, 2026
46ab8c1
Adapt the .cmt accumulator test to master's .cmt cleanup
cknitt Oct 12, 2026
91c637f
Add a changelog fragment for in-process compilation
cknitt Oct 12, 2026
110539d
Stream standalone bsc output and keep captured output on failure
cknitt Oct 12, 2026
c4d8e86
Exit at once on a second termination signal in OCaml rewatch
cknitt Oct 12, 2026
c9f6868
Define bsc's Clflags defaults in Clflags.reset only
cknitt Oct 12, 2026
3eb35f1
Find genType sources relative to the compiler request's directory
cknitt Oct 12, 2026
21636b7
Accept either signal's status in the second-signal test
cknitt Oct 12, 2026
51b34d6
Remove temporary PPX files when a PPX fails
cknitt Oct 12, 2026
8a513a6
Test that an exception escaping the compiler fails only its module
cknitt Oct 12, 2026
5c7c670
Test that a second build waits for an in-process build's lock
cknitt Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ npm link rescript

#### Use Local BSC with Existing ReScript Installation

Alternatively, you can set the `RESCRIPT_BSC_EXE` environment variable to point to your locally compiled `bsc.exe`.
The `rescript` build system has the compiler built in, so to test a local compiler change, link the local package as shown above.

The Rust build system, `rescript-rust`, still runs `bsc.exe` and accepts the `RESCRIPT_BSC_EXE` environment variable pointing to your locally compiled `bsc.exe`:

```sh
RESCRIPT_BSC_EXE=your-rescript-repo/packages/@rescript/darwin-arm64/bin/bsc.exe npx rescript
RESCRIPT_BSC_EXE=your-rescript-repo/packages/@rescript/darwin-arm64/bin/bsc.exe npx rescript-rust
```

This will test the local compiler while still using the build system from the installed Node module.

### Running Automatic Tests

We provide different test suites for different levels of the compiler and build system infrastructure. Always make sure to locally build your compiler before running any tests.
Expand Down
24 changes: 19 additions & 5 deletions analysis/src/completion_back_end.ml
Original file line number Diff line number Diff line change
Expand Up @@ -967,16 +967,28 @@ and get_completions_for_context_path ~state ~debug ~full ~opens ~raw_opens ~pos
match context_path with
| CPString ->
if Debug.verbose () then print_endline "[ctx_path]--> CPString";
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_string)]
[
Completion.create "dummy" ~env
~kind:(Completion.Value (Predef.type_string ()));
]
| CPBool ->
if Debug.verbose () then print_endline "[ctx_path]--> CPBool";
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_bool)]
[
Completion.create "dummy" ~env
~kind:(Completion.Value (Predef.type_bool ()));
]
| CPInt ->
if Debug.verbose () then print_endline "[ctx_path]--> CPInt";
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_int)]
[
Completion.create "dummy" ~env
~kind:(Completion.Value (Predef.type_int ()));
]
| CPFloat ->
if Debug.verbose () then print_endline "[ctx_path]--> CPFloat";
[Completion.create "dummy" ~env ~kind:(Completion.Value Predef.type_float)]
[
Completion.create "dummy" ~env
~kind:(Completion.Value (Predef.type_float ()));
]
| CPArray None ->
if Debug.verbose () then print_endline "[ctx_path]--> CPArray (no payload)";
[
Expand Down Expand Up @@ -1984,7 +1996,9 @@ let rec complete_typed_value ?(type_arg_context : type_arg_context option)
if prefix = "" then
[
create "\"\"" ~includes_snippets:true ~insert_text:"\"$0\""
~sort_text:"A" ~kind:(Value Predef.type_string) ~env;
~sort_text:"A"
~kind:(Value (Predef.type_string ()))
~env;
]
else []
| Tfunction {env; typ; args; return_type}
Expand Down
2 changes: 1 addition & 1 deletion analysis/src/module_resolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let ( /+ ) = Filename.concat
let rec resolve_node_module_path ~start_path name =
if name = "@rescript/runtime" then
(* Hack: we need a reliable way to resolve modules in monorepos. *)
Some !Runtime_package.path
Some (Runtime_package.get_path ())
else
let scope = Filename.dirname name in
let name = Filename.basename name in
Expand Down
1 change: 1 addition & 0 deletions changes/in-process-compilation.polish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Speed up `rescript` builds by compiling modules inside the build system on several CPU cores, instead of starting `bsc` for every file. https://github.com/rescript-lang/rescript/pull/8781
1 change: 1 addition & 0 deletions changes/ppx-temp-file-cleanup.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove the temporary PPX files when a PPX fails or a build is interrupted. https://github.com/rescript-lang/rescript/pull/8781
38 changes: 38 additions & 0 deletions compiler/bsc/build_identity_gen.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
let () =
let relevant file =
Filename.basename file = "dune"
|| List.exists (Filename.check_suffix file) [".ml"; ".mli"; ".c"; ".h"]
in
let files =
Array.to_list Sys.argv |> List.tl |> List.filter relevant
|> List.sort String.compare
in
let normalize path =
String.map
(function
| '\\' -> '/'
| character -> character)
path
in
let has_suffix suffix =
List.exists
(fun file -> Filename.check_suffix (normalize file) suffix)
files
in
[
"/flow_parser/parser/expression_parser.ml";
"/ext/ext_platform_primitives_stubs.c";
"/ext/platform/native/ext_platform_primitives.ml";
"/core/platform/native/js_name_of_module_id.ml";
"/syntax/src/res_driver.ml";
"/syntax/src/dune";
]
|> List.iter (fun suffix ->
if not (has_suffix suffix) then
failwith ("compiler identity is missing required input " ^ suffix));
let digest =
files
|> List.map (fun file -> file ^ "\000" ^ Digest.file file)
|> String.concat "\000" |> Digest.string
in
Printf.printf "let value = %S\n" (Digest.to_hex digest)
38 changes: 37 additions & 1 deletion compiler/bsc/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,46 @@
(flags
(:standard -ccopt -static))))

(executable
(name build_identity_gen)
(modules build_identity_gen))

(rule
(target rescript_compiler_build_identity.ml)
(deps
build_identity_gen.ml
dune
rescript_compiler_driver.ml
rescript_compiler_driver.mli
rescript_compiler_main.ml
rescript_compiler_main.mli
(source_tree ../common)
(source_tree ../core)
(source_tree ../depends)
(source_tree ../ext)
(source_tree ../flow_parser)
(source_tree ../frontend)
(source_tree ../gentype)
(source_tree ../ml)
(source_tree ../syntax))
(action
(with-stdout-to
%{target}
(run ./build_identity_gen.exe %{deps}))))

(library
(name rescript_compiler_driver)
(wrapped false)
(modules rescript_compiler_driver rescript_compiler_build_identity)
(instrumentation
(backend bisect_ppx))
(libraries common core depends flow_parser gentype syntax unix))

(executable
(name rescript_compiler_main)
(modules rescript_compiler_main)
(public_name bsc)
(package rescript)
(instrumentation
(backend bisect_ppx))
(libraries common core depends flow_parser gentype syntax))
(libraries rescript_compiler_driver))
Loading
Loading