-
-
Notifications
You must be signed in to change notification settings - Fork 113
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(compiler): Don't trigger recompilation for unnecessary compiler flags #2106
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Digestable configurations are ones that affect Grain object files. | ||
// Any config options that don't change object files should be marked | ||
// NotDigestable to avoid unnecessary recompiles | ||
type digestable = | ||
| Digestable | ||
| NotDigestable; | ||
|
@@ -86,6 +89,7 @@ let opt: | |
~env_docs: string=?, | ||
~env_doc: string=?, | ||
~env: string=?, | ||
~digestable: digestable, | ||
~names: list(string), | ||
~conv: Cmdliner.Arg.conv('a), | ||
'a | ||
|
@@ -99,11 +103,12 @@ let opt: | |
~env_docs=?, | ||
~env_doc=?, | ||
~env=?, | ||
~digestable, | ||
~names, | ||
~conv as c, | ||
v, | ||
) => { | ||
let cur = internal_opt(v, Digestable); | ||
let cur = internal_opt(v, digestable); | ||
specs := | ||
[ | ||
Spec( | ||
|
@@ -138,12 +143,23 @@ let toggle_flag: | |
~env_docs: string=?, | ||
~env_doc: string=?, | ||
~env: string=?, | ||
~digestable: digestable, | ||
~names: list(string), | ||
bool | ||
) => | ||
ref(bool) = ( | ||
(~docs=?, ~docv=?, ~doc=?, ~env_docs=?, ~env_doc=?, ~env=?, ~names, default) => { | ||
let cur = internal_opt(default, Digestable); | ||
ref(bool) = | ||
( | ||
~docs=?, | ||
~docv=?, | ||
~doc=?, | ||
~env_docs=?, | ||
~env_doc=?, | ||
~env=?, | ||
~digestable, | ||
~names, | ||
default, | ||
) => { | ||
let cur = internal_opt(default, digestable); | ||
specs := | ||
[ | ||
Spec( | ||
|
@@ -172,19 +188,7 @@ let toggle_flag: | |
...specs^, | ||
]; | ||
cur; | ||
}: | ||
( | ||
~docs: string=?, | ||
~docv: string=?, | ||
~doc: string=?, | ||
~env_docs: string=?, | ||
~env_doc: string=?, | ||
~env: string=?, | ||
~names: list(string), | ||
bool | ||
) => | ||
ref(bool) | ||
); | ||
}; | ||
|
||
let save_config = () => { | ||
let single_save = | ||
|
@@ -325,6 +329,7 @@ let profile = | |
~doc="Set a compilation profile.", | ||
~names=["profile"], | ||
~conv=option_conv(Cmdliner.Arg.enum([("release", Release)])), | ||
~digestable=Digestable, | ||
None, | ||
); | ||
|
||
|
@@ -335,6 +340,7 @@ let memory_base = | |
~doc="Set the start address for the Grain runtime heap.", | ||
~names=["memory-base"], | ||
~conv=option_conv(Cmdliner.Arg.int), | ||
~digestable=Digestable, | ||
None, | ||
); | ||
|
||
|
@@ -344,6 +350,7 @@ let include_dirs = | |
~conv=Cmdliner.Arg.(list(dir)), | ||
~doc="Extra library include directories", | ||
~docv="DIR", | ||
~digestable=NotDigestable, | ||
[], | ||
); | ||
|
||
|
@@ -353,17 +360,24 @@ let stdlib_dir = | |
~conv=option_conv(Cmdliner.Arg.string), | ||
~doc="Path to the standard library (stdlib) directory", | ||
~env="GRAIN_STDLIB", | ||
~digestable=Digestable, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remind me why the stdlib option would be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't need to be, good catch. |
||
None, | ||
); | ||
|
||
let color_enabled = | ||
toggle_flag(~names=["no-color"], ~doc="Disable colored output", true); | ||
toggle_flag( | ||
~names=["no-color"], | ||
~doc="Disable colored output", | ||
~digestable=NotDigestable, | ||
true, | ||
); | ||
|
||
let initial_memory_pages = | ||
opt( | ||
~names=["initial-memory-pages"], | ||
~conv=Cmdliner.Arg.int, | ||
~doc="Initial number of WebAssembly memory pages", | ||
~digestable=NotDigestable, | ||
64, | ||
); | ||
|
||
|
@@ -372,36 +386,45 @@ let maximum_memory_pages = | |
~names=["maximum-memory-pages"], | ||
~conv=option_conv(Cmdliner.Arg.int), | ||
~doc="Maximum number of WebAssembly memory pages", | ||
~digestable=NotDigestable, | ||
None, | ||
); | ||
|
||
let import_memory = | ||
toggle_flag( | ||
~names=["import-memory"], | ||
~doc="Import the memory from `env.memory`", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
type compilation_mode = | ||
| Normal /* Standard compilation with regular bells and whistles */ | ||
| Runtime /* GC doesn't exist yet, allocations happen in runtime heap */; | ||
|
||
let compilation_mode = internal_opt(Normal, Digestable); | ||
let compilation_mode = internal_opt(Normal, NotDigestable); | ||
|
||
let statically_link = | ||
toggle_flag(~names=["no-link"], ~doc="Disable static linking", true); | ||
toggle_flag( | ||
~names=["no-link"], | ||
~doc="Disable static linking", | ||
~digestable=NotDigestable, | ||
true, | ||
); | ||
|
||
let no_tail_call = | ||
toggle_flag( | ||
~names=["no-wasm-tail-call"], | ||
~doc="Disables tail-call optimization", | ||
~digestable=Digestable, | ||
false, | ||
); | ||
|
||
let strict_sequence = | ||
toggle_flag( | ||
~names=["strict-sequence"], | ||
~doc="Enable strict sequencing", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
|
@@ -412,20 +435,23 @@ let debug = | |
toggle_flag( | ||
~names=["debug"], | ||
~doc="Compile with debugging information", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
let wat = | ||
toggle_flag( | ||
~names=["wat"], | ||
~doc="Additionally produce a WebAssembly Text (.wat) file", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
let verbose = | ||
toggle_flag( | ||
~names=["verbose"], | ||
~doc="Print critical information at various stages of compilation", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
|
@@ -434,27 +460,31 @@ let sexp_locs_enabled = | |
~names=["hide-locs"], | ||
~doc= | ||
"Hide locations from intermediate trees. Only has an effect with `--verbose'.", | ||
~digestable=NotDigestable, | ||
true, | ||
); | ||
|
||
let no_pervasives = | ||
toggle_flag( | ||
~names=["no-pervasives"], | ||
~doc="Don't automatically import the Grain Pervasives module.", | ||
~digestable=Digestable, | ||
false, | ||
); | ||
|
||
let no_gc = | ||
toggle_flag( | ||
~names=["no-gc"], | ||
~doc="Turn off reference counting garbage collection.", | ||
~digestable=Digestable, | ||
false, | ||
); | ||
|
||
let bulk_memory = | ||
toggle_flag( | ||
~names=["no-bulk-memory"], | ||
~doc="Turn off Bulk Memory operations", | ||
~digestable=Digestable, | ||
true, | ||
); | ||
|
||
|
@@ -463,25 +493,33 @@ let wasi_polyfill = | |
~names=["wasi-polyfill"], | ||
~conv=option_conv(Cmdliner.Arg.string), | ||
~doc="Custom WASI implementation", | ||
~digestable=NotDigestable, | ||
None, | ||
); | ||
|
||
let use_start_section = | ||
toggle_flag( | ||
~names=["use-start-section"], | ||
~doc="Replace the _start export with a start section during linking.", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
let elide_type_info = | ||
toggle_flag( | ||
~names=["elide-type-info"], | ||
~doc="Don't include runtime type information used by toString/print", | ||
~digestable=Digestable, | ||
false, | ||
); | ||
|
||
let source_map = | ||
toggle_flag(~names=["source-map"], ~doc="Generate source maps", false); | ||
toggle_flag( | ||
~names=["source-map"], | ||
~doc="Generate source maps", | ||
~digestable=NotDigestable, | ||
false, | ||
); | ||
|
||
let print_warnings = internal_opt(true, NotDigestable); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit typo on
digestible