-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Component
Forge
Have you ensured that all of these are up to date?
- Foundry
- Foundryup
What version of Foundry are you on?
forge Version: 1.5.1-stable
What version of Foundryup are you on?
foundryup: 1.5.0
What command(s) is the bug in?
forge build --extra-output-files bin
Operating System
macOS (Apple Silicon)
Describe the bug
When using forge build --extra-output-files bin with contracts compiled by multiple profiles via additional_compiler_profiles and compilation_restrictions, Forge correctly generates multiple .json artifacts but only generates a single .bin file containing the bytecode from the additional profile, instead of generating a .bin file for each profile.
Steps to reproduce
- Clone the reproduction repository: https://github.com/RayXpub/foundry_compilation_restrictions_example/tree/main
- Build with extra output files:
forge build --extra-output-files bin- Inspect the artifacts for
Counter.sol
Expected behavior
Based on the Foundry documentation:
the same source file is compiled with several profiles, then an artifact is generated for each profile - if Counter is compiled with default and v1 profile, Counter.json and Counter.v1.json artifacts are created.
I would expect that when using --extra-output-files bin, the same convention applies to .bin files. Since Counter.sol is compiled with:
- Default profile (200 optimizer runs)
optimized-runsprofile (100,000 optimizer runs)
The output should include:
- ✅
Counter.json(default profile) - ✅
Counter.optimized-runs.json(optimized profile) - ❌ Invalid:
Counter.bin(generated with optimized profile bytecode) - ❌ Missing:
Counter.optimized-runs.bin(optimized profile bytecode)
Actual behavior
Only a single .bin file is generated:
out/Counter.sol/
├── Counter.bin # Contains optimized bytecode (100,000 runs)
├── Counter.json # Default profile artifact (200 runs)
└── Counter.optimized-runs.json # Optimized profile artifact (100,000 runs)Metadata
Metadata
Assignees
Labels
Type
Projects
Status