Skip to content

Requesting bytecode/IR for one contract results in it being generated for all selected contracts #15373

@klkvr

Description

@klkvr

Description

I am attaching 2 standard JSON input files. Both of them include two sources. One of them (src/contract.sol) is a Uniswap V3 position manager (can be any contract that takes at least some time to compile). Second is a contract containing a single import directive, importing the heavy contract (import "src/contract.sol";)

In first input, bytecode output selection is requested for both contracts, and in second input - only for the second one.

input1.json
input2.json

Expected behavior

I would expect solc to skip compiling contracts which are excluded from output selection unless they appear as a bytecode dependency (new keyword or .creationCode) in some of the included contracts.

Actual behavior

It seems that both inputs take a similar pretty long time to compile event though second input basically just compiles an empty source, and outputs nothing. I assume it spends time compiling imported heavy contract

$ time cat input1.json | solc --standard-json
solc --standard-json  3.49s user 0.09s system 96% cpu 3.707 total
$ time cat input2.json | solc --standard-json
solc --standard-json  3.49s user 0.07s system 99% cpu 3.597 total

Fixing this would mean a potentially very high compile time optimization. Right now, even if tooling resolves contract dependecies, and excludes all of them from output selection, solc still spends time compiling and optimizing unused dependencies, even though the resulted bytecode is not outputted at all.

Environment

  • Compiler version: 0.8.26
  • Target EVM version (as per compiler settings): Paris
  • Operating system: macOS

Metadata

Metadata

Assignees

Labels

medium effortDefault level of effortmedium impactDefault level of impactmust have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.performance 🐎

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions