Semantic Diff

#9304 Check compiler-flags when a build starts

1 commit

1efa212d3594fafe30d2c46f25e2201fdbb9aed7..pr-9304

84940e72b · cknitt + Claude · Nov 14, 2026, 09:37 UTC

Check compiler-flags when a build starts

Why

The build system passed the entries of compiler-flags to the compiler unchecked. An unknown flag failed every module with the same error, and a flag that the build system sets itself, such as -bs-ns, silently conflicted with its own. A build now checks the flags of every package against the compiler's flag table once, without applying them. Format, clean and compiler-args don't compile, so they don't check them.

addedDiagnostic unknown compiler flag

// rescript.json{"name": "flags", "sources": ["src"], "compiler-flags": ["-bs-fooo"]}
diagnostic
Before
After
Unknown option "-bs-fooo".(for every module)rescript.json: field "compiler-flags": unknown flag "-bs-fooo"

The other new errors: a flag without its value, a value where a flag is expected, a flag the build system sets itself (-o, -bs-ns, -bs-package-name, -bs-package-output, -bs-project-root, -bs-read-cmi, -bs-ast, -runtime-path), and a flag with which the compiler does not compile (-e, -v, -version, -warn-help, -format, -reprint-source).

Part of #9303

Review

  • Why not run the flag parser on the flags? Some flags act when parsed: -e compiles a string, -v prints and exits, -format reads a file. Values such as warning specs are checked once a typed request replaces the flag strings (#9303).