Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing values in libc in latest nightly #25

Closed
spencerelliott opened this issue Aug 6, 2022 · 9 comments
Closed

Missing values in libc in latest nightly #25

spencerelliott opened this issue Aug 6, 2022 · 9 comments

Comments

@spencerelliott
Copy link

Whenever I try to compile rust3ds-template project using cargo 3ds build, I get the following error:

error[E0425]: cannot find value `UTIME_OMIT` in crate `libc`
   --> /home/spencer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:552:63
    |
552 |         let omit = libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ };
    |                                                               ^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find function `futimens` in crate `libc`
    --> /home/spencer/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1118:36
     |
1118 |                 cvt(unsafe { libc::futimens(self.as_raw_fd(), times.0.as_ptr()) })?;
     |                                    ^^^^^^^^ help: a function with a similar name exists: `utimes`
     |
    ::: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/libc-0.2.126/src/unix/mod.rs:1159:5
     |
1159 |     pub fn utimes(filename: *const ::c_char, times: *const ::timeval) -> ::c_int;
     |     ---------------------------------------------------------------------------- similarly named function `utimes` defined here

For more information about this error, try `rustc --explain E0425`.
error: could not compile `std` due to 2 previous errors

I have tried running cargo clean, cargo update, and I have even deleted the entire folder and started over.

My version of nightly is:

nightly-x86_64-unknown-linux-gnu (default)
rustc 1.64.0-nightly (affe0d3a0 2022-08-05)
@ian-h-chamberlain
Copy link
Member

ian-h-chamberlain commented Aug 7, 2022

Unfortunately the rust3ds-template is pretty out of date and probably does not work with cargo-3ds at all.

We are in the midst of reorganizing the rust3ds organization, hopefully to make it less confusing to get started and archive some of the old repos (like rust3ds-template) that are no longer needed to get everything building...

For now, the simplest quick-start option is probably to clone https://github.com/Meziu/ctru-rs (which we are working to upstream to the rust3ds org) and try to cargo +nightly 3ds build some of the examples there: https://github.com/Meziu/ctru-rs/tree/master/ctru-rs/examples

As far as I know, those should mostly work with just ctru-rs as a dependency, which hopefully gives you a starting point to work from? We could probably stand to update the README here to make it more obvious how to get started, so perhaps this issue can be used to track that work.

Let me know if you have troubles, I'd like to make it as simple as possible for people to start using cargo-3ds and related libraries, so docs improvements should be forthcoming!

@ian-h-chamberlain
Copy link
Member

Hmm, after trying myself I realize there seems to have been a regression in std nightly for horizon (similarly, ESP-IDF and Redox had fixes around this): rust-lang/rust@e86c128

If you try with an older nightly (e.g. nightly-2022-07-18), it should work... we'll have to open a PR upstream to fix it in future versions.

@spencerelliott
Copy link
Author

Thanks for looking into this. I will try switching to a different nightly and attempt compiling again. I'll let you know if everything works.

@spencerelliott
Copy link
Author

spencerelliott commented Aug 7, 2022

I am able to compile the Rust source for the hello world example from the Meziu repository but the linker fails with the following error:

