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
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).