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

add stop-after stage for semantic analysis #15043

Open
0xalpharush opened this issue Apr 20, 2024 · 4 comments
Open

add stop-after stage for semantic analysis #15043

0xalpharush opened this issue Apr 20, 2024 · 4 comments
Labels

Comments

@0xalpharush
Copy link
Contributor

0xalpharush commented Apr 20, 2024

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

@mehtavishwa30
Copy link
Contributor

mehtavishwa30 commented Apr 24, 2024

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: #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.

@0xalpharush
Copy link
Contributor Author

0xalpharush commented Apr 24, 2024

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?

@mehtavishwa30
Copy link
Contributor

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.

@Duc0777776660

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants