How to specify a private repository for one library like libc?

#1

I made some change in my private repository on github for libc, then I changed the depdendencies field for libc in file src/bootstrap/Cargo.toml:

libc = { version = “0.2”, git = “https://github.com/BaoshanPang/libc.git”, branch = “vxworks” }

But in building, I still see the official reposity is used instead of my private repository. What else change should I do?

Thanks, Baoshan

0 Likes

#2

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#overriding-dependencies

When you change the normal libc dependency in your manifest, it only affects your own use. Other crates in your dependency tree may still use the libc from crates.io, distinct from yours. Using overrides as documented above will affect everything.

3 Likes

#3

Hi Cuviper,

Thanks for pointing out the document, it is very useful. I added “libc = { path = “…/libc” }” to the field [patch.crates-io] in rust’s Cargo.toml, and I do see the building is using my local code, but I am seeing this error at the stage building rustc_msan:

Compiling rustc_msan v0.0.0 (/home/bpang/myrust/rust/src/librustc_msan)

error: the feature cfg_target_vendor has been stable since 1.33.0 and no longer requires an attribute to enable –> /home/bpang/myrust/libc/src/lib.rs:22:13 | 22 | feature(cfg_target_vendor, link_cfg, no_core) | ^^^^^^^^^^^^^^^^^ | = note: -D stable-features implied by -D warnings

error: unused attribute –> /home/bpang/myrust/libc/src/lib.rs:27:1 | 27 | #![no_std] | ^^^^^^^^^^ | = note: -D unused-attributes implied by -D warnings

error: crate-level attribute should be in the root module –> /home/bpang/myrust/libc/src/lib.rs:27:1 | 27 | #![no_std] | ^^^^^^^^^^

Any idea what else change should I make?

Thanks, Baoshan

0 Likes

#4

Remove the #[feature(cfg_target_vendor)]. -A stable-features may also work.

0 Likes

#5

Hi CAD97,

Thanks for helping on this issue. Why should I change the code? I see the same code could pass building if it is built with the normal way.

Thanks, Baoshan

0 Likes

#6

The issue can be reproduced with the offical git repo when build it for x86_64:

$ git clone https://github.com/rust-lang/rust.git

$ git clone https://github.com/rust-lang/libc.git

$ cd rust

$ # edit Cargo.toml in rust to contain this line in field [patch.crates-io]:

libc = {path = “…/libc” }

$ ./x.py build

Then the erros appear:

error: the feature cfg_target_vendor has been stable since 1.33.0 and no longer requires an attribute to enable –> /home/bpang/rust_ref/libc/src/lib.rs:22:13 | 22 | feature(cfg_target_vendor, link_cfg, no_core) | ^^^^^^^^^^^^^^^^^ | = note: -D stable-features implied by -D warnings

error: unused attribute –> /home/bpang/rust_ref/libc/src/lib.rs:27:1 | 27 | #![no_std] | ^^^^^^^^^^ | = note: -D unused-attributes implied by -D warnings

error: crate-level attribute should be in the root module –> /home/bpang/rust_ref/libc/src/lib.rs:27:1 | 27 | #![no_std] | ^^^^^^^^^^

error: aborting due to 3 previous errors

0 Likes