diff --git a/ctru-rs/Cargo.toml b/ctru-rs/Cargo.toml index fd0360f..4d395a1 100644 --- a/ctru-rs/Cargo.toml +++ b/ctru-rs/Cargo.toml @@ -11,6 +11,8 @@ name = "ctru" [dependencies] ctru-sys = { path = "../ctru-sys", version = "0.4" } +linker-fix-3ds = { git = "https://github.com/AzureMarker/rust-linker-fix-3ds.git" } +pthread-3ds = { git = "https://github.com/AzureMarker/pthread-3ds.git" } libc = "0.2" bitflags = "1.0.0" widestring = "0.2.2" diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 61da7a1..6c9342c 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -8,6 +8,15 @@ extern crate widestring; extern crate ctru_sys as libctru; +/// Call this somewhere to force Rust to link some required crates +/// (ex. pthread-3ds). The call doesn't need to execute, just exist. +/// +/// See https://github.com/rust-lang/rust/issues/47384 +pub fn init() { + linker_fix_3ds::init(); + pthread_3ds::init(); +} + pub mod applets; pub mod console; pub mod error; diff --git a/ctru-sys/Cargo.toml b/ctru-sys/Cargo.toml index 92204c7..2dedcf5 100644 --- a/ctru-sys/Cargo.toml +++ b/ctru-sys/Cargo.toml @@ -7,4 +7,3 @@ links = "ctru" [dependencies] libc = { version = "0.2", default-features = false } -linker-fix-3ds = { git = "https://github.com/Meziu/rust-linker-fix-3ds.git" } diff --git a/ctru-sys/build.rs b/ctru-sys/build.rs index 1f14260..7464b18 100644 --- a/ctru-sys/build.rs +++ b/ctru-sys/build.rs @@ -2,20 +2,9 @@ use std::env; fn main() { let dkp_path = env::var("DEVKITPRO").unwrap(); - let manifest_path = env::var("CARGO_MANIFEST_DIR").unwrap(); let profile = env::var("PROFILE").unwrap(); println!("cargo:rustc-link-search=native={}/libctru/lib", dkp_path); - println!("cargo:rustc-link-search=native={}", manifest_path); - println!( - "cargo:rustc-link-search=native={}/devkitARM/arm-none-eabi/lib/armv6k/fpu", - dkp_path - ); - println!( - "cargo:rustc-link-search=native={}/devkitARM/lib/gcc/arm-none-eabi/11.1.0/armv6k/fpu", - dkp_path - ); - println!( "cargo:rustc-link-lib=static={}", match profile.as_str() { @@ -23,8 +12,4 @@ fn main() { _ => "ctru", } ); - println!("cargo:rustc-link-lib=static=gcc"); - println!("cargo:rustc-link-lib=static=sysbase"); - println!("cargo:rustc-link-lib=static=c"); - println!("cargo:rustc-link-lib=static=pthread_3ds"); } diff --git a/ctru-sys/libpthread_3ds.a b/ctru-sys/libpthread_3ds.a deleted file mode 100644 index 0bdd9b8..0000000 Binary files a/ctru-sys/libpthread_3ds.a and /dev/null differ diff --git a/ctru-sys/src/lib.rs b/ctru-sys/src/lib.rs index 3083ae2..40ffd94 100644 --- a/ctru-sys/src/lib.rs +++ b/ctru-sys/src/lib.rs @@ -4,6 +4,5 @@ #![no_std] extern crate libc; -extern crate linker_fix_3ds; include!("bindings.rs");