Skip to content

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

Open
@cordawyn

Description

@cordawyn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions