diff --git a/CHANGELOG.md b/CHANGELOG.md index f5fbc7d096..ffaa65be62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ - Convert OCaml codebase to snake case style. https://github.com/rescript-lang/rescript-compiler/pull/6702 - Fix location of let bindings with attributes. https://github.com/rescript-lang/rescript-compiler/pull/6791 - Refactor uppercase exotic ident handling. https://github.com/rescript-lang/rescript-compiler/pull/6779 +- Fix `-nostdlib` internal compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6824 #### :nail_care: Polish @@ -60,7 +61,7 @@ - In generated code, use `let` instead of `var`. https://github.com/rescript-lang/rescript-compiler/pull/6102 - 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 - Improve unused attribute warning message. https://github.com/rescript-lang/rescript-compiler/pull/6787 -- Remove unused -no-stdlib compiler option. https://github.com/rescript-lang/rescript-compiler/pull/6778 +- Remove internal option `use-stdlib` from build schema. https://github.com/rescript-lang/rescript-compiler/pull/6778 # 11.1.1 diff --git a/jscomp/bsc/rescript_compiler_main.ml b/jscomp/bsc/rescript_compiler_main.ml index b41f1c7509..bbc97c1452 100644 --- a/jscomp/bsc/rescript_compiler_main.ml +++ b/jscomp/bsc/rescript_compiler_main.ml @@ -352,6 +352,9 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array = "-bs-unsafe-empty-array", set Config.unsafe_empty_array, "*internal* Allow [||] to be polymorphic"; + "-nostdlib", set Js_config.no_stdlib, + "*internal* Don't use stdlib"; + "-color", string_call set_color_option, "*internal* Enable or disable colors in compiler messages\n\ The following settings are supported:\n\ diff --git a/jscomp/common/js_config.ml b/jscomp/common/js_config.ml index 358f0370d5..84f4e22f68 100644 --- a/jscomp/common/js_config.ml +++ b/jscomp/common/js_config.ml @@ -54,6 +54,7 @@ let jsx_module = ref React let jsx_mode = ref Automatic let js_stdout = ref true let all_module_aliases = ref false +let no_stdlib = ref false let no_export = ref false let as_ppx = ref false diff --git a/jscomp/common/js_config.mli b/jscomp/common/js_config.mli index 13048084b2..31855eaca7 100644 --- a/jscomp/common/js_config.mli +++ b/jscomp/common/js_config.mli @@ -87,6 +87,8 @@ val js_stdout : bool ref val all_module_aliases : bool ref +val no_stdlib : bool ref + val no_export : bool ref val as_ppx : bool ref diff --git a/jscomp/core/res_compmisc.ml b/jscomp/core/res_compmisc.ml index 1c7f3974e3..6213e2e022 100644 --- a/jscomp/core/res_compmisc.ml +++ b/jscomp/core/res_compmisc.ml @@ -27,7 +27,9 @@ let init_path () = let exp_dirs = List.map (Misc.expand_directory Config.standard_library) dirs in - Config.load_path := List.rev_append exp_dirs [Config.standard_library]; + Config.load_path := + if !Js_config.no_stdlib then exp_dirs + else (List.rev_append exp_dirs [Config.standard_library]); Env.reset_cache () (* Return the initial environment in which compilation proceeds. *) diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja index 462cfaaeee..21b03b82eb 100644 --- a/jscomp/others/release.ninja +++ b/jscomp/others/release.ninja @@ -1,5 +1,5 @@ -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 +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 bsc_flags = $bsc_primitive_flags -open Belt_internals rule cc diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index d9214de2c3..d21ca55b4d 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -1,5 +1,5 @@ -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 +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 bsc_flags = $bsc_no_open_flags -open Bs_stdlib_mini rule cc @@ -10,7 +10,7 @@ rule cc_cmi description = $in -> $out o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi - bsc_flags = -nopervasives + bsc_flags = -nostdlib -nopervasives o runtime/js.cmj runtime/js.cmi : cc runtime/js.ml bsc_flags = $bsc_no_open_flags o runtime/caml.cmj : cc_cmi runtime/caml.res | runtime/caml.cmi runtime/caml_int64_extern.cmj diff --git a/jscomp/stdlib-406/release.ninja b/jscomp/stdlib-406/release.ninja index ccd377821a..992f90f652 100644 --- a/jscomp/stdlib-406/release.ninja +++ b/jscomp/stdlib-406/release.ninja @@ -1,5 +1,5 @@ -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 +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 rule cc command = $bsc -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in diff --git a/scripts/ninja.js b/scripts/ninja.js index 1dda2c3a17..bce31a4465 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -30,7 +30,7 @@ var runtimeMliFiles = runtimeFiles.filter( var runtimeSourceFiles = runtimeMlFiles.concat(runtimeMliFiles); var runtimeJsFiles = [...new Set(runtimeSourceFiles.map(baseName))]; -var commonBsFlags = `-no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero `; +var commonBsFlags = `-no-keep-locs -no-alias-deps -bs-no-version-header -bs-no-check-div-by-zero -nostdlib `; var js_package = pseudoTarget("js_pkg"); var runtimeTarget = pseudoTarget("runtime"); var othersTarget = pseudoTarget("others"); @@ -842,7 +842,7 @@ ${ninjaQuickBuildList([ "bs_stdlib_mini.resi", "cc", ninjaCwd, - [["bsc_flags", "-nopervasives"]], + [["bsc_flags", "-nostdlib -nopervasives"]], [], externalDeps, ],