foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Debugger: Show generated yul when compiled --via-ir

Open zk-tarts opened this issue 2 years ago • 4 comments

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:

  1. Compile solidity --via ir which generates a solidity --> bytecode sourcemap
  2. Compile the generated yul which will output a yul --> bytecode sourcemap.

#759 is worth mentioning because yul compilation is required to do those steps.

zk-tarts avatar Apr 10 '22 03:04 zk-tarts

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 :)

onbjerg avatar Apr 11 '22 15:04 onbjerg

assign this to me @onbjerg

malik672 avatar Feb 13 '24 09:02 malik672

@onbjerg @zk-tarts the compiler does not generate a yul file when you compile a solidity file

malik672 avatar Apr 20 '24 10:04 malik672

it generates assembly though

malik672 avatar Apr 20 '24 10:04 malik672

Compiling with forge build --via-ir --extra-output ir or forge build --via-ir --extra-output irOptimized does yield Yul

zerosnacks avatar Aug 01 '24 13:08 zerosnacks