Code Monkey home page Code Monkey logo

rust3ds-template's Introduction

Deprecated

This repository has been deprecated in favour of the new example projects present within the new ctru-rs version of the Rust3DS toolchain. Also, the build instructions here documented aren't valid for our new projects. For more information about the new tools and libraries, check ctru-rs.

Rust 3DS Template

An example project demonstrating how to compile and run Rust programs on the Nintendo 3DS using ctru-rs.

Requirements

A nightly version of Rust is required to use this project. If you don't have Rust installed or don't have a nightly compiler, check out rustup.rs.

Next, you will need Xargo to facilitate cross-compilation to the 3DS.

Finally, you will need the most recent version of devkitARM.

Preparation of the requirements

Installing Rust

If you don't have Rust installed (macOS & Linux):

`$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly`

If you have already installed rustup:

`$ rustup default nightly`

Installing Xargo

`$ rustup component add rust-src`
`$ cargo install xargo`

Installing devkitARM

As of this writing, the current version of devkitARM is r48 and the current version of libctru is 1.5.0.

A detailed tutorial on how to set up devkitARM can be found on the 3dbrew wiki.

On macOS & Linux, devkitARM requires two environment variables to be set:

  • $DEVKITPRO = /path/to/devkitPro/ (usually /opt/devkitpro/)
  • $DEVKITARM = $DEVKITPRO/devkitARM

Usage

Use the included Makefile to build your program. Under the hood, make calls xargo to create a custom sysroot containing cross-compiled versions of the Rust core libraries, as well as a limited version of the Rust standard library. xargo caches the sysroot after it has been built for the first time. Once the sysroot is in place, a Homebrew Launcher-compatible 3dsx version of your program will be generated.

Running make will build your program in release mode. Running make test will open your program in the Citra emulator if you have it installed. Running make send will send your program to your 3DS via 3dslink (press Y in the Homebrew Launcher to receive the program).

Troubleshooting

I get an error saying that the 3ds target can't be found when I run xargo build

Recent versions of Rust require you to set the $RUST_TARGET_PATH env variable to the directory where your target spec is located. The Makefile does this automatically when you invoke it, or you can manually set the variable yourself.

std or <some other crate> is failing to build

Nightly Rust moves fast and things tend to break a lot. If you want to use a known-working nightly, try the one listed in the travis config file for ctru-rs. And feel free to file an issue detailing the error at the repo too!

I'm running my homebrew in Citra and I don't see any error message if my program panics

You need to enable Debug SVC output in Citra's logger. There are two configuration files in ~/.config/citra-emu: sdl2-config.ini and qt-config.ini. The first is for the normal citra executable and the second for citra-qt. Add Debug.Emulated:Debug to the log_filter variable for whichever version you intend to use. The Makefile calls the sdl2 version by default when running make test.

I got hello world working, but now what? Is there documentation for how to do anything else?

Not quite yet, but we're working on that. Feel free to browse the list of example programs in the meantime.

You should also become familiar with libctru's documentation if you aren't already. It will help you understand what the current ctru-rs APIs are doing, plus you can use raw libctru functions directly via the ctru-sys crate if you want access to anything not yet exposed in ctru-rs.

rust3ds-template's People

Contributors

dten avatar fenrirwolf avatar hybrideidolon avatar louy2 avatar meziu avatar panicbit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust3ds-template's Issues

Using the latest version of ctru-rs

Hi, I'm trying to use the latest version of ctru-rs with this template but I get the following error when I try to compile it:

rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/CodeGen/AsmPrinterDwarfUnit.cpp:724: llvm::DIE* llvm::DwarfUnit::getOrCreateTypeDIE(const llvm::MDNode*): assertion `Ty == resolve(Ty->getRef()) && "type was not uniqued, possible ODR violation."' failed.

I'm using a local version of ctru-rs but the problem also occurs when I'm using the git version.
Is there a way to fix this compilation problem ?

The ultimate goal would be to be able to be able to get involved into improving ctru-rs while being able to test it using this template.

I'm using the latest rust nightly with the latest xargo from git and devkitarm 44

Edit: setting lto from true to false in Cargo.toml allowed the compilation to succed, is it ok to disable it?

Error during the link

Hi,

I got the following error during the final link:
= note: arm-none-eabi-gcc: error: 3dsx.specs: No such file or directory

error: aborting due to previous error

error: Could not compile rust3ds-template.

Not sure why but I have the file in /opt/devkitpro/devkitARM/arm-none-eabi/lib/3dsx.specs

Rust updates broke stuff.

I'd successfully compiled the template project a few times using various Rust 1.4 and 1.5 nightly builds, but it seems that something broke somewhere along the line in the 1.6 nightly and onwards.

For one, libc got changed a lot and the path to it is now $RUST_SRC_PATH/src/liblibc/src/lib.rs. I also had to manually add #![no_std] to the lib.rs file because apparently libc has some sort of conditional dependency on stdlib now, and I couldn't figure out how to pass the proper condition to use libcore instead via the rust3ds_template Makefile.

Then aside from the libc stuff, any attempt to compile the template project itself fails for some reason I haven't been able to pin down. Using the --verbose flag during compilation results in a giant spew of multiple function definition errors, and I haven't been able to figure out what's causing that. Maybe the compiler-rt.a file needs to be updated?

error[E0463]: can't find crate for `core`

I'm using Fedora 32 x86_64. using pre-installed Rustup. Set default toolchain to nightly, installed xargo as what README says.

Now when I run make, This thing happens:

 kokoseij@KKSJ-devlaptop  ~/git/rust3ds-template   master  make
RUST_TARGET_PATH=/home/kokoseij/git/rust3ds-template xargo build --release
warning: Patch `rustc-std-workspace-alloc v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-std v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-std)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling compiler_builtins v0.1.32
   Compiling core v0.0.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling rustc-std-workspace-core v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
    Finished release [optimized] target(s) in 13.59s
