Custom target failing to build `net`

I'm trying to make a custom target that doesn't include gcc_eh and gcc_a.

I used

rustc +nightly -Z unstable-options --target=x86_64-pc-windows-gnu --#print target-spec-json

To print it out.
I then removed libgcc_eh and libgcc_a from the JSON.

I changed "is-builtin" and made it false.

Now, I run cargo build -Z build-std -Z build-std-features --target custom_file.json, but there is something in std it isn't building and I don't know what to do.

error[E0425]: cannot find function `getsockopt` in module `net`
   --> C:\Users\tpb398\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\net.rs:417:35
    |
    |                                   ^^^^^^^^^^ not found in `net`
    |
help: consider importing one of these items
    |
3   + use crate::sys::c::getsockopt;
    |
3   + use libc::getsockopt;
    |
help: if you import `getsockopt`, refer to it directly
    |
417 -         let val: c::linger = net::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
417 +         let val: c::linger = getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
    |

error[E0425]: cannot find function `setsockopt` in module `net`
   --> C:\Users\tpb398\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\net.rs:423:14
    |
423 |         net::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL)
    |              ^^^^^^^^^^ not found in `net`
    |
help: consider importing one of these items
    |
3   + use crate::sys::c::setsockopt;
    |
3   + use libc::setsockopt;
    |
help: if you import `setsockopt`, refer to it directly
    |
423 -         net::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL)
423 +         setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL)
    |

error[E0425]: cannot find function `getsockopt` in module `net`
   --> C:\Users\tpb398\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\net.rs:427:33
    |
427 |         let raw: c::BOOL = net::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?;
    |                                 ^^^^^^^^^^ not found in `net`
    |
help: consider importing one of these items
    |
3   + use crate::sys::c::getsockopt;
    |
3   + use libc::getsockopt;
    |
help: if you import `getsockopt`, refer to it directly
    |
427 -         let raw: c::BOOL = net::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?;
427 +         let raw: c::BOOL = getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?;
    |

error[E0425]: cannot find function `getsockopt` in module `net`
   --> C:\Users\tpb398\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sys\windows\net.rs:432:31
    |
432 |         let raw: c_int = net::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?;
    |                               ^^^^^^^^^^ not found in `net`
    |
help: consider importing one of these items
    |
3   + use crate::sys::c::getsockopt;
    |
3   + use libc::getsockopt;
    |
help: if you import `getsockopt`, refer to it directly
    |
432 -         let raw: c_int = net::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?;
432 +         let raw: c_int = getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?;

I have verified that the file can be read by rustc by:

rustc --print cfg --target .\custom_target_file.json    
debug_assertions
overflow_checks
panic="abort"
relocation_model="pic"
target_abi=""
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="windows"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_has_atomic
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_equal_alignment="16"
target_has_atomic_equal_alignment="32"
target_has_atomic_equal_alignment="64"
target_has_atomic_equal_alignment="8"
target_has_atomic_equal_alignment="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_os="windows"
target_pointer_width="64"
target_vendor="pc"
windows

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.