matter-labs / foundry-zksync

Fork of Foundry tailored for zkSync environment
Apache License 2.0
299 stars 130 forks source link

LLVM IR generator definition pass error #317

Closed ChiHaoLu closed 5 months ago

ChiHaoLu commented 7 months ago

Component

Forge

Have you ensured that all of these are up to date?

What version of Foundry are you on?

No response

What command(s) is the bug in?

forge build --zksync

Operating System

macOS (Apple Silicon)

Describe the bug

I am building the a project with zkSync-foundry, but I meet a problem returns error when compiling:

$ forge build --zksync
>
[⠒] Compiling...
No files changed, compilation skipped

Error:
Failed to compile with zksolc: Compilation failed with "Contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` compiling error: 

The contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` LLVM IR generator definition pass error: 

Library `contracts/util/SignatureChecker.sol:SignatureChecker` not found in the project

The contract `contracts/v2/FiatTokenV2.sol:FiatTokenV2` LLVM IR generator definition pass error: 

Library `contracts/util/SignatureChecker.sol:SignatureChecker` not found in the project\n\n\nStack backtrace:
    0: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    1: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    2: __mh_execute_header
    3: __mh_execute_header
    4: __mh_execute_header
    5: __mh_execute_header
    6: __mh_execute_header
    7: __mh_execute_header
    8: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    9: __mh_execute_header
    10: __mh_execute_header
    11: __mh_execute_header
    12: __mh_execute_header
    13: __mh_execute_header
    14: __mh_execute_header
    15: __mh_execute_header
    16: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    17: __mh_execute_header
    18: __mh_execute_header
    19: __mh_execute_header
    20: __ZN4llvm15SmallVectorBaseIyE8grow_podEPvmm
    21: __pthread_deallocate\n". 

Using compiler: "/Users/chihaolu/.zksync/zksolc-macosx-arm64-v1.4.0", with args "/Users/chihaolu/Desktop/project/stablecoin-zkSync/contracts/v2/FiatTokenV2.sol" ["--standard-json", "--solc", "/Users/chihaolu/.svm/0.6.12/solc-0.6.12"]

My repo is here, you can use it to reproduce.

I found some similar issues, but I still can't figure out how to solve this problem.

dutterbutter commented 7 months ago

Thanks @ChiHaoLu we are in the process of improving compiling so this is very helpful.

Karrq commented 5 months ago

Hello, I wanted to let you know that this should been taken care of by #357!

You should now get a better error when using forge build --zksync which also lets you know what you need to do next (and I expect it to mention SignatureChecker).

Looking at the information you provided tho, I expect you to encounter #382 when doing forge test --zksync, please take a look there for more information.

If you still encounter this error please let us know

Karrq commented 5 months ago

I tried your repo locally and I got the expected error.

--> contracts/util/SignatureChecker.sol
Error: 
Missing libraries detected [ZkMissingLibrary { contract_name: "SignatureChecker", contract_path: "contracts/util/SignatureChecker.sol", missing_libraries: [] }]

Run the following command in order to deploy the missing libraries:
forge create --deploy-missing-libraries --private-key <PRIVATE_KEY> --rpc-url <RPC_URL> --chain <CHAIN_ID> --zksync

Thank you for your report! If the issue persists on your end, please reopen this issue.