Skip to content

Commit 1fba8ef

Browse files
authored
Re-add -nostdlib option and make it actually do something (#6824)
1 parent fcdf7a9 commit 1fba8ef

File tree

9 files changed

+17
-8
lines changed

9 files changed

+17
-8
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- Convert OCaml codebase to snake case style. https://github.com/rescript-lang/rescript-compiler/pull/6702
4848
- Fix location of let bindings with attributes. https://github.com/rescript-lang/rescript-compiler/pull/6791
4949
- Refactor uppercase exotic ident handling. https://github.com/rescript-lang/rescript-compiler/pull/6779
50+
- Fix `-nostdlib` internal compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6824
5051

5152
#### :nail_care: Polish
5253

@@ -60,7 +61,7 @@
6061
- In generated code, use `let` instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6102
6162
- Turn off transformation for closures inside loops when capturing loop variables, now that `let` is emitted instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6480
6263
- Improve unused attribute warning message. https://github.com/rescript-lang/rescript-compiler/pull/6787
63-
- Remove unused -no-stdlib compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6778
64+
- Remove internal option `use-stdlib` from build schema. https://github.com/rescript-lang/rescript-compiler/pull/6778
6465

6566
# 11.1.1
6667

jscomp/bsc/rescript_compiler_main.ml

+3
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
352352
"-bs-unsafe-empty-array", set Config.unsafe_empty_array,
353353
"*internal* Allow [||] to be polymorphic";
354354

355+
"-nostdlib", set Js_config.no_stdlib,
356+
"*internal* Don't use stdlib";
357+
355358
"-color", string_call set_color_option,
356359
"*internal* Enable or disable colors in compiler messages\n\
357360
The following settings are supported:\n\

jscomp/common/js_config.ml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ let jsx_module = ref React
5454
let jsx_mode = ref Automatic
5555
let js_stdout = ref true
5656
let all_module_aliases = ref false
57+
let no_stdlib = ref false
5758
let no_export = ref false
5859
let as_ppx = ref false
5960

jscomp/common/js_config.mli

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ val js_stdout : bool ref
8787

8888
val all_module_aliases : bool ref
8989

90+
val no_stdlib : bool ref
91+
9092
val no_export : bool ref
9193

9294
val as_ppx : bool ref

jscomp/core/res_compmisc.ml

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ let init_path () =
2727
let exp_dirs =
2828
List.map (Misc.expand_directory Config.standard_library) dirs
2929
in
30-
Config.load_path := List.rev_append exp_dirs [Config.standard_library];
30+
Config.load_path :=
31+
if !Js_config.no_stdlib then exp_dirs
32+
else (List.rev_append exp_dirs [Config.standard_library]);
3133
Env.reset_cache ()
3234

3335
(* Return the initial environment in which compilation proceeds. *)

jscomp/others/release.ninja

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
2+
bsc_primitive_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
33
bsc_flags = $bsc_primitive_flags -open Belt_internals
44

55
rule cc

jscomp/runtime/release.ninja

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
2+
bsc_no_open_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -nopervasives -unsafe -w +50 -warn-error A
33
bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini
44

55
rule cc
@@ -10,7 +10,7 @@ rule cc_cmi
1010
description = $in -> $out
1111

1212
o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi
13-
bsc_flags = -nopervasives
13+
bsc_flags = -nostdlib -nopervasives
1414
o runtime/js.cmj runtime/js.cmi : cc runtime/js.ml
1515
bsc_flags = $bsc_no_open_flags
1616
o runtime/caml.cmj : cc_cmi runtime/caml.res | runtime/caml.cmi runtime/caml_int64_extern.cmj

jscomp/stdlib-406/release.ninja

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others
2+
bsc_flags = -no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib -bs-cross-module-opt -make-runtime -w -9-3-106 -warn-error A -I others
33

44
rule cc
55
command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in

scripts/ninja.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var runtimeMliFiles = runtimeFiles.filter(
3030
var runtimeSourceFiles = runtimeMlFiles.concat(runtimeMliFiles);
3131
var runtimeJsFiles = [...new Set(runtimeSourceFiles.map(baseName))];
3232

33-
var commonBsFlags = `-no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero `;
33+
var commonBsFlags = `-no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib `;
3434
var js_package = pseudoTarget("js_pkg");
3535
var runtimeTarget = pseudoTarget("runtime");
3636
var othersTarget = pseudoTarget("others");
@@ -843,7 +843,7 @@ ${ninjaQuickBuildList([
843843
"bs_stdlib_mini.resi",
844844
"cc",
845845
ninjaCwd,
846-
[["bsc_flags", "-nopervasives"]],
846+
[["bsc_flags", "-nostdlib -nopervasives"]],
847847
[],
848848
externalDeps,
849849
],

0 commit comments

Comments
 (0)