solidity
solidity copied to clipboard
add stop-after stage for semantic analysis
Abstract
Add another option, semantic, to --stop-after
that produces an equivalent AST as the one produced when the full compilation pipeline is ran. There is an option --stop-after parsing
but it does not do import resolution or populate the reference id's/ exported symbols and thus is insufficient for tools that use semantic analysis info added to the AST, presumably after parsing.
Motivation
The compilation pipeline is slow (~30s) on the "average" project relative to what developers expect of developer tooling, and it slows done all developer tooling that request the AST from Solidity for tasks that do not require bytecode. This would benefit all source level analysis tools such as linters, formatters, language servers, code search tools, etc.
Specification
Running solc file.sol --stop-after semantic
produces an equivalent AST as the one produced when the full compilation pipeline is ran but lowering the AST and generating the bytecode is skipped. Not as important but nice-to-have: this AST should be able to be cached and passed back to solc with the --import-ast
flag and produce the same bytecode as if it were compiled start to finish.
Backwards Compatibility
Fully backwards compatible
Hey @0xalpharush! Thanks for reporting this. I have a few comments.
The compiler will currently stop after analysis in the case where no options are being requested that could trigger compilation. Devs were running into a bug wherein unnecessary compilation was being performed when --via-ir
was used. This was recently fixed (see: https://github.com/ethereum/solidity/issues/14917 and the corresponding fix in #14926).
Please note that the current behaviour solves your issue unless you have observed any other options (such as the --via-ir
in the previous bug) that might be triggering compilation unnecessarily. If so, please mention those as a response to this. It would make most sense to work on a fix for that which would solve the underlying issue.
On the flip side, if you were already aware of the above and have a specific use case in mind that is not possible to implement with the current state of the compiler, feel free to outline it for us.
I don't see how that issue or PR is related to the --stop-after
flag or the limitations of the parsing stage that motivated my feature request. I don't think this is a bug or something that can be worked around as it is not implemented
EDIT: I think I misunderstood and you're suggesting to simply not request --bin
and it should speed up everything else. Did you mean that solc --ast
or solc --ast --via-ir
should produce a complete AST with reference ids and imports resolved or am I mistaken?
You understand it correctly. :)
So my ask here is for you to mention any possible cases that aren't covered by the current behaviour. In which case, it would make sense to keep this issue open. If not, I would close this issue for now.
Ôk
This issue has been marked as stale due to inactivity for the last 90 days. It will be automatically closed in 7 days.