Allow building without `dkp-pacman` installed
holly-hacker opened this issue · comments
I'm trying to create a 3ds project that I can build using a nix flake, and I'm installing devkitPro using the devkitNix overlay. This installs all the devkitARM files and correctly sets up the $DEVKITPRO
and $DEVKITARM
environment variables, but it does not install dkp-pacman
so ctru-sys
will fail to run its build script when trying to query the libctru
version.
I'm not fully familiar with ctru-sys
' build script, but it would be nice if it was possible to bypass this check or manually specify the version of libctru.
I've been trying to fix other build issues and by properly including libclang's lib folder in my path, it somehow seems to have fixed this error. It still doesn't build but I'll close this for now as I'm not sure whether this is actually fixed or not.
Interesting, I guess we had never taken into consideration the possibility for other build systems, but there was some talk about manually specifying a libctru
version already (mainly to assess builds made with custom libctru
versions). Write here or open a new issue if there are any problems you need to discuss.
It seems that my issues with linking to libctru
are gone, I don't see the error in my build output anymore. My current issue is that realpath
seems to not exist in libc and I'm not quite sure how to go about fixing it (I don't have nearly enough experience with linkers or linking to C/C++ code).
The error message looks like this:
= note: /nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libstd-757c6d6d8f22079a.rlib(std-757c6d6d8f22079a.std.718a07a5dabc4bbd-cgu.02.rcgu.o): in function `std::sys::unix::fs::canonicalize::{{closure}}':
/nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1720: undefined reference to `realpath'
collect2: error: ld returned 1 exit status
Full build output
variant9@nixos ~/P/r/bla (master)> cargo 3ds build No pre-build std found, using build-std Compiling bla v0.1.0 (/home/variant9/Projects/rust-3ds-test/bla) error: linking with `arm-none-eabi-gcc` failed: exit status: 1 | = note: LC_ALL="C" PATH="/nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/lib/rustlib/x86_64-unknown-linux-gnu/bin:/nix/store/44pqwx8bjngjpkbk1y2dd8pzs49s14w9-patchelf-0.15.0/bin:/nix/store/khkhbch4p1wjfl1g89gw1mszvvr7bzv0-gcc-wrapper-13.2.0/bin:/nix/store/j00nb8s5mwaxgi77h21i1ycb91yxxqck-gcc-13.2.0/bin:/nix/store/dvvb6frpdnimidx1f51zjgi3af8rlny1-glibc-2.38-27-bin/bin:/nix/store/5idwbbv23b6vnqdicx97s3hsgrwwnj7j-coreutils-9.4/bin:/nix/store/6zhs433c4cyaih7l65c11zm743sava5a-binutils-wrapper-2.40/bin:/nix/store/0gi4vbw1qfjncdl95a9ply43ymd6aprm-binutils-2.40/bin:/nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/bin:/nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/bin:/nix/store/rp7lvdmfriqh57a8d14fhfl37b1ws1bx-cargo-3ds-v0.1.2/bin:/nix/store/5idwbbv23b6vnqdicx97s3hsgrwwnj7j-coreutils-9.4/bin:/nix/store/4ajik70nplhkb8ndn3gqh7v0b09hmvg9-findutils-4.9.0/bin:/nix/store/y4m3b33d240amsyd50d6mn0m9pyf987p-diffutils-3.10/bin:/nix/store/9zial3lqry9f7rsw31r7vs5p1mnb7lan-gnused-4.9/bin:/nix/store/6i00hdmzlj56qy500p5gb5v88wfj6nhg-gnugrep-3.11/bin:/nix/store/w48cndp5bwz4x4l49yr2gbz09g6f91dq-gawk-5.2.2/bin:/nix/store/msavqbm59r0q4wv54s4smp0ixwl6y3dz-gnutar-1.35/bin:/nix/store/6z1ssks5dbmc9zs5cczn9qgx28yl8j8y-gzip-1.13/bin:/nix/store/zd07lalq650lv09xkkp2yc9ahx66lm25-bzip2-1.0.8-bin/bin:/nix/store/05sqpqfnha0pmb5aia3gz968im7n806v-gnumake-4.4.1/bin:/nix/store/cjbyb45nxiqidj95c4k1mh65azn1x896-bash-5.2-p21/bin:/nix/store/mmfzn2r4rq6ljlikmpgk7y1i914g40xi-patch-2.7.6/bin:/nix/store/fp49ki5fbhsq744ljmffcc646yczhw9m-xz-5.4.5-bin/bin:/nix/store/8rk7cyqxf7mdvwjnnvlh5kw7zvvnv3y0-file-5.45/bin:/run/wrappers/bin:/home/variant9/.nix-profile/bin:/nix/profile/bin:/home/variant9/.local/state/nix/profile/bin:/etc/profiles/per-user/variant9/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/opt/devkitpro/devkitARM/bin" VSLANG="1033" "arm-none-eabi-gcc" "-specs=3dsx.specs" "-mtune=mpcore" "-mfloat-abi=hard" "-mtp=soft" "/tmp/nix-shell.y5GTRF/rustcWHTPk6/symbols.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.1ct87h5rme87ek89.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.1dlbii834bo3ff1m.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.1v41jaqleztsysrq.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.2bddiri9gj55z4ju.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.2ugeb7cn7hz7qc0g.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.30mxgg521vg6f5rs.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.32t59s8y36bt0g2r.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.3rwq7u9w4h4fdpti.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.3sl1dnmekzer674p.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.3vl91jlvb70i8pfk.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.3x7fyk3br7t31x3p.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.4ru9qlg99erg8pae.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.550b89qi205oj0p7.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.561vgsg5b5j24y3p.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.5cznvd27hewfc2av.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.8an2ag2doe711u8.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.kbfbul0oyexmv20.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.okdzwin29955my0.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.ommlna1h6yvhvqc.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.t5chzmf34p6g693.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.xdmclwhsoewdw0x.rcgu.o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.9mi5v3leuatmffl.rcgu.o" "-Wl,--as-needed" "-L" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps" "-L" "/home/variant9/Projects/rust-3ds-test/bla/target/debug/deps" "-L" "/nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/opt/devkitpro/libctru/lib" "-L" "/nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/opt/devkitpro/libctru/lib" "-L" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/build/ctru-sys-04bacb6f6510687d/out" "-L" "/nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/lib/rustlib/armv6k-nintendo-3ds/lib" "-Wl,-Bdynamic" "-lctrud" "-Wl,-Bstatic" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libctru-fbf458a595ca203b.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libcfg_if-988e1267dfce64e1.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libconst_zero-c08571da0c13efa4.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libbitflags-dfbbe2b7ca099dd7.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libshim_3ds-10e4941ac64a6a13.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libpthread_3ds-978a677113307c5f.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libctru_sys-e161e8698127edd1.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/liblibc-635d4e006f805030.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libstatic_assertions-cbee3b8cc7320540.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libspin-bc8eb66c7ac1ddda.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libstd-757c6d6d8f22079a.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libpanic_unwind-f2140cac205abdee.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libobject-dd253302d2fa23fa.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libmemchr-4085b72a15229292.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libaddr2line-b15d01168b7b7f5e.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libgimli-624aa3e46cc6194a.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/librustc_demangle-efbe64d5f31e45ac.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libstd_detect-f18ee8960d2297f7.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libhashbrown-3c9dadd7f65e2445.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/librustc_std_workspace_alloc-b0ff1159d18a7aee.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libminiz_oxide-631485b56970d540.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libadler-9a7a1545bddb2428.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libunwind-96728e6432346e2b.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libcfg_if-b8c76e77975c415f.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/liblibc-a71ee02cf5c6a221.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/liballoc-d071009dd6b997f0.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/librustc_std_workspace_core-4601872e6a0e575c.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libcore-0178fda0e565e24a.rlib" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libcompiler_builtins-f6e0d4f5fe172d80.rlib" "-Wl,-Bdynamic" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lc" "-lm" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-lctrud" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/lib/rustlib/armv6k-nintendo-3ds/lib" "-o" "/home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/bla-d334f76a659dd739.elf" "-Wl,--gc-sections" "-no-pie" = note: /nix/store/gbc010vn630wk5yf83khfkbsqd0xjw5g-devkitARM/opt/devkitpro/devkitARM/bin/../lib/gcc/arm-none-eabi/12.2.0/../../../../arm-none-eabi/bin/ld: /home/variant9/Projects/rust-3ds-test/bla/target/armv6k-nintendo-3ds/debug/deps/libstd-757c6d6d8f22079a.rlib(std-757c6d6d8f22079a.std.718a07a5dabc4bbd-cgu.02.rcgu.o): in function `std::sys::unix::fs::canonicalize::{{closure}}': /nix/store/acp5nyxkf7l01acnqm8cf7fsvfx79kwj-rust-default-1.76.0-nightly-2023-11-20/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:1720: undefined reference to `realpath' collect2: error: ld returned 1 exit status= note: 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 thecargo: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)error: could not compile
bla
(bin "bla") due to previous error
In case someone with nix knowledge is interested in reproducing this issue, I'll include my flake.nix
file here:
flake.nix
{ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; devkitNix = { url = "github:bandithedoge/devkitNix"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; }; }; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; flake-utils.follows = "flake-utils"; }; }; }; outputs = { self, nixpkgs, flake-utils, devkitNix, rust-overlay, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; overlays = [ devkitNix.overlays.default rust-overlay.overlays.default ]; }; rust-toolchain = pkgs.rust-bin.nightly.latest.default.override { extensions = [ "rust-src" ]; # targets = [ "armv6k-nintendo-3ds" ]; }; cargo-3ds = pkgs.rustPlatform.buildRustPackage rec { pname = "cargo-3ds"; version = "v0.1.2";src = pkgs.fetchFromGitHub { owner = "rust3ds"; repo = pname; rev = version; hash = "sha256-2P0kycBSWnB1IPeqdkew9Q62WSpNEGaSJfs4qNIBCgE="; }; cargoHash = "sha256-xCsNO6COqmtnZRJrxKqNoPBsrLWi8/99RJ/bb3dDQ9c="; meta = { description = "Cargo command to work with Nintendo 3DS project binaries."; homepage = "https://github.com/rust3ds/cargo-3ds"; # license = lib.licenses.unlicense; maintainers = []; }; }; in { devShells.default = pkgs.mkShell { buildInputs = [ pkgs.devkitNix.devkitARM rust-toolchain cargo-3ds ]; shellHook = '' ${pkgs.devkitNix.devkitARM.shellHook} export LIBCLANG_PATH="${pkgs.llvmPackages_latest.libclang.lib}/lib" export PATH="$PATH:$DEVKITARM/bin" ''; }; });
}
You can place this flake.nix
in a folder, run nix develop
(assuming flakes are enabled), create a project with cargo 3ds new myproject
and then build it with cd myproject; cargo 3ds build
. I'm still fairly new to nix/flakes so this flake file may be a bit messy.
I never used nix (wanted to, but don’t really have the time to do some distro hopping these days). I just want to note 2 things:
realpath
is defined withindevkitARM
’slibgloss
, so there might be a problem with your setup if it isn’t found.- The issue with the build script shouldn’t have “magically” disappeared, since that command is supposed to always fire.
It seems I misread some parts of the build script, and missing pacman
will only output a build warning, which is likely suppressed in my build because of the linker warning.
I'll continue looking into the realpath issue tomorrow and report back if I made any progress. If I don't, assume I've given up and moved on :)