Skip to content

Unresolved imports with custom target and build-std #104761

Closed
@cilki

Description

@cilki

Problem

I'm trying to create a custom target, but I can't seem to compile std even when the custom target is basically identical to the built-in.

error[E0432]: unresolved import `crate::sys_common::net::LookupHost`
  --> /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/net/socket_addr.rs:14:5
   |
14 | use crate::sys_common::net::LookupHost;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `LookupHost` in `sys::unix::net`

error[E0432]: unresolved imports `crate::sys_common::net::getsockopt`, `crate::sys_common::net::setsockopt`, `crate::sys_common::net::sockaddr_to_addr`
 --> /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/net.rs:9:30
  |
9 | use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
  |                              ^^^^^^^^^^  ^^^^^^^^^^  ^^^^^^^^^^^^^^^^ no `sockaddr_to_addr` in `sys::unix::net`
  |                              |           |
  |                              |           no `setsockopt` in `sys::unix::net`
  |                              no `getsockopt` in `sys::unix::net`

error[E0433]: failed to resolve: could not find `TcpStream` in `net_imp`
   --> /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/net/[tcp.rs:157](http://tcp.rs:157/):41
    |
157 |         super::each_addr(addr, net_imp::TcpStream::connect).map(TcpStream)
    |                                         ^^^^^^^^^ could not find `TcpStream` in `net_imp`

Steps

docker run -it --rm debian
apt update && apt install -y gcc curl
curl https://sh.rustup.rs/ -sSf | sh -s -- -y --default-toolchain none
source $HOME/.cargo/env
rustup toolchain install nightly --component rustc cargo rust-src
cargo new reproducer
cd reproducer
rustc --print=target-spec-json -Z unstable-options | grep -v is-builtin >custom.json
cargo +nightly rustc --target=custom.json -Z build-std

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.67.0-nightly (eb5d35917 2022-11-17)
release: 1.67.0-nightly
commit-hash: eb5d35917b2395194593c9ca70c3778f60c1573b
commit-date: 2022-11-17
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Linux [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zbuild-stdUnstable Cargo option: Compile the standard library yourself.A-crossArea: Cross compilationA-target-specsArea: Compile-target specificationsC-bugCategory: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions