Skip to content

Re-add -nostdlib option and make it actually do something #6824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 3 additions & 0 deletions jscomp/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
1 change: 1 addition & 0 deletions jscomp/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions jscomp/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion jscomp/core/res_compmisc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)
Expand Down
2 changes: 1 addition & 1 deletion jscomp/others/release.ninja
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions jscomp/runtime/release.ninja
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jscomp/stdlib-406/release.ninja
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions scripts/ninja.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -842,7 +842,7 @@ ${ninjaQuickBuildList([
"bs_stdlib_mini.resi",
"cc",
ninjaCwd,
[["bsc_flags", "-nopervasives"]],
[["bsc_flags", "-nostdlib -nopervasives"]],
[],
externalDeps,
],
Expand Down