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

forge coverage doesn't use via-ir/optimizer setting #6592

Closed
calbera opened this issue Dec 12, 2023 · 4 comments
Closed

forge coverage doesn't use via-ir/optimizer setting #6592

calbera opened this issue Dec 12, 2023 · 4 comments

Comments

@calbera
Copy link

calbera commented Dec 12, 2023

When running forge coverage, it builds differently than running forge build (seems like does not use any of the configuration provided in foundry.toml that is used by forge build).

forge coverage fails (due to no via-ir flag set):

>>> forge coverage --report lcov --root ./contracts
[⠒] Compiling...
[⠑] Compiling 112 files with 0.8.21
[⠃] Solc 0.8.21 finished in 2.68s
Error:
Compiler run failed:
Error: Compiler error (/solidity/libsolidity/codegen/LValue.cpp:56):Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.

forge build success using via-ir = true from foundry.toml:

>>> forge build --root ./contracts
[⠢] Compiling...
[⠰] Compiling 3 files with 0.8.21
[⠔] Solc 0.8.21 finished in 32.61s
Compiler run successful with warnings:
@calbera calbera changed the title forge coverage fails to use via-ir/optimizer setting forge coverage doesn't use via-ir/optimizer setting Dec 12, 2023
@calbera
Copy link
Author

calbera commented Dec 12, 2023

Ah I see that this is an intentional feature foundry-rs/forge-std#477 (comment). Is there any common work around here?

@mds1 mds1 transferred this issue from foundry-rs/forge-std Dec 13, 2023
@gakonst gakonst added this to Foundry Dec 13, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Dec 13, 2023
@mds1
Copy link
Collaborator

mds1 commented Dec 13, 2023

In order of best results:

  1. Refactor your contracts so they don't give stack too deep when compiled with no optimizer and no via-ir
  2. Run forge coverage with the --ir-minimum flag

@mds1 mds1 closed this as completed Dec 13, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Dec 13, 2023
@calbera
Copy link
Author

calbera commented Dec 13, 2023

Thanks @mds1! Yeah 1) is the main priority here. However 2) worked as well; should the flag be on the docs page? I didn't see an option on the docs and then never tried forge coverage --help to find the --ir-minimum flag.

@mds1
Copy link
Collaborator

mds1 commented Dec 13, 2023

Yes it definitely should be in the docs page, if you could open a PR for it that would be awesome! You can learn more about that flag here: #5349

@DaniPopes DaniPopes closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants