foundry
foundry copied to clipboard
Debugger: Show generated yul when compiled --via-ir
Component
Forge
Describe the feature you would like
I think a good feature to add to the debugger would be to see the optimized yul output if your file was compiled with --via-ir
option.
This is useful when you want a better view of what the compiler is doing to your code.
My preferred UI would have you able to swap between yul and solidity, like how dapptools' debugger lets you swap between the call trace view and the memory view.
If this is hard to implement then it could be a command line option, and yul would display instead of solidity.
Additional context
Assuming the solidity compiler is consistent, the implementation could follow these steps:
- Compile solidity
--via ir
which generates asolidity --> bytecode
sourcemap - Compile the generated yul which will output a
yul --> bytecode
sourcemap.
#759 is worth mentioning because yul compilation is required to do those steps.
I'm not sure Solidity generates sourcemaps for Yul. This is pretty hard as well - afaik ethers-solc does not support compiling Yul yet, and requires changes in both forge run
, forge test
and forge build
. Good request, though, definitely valuable :)
assign this to me @onbjerg
@onbjerg @zk-tarts the compiler does not generate a yul file when you compile a solidity file
it generates assembly though
Compiling with forge build --via-ir --extra-output ir
or forge build --via-ir --extra-output irOptimized
does yield Yul