`--libraries` fails for a library found through `--include-path`

Aperta
#717 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@xermicus ci sta già lavorando.

Dal 28/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

src/C.sol imports dep/L.sol, which lives at lib/dep/L.sol and is found through --include-path lib. Its source unit name is dep/L.sol, so the library is dep/L.sol:L. solc --libraries dep/L.sol:L=0x1111...1111 compiles and links C with L at 0x1111...1111. resolc with the same command line compiles nothing and exits 1 with Error: File "dep/L.sol" reading: No such file or directory. Without --libraries, resolc compiles both contracts and leaves C unlinked. With the file-system path as the key (lib/dep/L.sol:L), resolc compiles L a second time as lib/dep/L.sol:L and C still stays unlinked, so C cannot be linked at compile time at all.

MRE (lib/dep/L.sol):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library L { function f(uint256 x) external pure returns (uint256) { return x + 1; } }

MRE (src/C.sol):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "dep/L.sol";
contract C { function g(uint256 x) external pure returns (uint256) { return L.f(x); } }

Reproduce:

A=0x1111111111111111111111111111111111111111

solc --bin --base-path . --include-path lib src/C.sol --libraries dep/L.sol:L=$A 2>/dev/null | grep -E '=====|Error'
# ======= dep/L.sol:L =======
# ======= src/C.sol:C =======
solc --bin --base-path . --include-path lib src/C.sol --libraries dep/L.sol:L=$A 2>/dev/null | grep -A2 'src/C.sol:C' | tail -1 | grep -o ${A#0x} | head -1
# 1111111111111111111111111111111111111111

resolc --bin --base-path . --include-path lib src/C.sol --libraries dep/L.sol:L=$A; echo exit=$?
# Error: File "dep/L.sol" reading: No such file or directory (os error 2)
# exit=1

resolc --bin --base-path . --include-path lib src/C.sol 2>&1 | grep -E '=====|Error|Warning'
# Warning: src/C.sol:C is unlinked. Consider providing missing libraries.
# ======= dep/L.sol:L =======
# ======= src/C.sol:C =======

resolc --bin --base-path . --include-path lib src/C.sol --libraries lib/dep/L.sol:L=$A 2>&1 | grep -E '=====|Error|Warning'
# Warning: src/C.sol:C is unlinked. Consider providing missing libraries.
# ======= dep/L.sol:L =======
# ======= lib/dep/L.sol:L =======
# ======= src/C.sol:C =======

Expected behavior: as in solc, a --libraries key is matched against source unit names only, so dep/L.sol:L links C and resolc does not read dep/L.sol from the current directory.

Git commit: 09bfc7e

Lingua principale
Rust
Stelle
104
Fork
28
Merge medio
5g 14h
PR unite (30g)
24

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di paritytech/revive

Tutte le issue di paritytech/revive

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.