Skip to content
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

fix(stdlib): pass flags when building stdlib.ml #7241

Merged
merged 1 commit into from
Mar 14, 2023
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Unreleased
- Bootstrap: correctly detect the number of processors by allowing `nproc` to be
looked up in `$PATH` (#7272, @Alizter)

- Pass correct flags when compiling `stdlib.ml`. (#7241, @emillon)

- Speed up file copying on macos by using `clonefile` when available
(@rgrinberg, #7210)

Expand Down
13 changes: 9 additions & 4 deletions src/dune_rules/compilation_context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,16 @@ let create ~super_context ~scope ~expander ~obj_dir ~modules ~flags
}

let for_alias_module t alias_module =
let keep_flags = Modules.is_stdlib_alias (modules t) alias_module in
let flags =
let project = Scope.project t.scope in
let dune_version = Dune_project.dune_version project in
let profile = (Super_context.context t.super_context).profile in
Ocaml_flags.default ~dune_version ~profile
if keep_flags then
(* in the case of stdlib, these flags can be written by the user *)
t.flags
else
let project = Scope.project t.scope in
let dune_version = Dune_project.dune_version project in
let profile = (Super_context.context t.super_context).profile in
Ocaml_flags.default ~dune_version ~profile
in
let sandbox =
let ctx = Super_context.context t.super_context in
Expand Down
18 changes: 18 additions & 0 deletions test/blackbox-tests/test-cases/stdlib/stdlib-flags.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$ cat > dune-project << EOF
> (lang dune 3.7)
> (using experimental_building_ocaml_compiler_with_dune 0.1)
> EOF

$ cat > dune << EOF
> (library
> (name mystdlib)
> (stdlib)
> (flags :standard -w -8))
> EOF

$ cat > mystdlib.ml << EOF
> (* This triggers warning 8 *)
> let None = None
> EOF

$ dune build