error: linking with `arm-none-eabi-gcc` failed: exit status: 1
  |
  = note: "arm-none-eabi-gcc" "-specs=3dsx.specs" "-mtune=mpcore" "-mfloat-abi=hard" "-mtp=soft" "/tmp/rustcGsV4aq/symbols.o" "/home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/rust3ds_template-60abccf8cfbf4027.ctru-3f8df33ef42cdc17.ctru.e2c90a4f-cgu.0.rcgu.o.rcgu.o" "-Wl,--as-needed" "-L" "/home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps" "-L" "/home/spencer/projects/rust3ds-template-master/target/debug/deps" "-L" "/opt/devkitpro//libctru/lib" "-L" "/opt/devkitpro//libctru/lib" "-L" "/home/spencer/.rustup/toolchains/nightly-2022-07-18-x86_64-unknown-linux-gnu/lib/rustlib/armv6k-nintendo-3ds/lib" "-lctru" "-Wl,-Bstatic" "/tmp/rustcGsV4aq/libctru_sys-88e3acefb5528873.rlib" "-Wl,--start-group" "-Wl,--end-group" "/home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib" "-Wl,-Bdynamic" "-lctru" "-lctru" "-lc" "-lm" "-lctru" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/spencer/.rustup/toolchains/nightly-2022-07-18-x86_64-unknown-linux-gnu/lib/rustlib/armv6k-nintendo-3ds/lib" "-o" "/home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/rust3ds_template-60abccf8cfbf4027.elf" "-Wl,--gc-sections" "-no-pie"

  = note: /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.15.rcgu.o): in function `compiler_builtins::float::conv::int_to_float::u64_to_f64_bits':
          /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:45: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:46: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:47: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:47: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:48: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.15.rcgu.o):/home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/float/conv.rs:49: more undefined references to `core::panicking::panic' follow
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.7.rcgu.o): in function `core::f64::<impl f64>::to_bits':
          /home/spencer/.rustup/toolchains/nightly-2022-07-18-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs:934: undefined reference to `core::intrinsics::const_eval_select'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.7.rcgu.o): in function `core::f64::<impl f64>::from_bits':
          /home/spencer/.rustup/toolchains/nightly-2022-07-18-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/f64.rs:1027: undefined reference to `core::intrinsics::const_eval_select'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.9.rcgu.o): in function `compiler_builtins::arm::__aeabi_memcpy4':
          /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/arm.rs:105: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.9.rcgu.o): in function `compiler_builtins::arm::__aeabi_memset4':
          /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/arm.rs:154: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.1.rcgu.o): in function `compiler_builtins::int::specialized_div_rem::u32_normalization_shift':
          /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/int/specialized_div_rem/norm_shift.rs:64: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/int/specialized_div_rem/norm_shift.rs:66: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/int/specialized_div_rem/norm_shift.rs:69: undefined reference to `core::panicking::panic'
          /opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.1.0/../../../../arm-none-eabi/bin/ld: /home/spencer/projects/rust3ds-template-master/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-d99bd19cd65bc4ce.rlib(compiler_builtins-d99bd19cd65bc4ce.compiler_builtins.01645937-cgu.1.rcgu.o):/home/spencer/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.73/src/int/specialized_div_rem/delegate.rs:71: more undefined references to `core::panicking::panic' follow
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

@Meziu
Copy link
Member

Meziu commented Aug 7, 2022

Hmm, after trying myself I realize there seems to have been a regression in std nightly for horizon (similarly, ESP-IDF and Redox had fixes around this): rust-lang/rust@e86c128

If you try with an older nightly (e.g. nightly-2022-07-18), it should work... we'll have to open a PR upstream to fix it in future versions.

I've made a fix in my local repository (it's just 2 lines of #[cfg]). I will PR it.

@Meziu
Copy link
Member

Meziu commented Aug 7, 2022

I've opened rust-lang/rust#100249

@Meziu
Copy link
Member

Meziu commented Aug 7, 2022

I am able to compile the Rust source for the hello world example from the Meziu repository but the linker fails with the following error:

This shouldn't happen in a clean install. I'd suggest to cargo clean the project and retry. Otherwise, check your installation (correct rust-src installed, latest devkitARM etc.). What were your installation steps? @spencerelliott

@spencerelliott
Copy link
Author

spencerelliott commented Aug 7, 2022

Hi @Meziu, I used the devkitPro pacman command to install the latest version of devkitARM along with the examples. To install the Rust toolchain, I ran the following commands:

rustup install nightly-2022-07-18
rustup +nightly-2022-07-18 component add rust-src
cd <project directory>
rustup override set nightly-2022-07-18
cargo clean
cargo update
cargo 3ds build

While I was writing out these steps, I also looked at my Cargo.toml file and I removed the following lines that were in the rust3ds-template project:

[profile.dev]
lto = true

[profile.release]
lto = true

Now, I am able to compile the 3dsx file 👍 I guess the link-time optimizations were removing needed methods.

@Meziu
Copy link
Member

Meziu commented Aug 8, 2022

Indeed. Because of some issues with how the libraries are linked, lto breaks some workarounds we are currently using (mainly to link a library after it’s used…). It’s weird really, but we could not find any other way, even with the help of Rust’s maintainers.

@Meziu Meziu closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants