Skip to content

Cannot find librustapp.a: No such file or directory #97

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

Open
cordawyn opened this issue May 4, 2025 · 1 comment
Open

Cannot find librustapp.a: No such file or directory #97

cordawyn opened this issue May 4, 2025 · 1 comment

Comments

@cordawyn
Copy link

cordawyn commented May 4, 2025

Hello!

I'm trying to compile a sample app in Rust targeting riscv64. It is essentially a copy of "hello_world" from "samples" dir, without modifications. Everything seems to proceed just fine until I get the error, as shown below:

$ west build -b qemu_riscv64

[1/9] Building Rust application
    Finished `release` profile [optimized] target(s) in 3.21s
[2/7] Linking C executable zephyr/zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/zephyr_pre0.map
: && ccache /home/cordawyn/zephyr-sdk-0.17.0/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/riscv/core/offsets/offsets.c.obj  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/riscv/core/libarch__riscv__core.a  zephyr/lib/libc/picolibc/liblib__libc__picolibc.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/drivers/interrupt_controller/libdrivers__interrupt_controller.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr  -lgcc  -Wl,--allow-multiple-definition  rust/target/riscv64imac-unknown-none-elf/release/librustapp.a  zephyr/arch/common/libisr_tables.a  -mcmodel=medany  -mabi=lp64  -march=rv64imac_zicsr_zifencei  -fuse-ld=bfd  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie  -specs=picolibc.specs  -DPICOLIBC_LONG_LONG_PRINTF_SCANF -L"/home/cordawyn/zephyr-sdk-0.17.0/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/12.2.0/rv64imac_zicsr_zifencei/lp64/medany" -lc -lgcc && cd /home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr && /usr/bin/cmake -E true
/home/cordawyn/zephyr-sdk-0.17.0/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/12.2.0/../../../../riscv64-zephyr-elf/bin/ld.bfd: cannot find rust/target/riscv64imac-unknown-none-elf/release/librustapp.a: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /usr/bin/cmake --build /mnt/e/projects/zephyrproject/try-zephyr/build

(Before you get confused, "/home/cordawyn/projects" is a softlink to "/mnt/e/projects", but different tools seem to prefer different "true paths").

No other errors were encountered during the build process so far.

I also tried building "librustapp" using:

$ cd build && ninja -v librustapp

[1/1] cd /home/cordawyn/projects/zephyrproject/try-zephyr && /usr/bin/cmake -E env BUILD_DIR=/home/cordawyn/projects/zephyrproject/try-zephyr/build ZEPHYR_BASE=/home/cordawyn/projects/zephyrproject/zephyr DOTCONFIG=/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/.config ZEPHYR_DTS=/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/zephyr.dts INCLUDE_DIRS="/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/include/generated/zephyr /home/cordawyn/projects/zephyrproject/zephyr/include /home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/include/generated /mnt/e/projects/zephyrproject/zephyr/soc/qemu/virt_riscv /home/cordawyn/projects/zephyrproject/zephyr/lib/libc/common/include /home/cordawyn/projects/zephyrproject/zephyr/soc/common/riscv-privileged/. " INCLUDE_DEFINES="KERNEL __ZEPHYR__=1  __LINUX_ERRNO_EXTENSIONS__ PICOLIBC_LONG_LONG_PRINTF_SCANF K_HEAP_MEM_POOL_SIZE=0" WRAPPER_FILE="/home/cordawyn/projects/zephyrproject/try-zephyr/build/rust/wrapper.c" DT_AUGMENTS="/home/cordawyn/projects/zephyrproject/modules/lang/rust/dt-rust.yaml" BINARY_DIR_INCLUDE_GENERATED="/home/cordawyn/projects/zephyrproject/try-zephyr/build/zephyr/include/generated/zephyr" cargo build --release --config patch.crates-io.zephyr.path=\"/home/cordawyn/projects/zephyrproject/modules/lang/rust/zephyr\" --config patch.crates-io.zephyr-build.path=\"/home/cordawyn/projects/zephyrproject/modules/lang/rust/zephyr-build\" --config patch.crates-io.zephyr-sys.path=\"/home/cordawyn/projects/zephyrproject/modules/lang/rust/zephyr-sys\" --target riscv64imac-unknown-none-elf --target-dir /home/cordawyn/projects/zephyrproject/try-zephyr/build/rust/target
    Finished `release` profile [optimized] target(s) in 3.03s

... which seemed to have succeeded, but it still did not result in getting "librustapp.a" anywhere.

I tried looking through any possible CMakeFiles.txt or build.ninja files produced, but couldn't find any clues.

It should probably be noted that I'm not an experienced developer in this area, just trying my first steps. So I could be missing something obvious. Your help would be much appreciated!

If it helps, here's some numbers:

  • Host OS: Ubuntu 22.04 (WSL)
  • Target board: qemu_riscv64
  • "riscv64imac-unknown-none-elf" target is installed with rustup
  • Zephyr SDK: 0.17.0 (includes the toolchain for "riscv64-zephyr-elf")
  • West: 1.3.0
  • Rustc: 1.83.0
  • Clang: 14.0.0
  • Ninja: 1.10.1
  • CMake: 3.22.1
@cordawyn
Copy link
Author

cordawyn commented May 19, 2025

After some poking around I discovered that the build actually produces a couple of libtry_zephyr.{a,d} files in build/rust/target/riscv64imac-unknown-none-elf/release/ ("try-zephyr" is the name of my project). I renamed those files to librustapp.{a,d} and the build proceeded just fine, producing the final zephyr.elf. I ran it with QEMU and it worked just fine.

Update: I later successfully recompiled the whole project again by changing the "name" to "rustapp" in Cargo.toml.

So I assume that "librustapp" is a placeholder which did not get replaced with the project name during the build configuration phase? I suppose this should be the actual issue reported here.

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

1 participant