Skip to content

Can't build std if I specify target json file: std does not see networking #60

Closed
rust-lang/rust
#120232
@vi

Description

@vi

Building hello world for x86_64-unknown-linux-gnu works.

But if I save x86_64-unknown-linux-gnu's target specification to json and build using that json, std fails to find socket-related things.

$ cargo --version
cargo 1.48.0-nightly (8777a6b1e 2020-09-15)
$ rustc --version
rustc 1.48.0-nightly (285fc7d70 2020-09-16)

$ rustc +nightly -Z unstable-options --print target-spec-json > mytarget.json
$ gvim mytarget.json # change `is-builin` to `false`. It doesn't matter actually.
$ cargo build --release -Zbuild-std=panic_abort,std -Zbuild-std-features=panic_immediate_abort --target=./mytarget.json
...
   Compiling std v0.0.0 (/nix/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
error[E0432]: unresolved imports `crate::sys_common::net::getsockopt`, `crate::sys_common::net::setsockopt`, `crate::sys_common::net::sockaddr_to_addr`
 --> /nix/rust/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/net.rs:8:30
  |
8 | 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[E0432]: unresolved import `crate::sys_common::net::LookupHost`
... (a lot of other missing things related to networking) ...

I except building using custom target json that happens to be the same as built-in json to be exactly the same as building specifying built-in target directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    implementationImplementation exploration and tracking issuesplan before stabilizationThis needs a plan for how to address before stabilization, but does not need to be implemented.upstreamAn issue with the standard library itself or its dependencies.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions