rust-lang / rust-lang/libc

i586-pc-nto-qnx700 doesn't work because of missing cfg-if branch for 32-bit x86

Open
#4,241 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
2.6k
Forks
1.3k
Avg merge
1d 22h
Merged PRs (30d)
69

Description

Trying to build i586-pc-nto-qnx700 with this script:

#!/bin/bash
source ~/qnx700/qnxsdp-env.sh
export build_env='
         CC_aarch64_unknown_nto_qnx700=qcc
        CXX_aarch64_unknown_nto_qnx700=qcc
     CFLAGS_aarch64_unknown_nto_qnx700=-Vgcc_ntoaarch64le_cxx
         AR_aarch64_unknown_nto_qnx700=ntoaarch64-ar
         CC_i586_pc_nto_qnx700=qcc
        CXX_i586_pc_nto_qnx700=qcc
     CFLAGS_i586_pc_nto_qnx700=-Vgcc_ntox86_cxx
         AR_i586_pc_nto_qnx700=ntox86-ar
'

env $build_env ./x.py build \
  --target aarch64-apple-darwin,aarch64-unknown-nto-qnx700,i586-pc-nto-qnx700 \
  rustc library/core library/alloc library/std src/tools/remote-test-server

produces this error:

error[E0432]: unresolved imports `crate::c_char`, `crate::c_long`, `crate::c_ulong`
   --> /Users/jonathan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.169/src/macros.rs:84:17
    |
65  | / macro_rules! prelude {
66  | |     () => {
67  | |         /// Frequently-used types that are available on all platforms
68  | |         ///
...   |
84  | |                 c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint,
    | |                 ^^^^^^                            ^^^^^^ no `c_long` in the root
    | |                 |
    | |                 no `c_char` in the root
    | |                 help: a similar name exists in the module: `c_schar`
85  | |                 c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t,
    | |                 ^^^^^^^ no `c_ulong` in the root
...   |
88  | |     };
89  | | }
    | |_- in this expansion of `prelude!`
    |
   ::: /Users/jonathan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.169/src/lib.rs:138:9
    |
138 |           prelude!();
    |           ---------- in this macro invocation
    |
    = help: consider importing this type alias instead:
            rustc_std_workspace_core::ffi::c_char
    = help: consider importing this type alias instead:
            rustc_std_workspace_core::ffi::c_long
    = help: consider importing this type alias instead:
            rustc_std_workspace_core::ffi::c_ulong

Building the aarch64 target works.

I believe the fault lies in this block, which is missing a branch for x86.

cfg_if! {
    if #[cfg(target_arch = "x86_64")] {
        mod x86_64;
        pub use self::x86_64::*;
    } else if #[cfg(target_arch = "aarch64")] {
        mod aarch64;
        pub use self::aarch64::*;
    } else {
        panic!("Unsupported arch");
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the cfg_if! block shown in the issue and compare its architecture branches with the target-specific modules. Reproduce the reported x86 build using the provided x.py command and QNX environment, then verify that the i586-pc-nto-qnx700 target resolves the libc types and completes the requested build.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.