warning: Patch `rustc-std-workspace-alloc v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-std v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-std)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling libc v0.2.71
   Compiling panic_abort v0.0.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libpanic_abort)
    Finished release [optimized] target(s) in 0.77s
warning: Patch `rustc-std-workspace-alloc v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-std v1.99.0 (/home/kokoseij/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/tools/rustc-std-workspace-std)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling cc v1.0.54
   Compiling cfg-if v0.1.10
error[E0463]: can't find crate for `core`
  |
  = note: the `3ds` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.Rv7Tjxt4GUJ6/Cargo.toml" "--target" "3ds" "-p" "panic_unwind"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace
make: *** [Makefile:20: target/3ds/release/rust3ds-template.elf] Error 1

Project doesn't build.

Steps to reproduce:

# clean up
rm -Rf ~/.cargo/
rm -Rf ~/.rustup/
rm -Rf ~/.multirust

then follow https://github.com/louy2/rust3ds-template/blob/c8eca1de0dbe0e958dec5281209844d5bc42f56e/README.md

after cloning the repo running make gives tihs this error:

error: failed to run `rustc` to learn about target-specific information

googling pointed to phil-opp/nightly-libcore#6

I downloaded the install-libcore.sh file to try to run it against the 3ds specification and it complain about a new linker-flavor flag missing in the 3ds.json file, so I added it and set to gcc, after it still looks like it cannot compile core:

error[E0557]: feature has been removed
  --> src/lib.rs:85:12
   |
85 | #![feature(reflect)]
   |            ^^^^^^^

error[E0093]: unrecognized intrinsic function: `forget`
   --> src/intrinsics.rs:671:5
    |
671 |     pub fn forget<T>(_: T) -> ();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unrecognized intrinsic

error: aborting due to previous error

error: Could not compile `core`.

I then try to run make again and it starts correctly this time, but it fails to compile a std with a bunch of other errors:

error[E0432]: unresolved import `core::num::Zero`
  --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/num.rs:21:21
   |
21 | pub use core::num::{Zero, One};
   |                     ^^^^ no `Zero` in `num`

error[E0432]: unresolved import `core::num::One`
  --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/num.rs:21:27
   |
21 | pub use core::num::{Zero, One};
   |                           ^^^ no `One` in `num`

error[E0425]: cannot find function `utf8_char_width` in module `core_str`
    --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/io/mod.rs:1645:31
     |
1645 |         let width = core_str::utf8_char_width(first_byte);
     |                               ^^^^^^^^^^^^^^^ not found in `core_str`
     |
     = help: possible candidate is found in another module, you can import it into scope:
               `use __core::str::utf8_char_width;`

error: use of unstable library feature 'core_float': stable interface is via `impl f{32,64}` in later crates (see issue #32110)
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f32.rs:276:9
    |
276 |         num::Float::integer_decode(self)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(core_float)] to the crate attributes to enable

error: use of unstable library feature 'core_float': stable interface is via `impl f{32,64}` in later crates (see issue #32110)
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f64.rs:217:53
    |
217 |     pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(core_float)] to the crate attributes to enable

error: no associated item named `integer_decode` found for type `core::num::Float` in the current scope
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f32.rs:276:9
    |
276 |         num::Float::integer_decode(self)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0038]: the trait `core::num::Float` cannot be made into an object
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f32.rs:276:9
    |
276 |         num::Float::integer_decode(self)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `core::num::Float` cannot be made into an object
    |
    = note: the trait cannot require that `Self : Sized`

error: no associated item named `integer_decode` found for type `core::num::Float` in the current scope
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f64.rs:217:53
    |
217 |     pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0038]: the trait `core::num::Float` cannot be made into an object
   --> /home/kentaromiura/.cargo/git/checkouts/ctru-rs-1206856f7a5d76bc/20a7da8/ctr-std/src/f64.rs:217:53
    |
217 |     pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) }
    |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `core::num::Float` cannot be made into an object
    |
    = note: the trait cannot require that `Self : Sized`

error: aborting due to 4 previous errors

error: Could not compile `std`.

Error compiling alloc_system

rustup 1.24.3
rustc 1.64.0-nightly

error[E0432]: unresolved imports `core::alloc::Alloc`, `core::alloc::AllocErr`
  --> /home/dev/.cargo/git/checkouts/alloc_system3ds-2e7bbb6fda5c7d52/54ee0d3/src/lib.rs:37:19
   |
37 | use core::alloc::{Alloc, GlobalAlloc, AllocErr, Layout}; 
   |                   ^^^^^               ^^^^^^^^
   |                   |                   |
   |                   |                   no `AllocErr` in `alloc`
   |                   |                   help: a similar name exists in the module: `AllocError`
   |                   no `Alloc` in `alloc`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.