Skip to content
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

Compiling wamr-sys for thumbv6m-none-eabi fails #30

Open
Zelzahn opened this issue Apr 22, 2024 · 2 comments
Open

Compiling wamr-sys for thumbv6m-none-eabi fails #30

Zelzahn opened this issue Apr 22, 2024 · 2 comments

Comments

@Zelzahn
Copy link

Zelzahn commented Apr 22, 2024

Honestly, I'm not really sure whether I should file this issue here or in the WAMR repo, but I would like to run WAMR on a RP2040 (thus the thumbv6m-none-eabi target).

When I try to build my project, I get the following error:

error: failed to run custom build command for `wamr-sys v0.1.0 (https://github.com/bytecodealliance/wamr-rust-sdk?branch=main#83efde0c)`

Caused by:
  process didn't exit successfully: `target/debug/build/wamr-sys-4c26d7286deec4f6/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_thumbv6m-none-eabi = None
  CMAKE_TOOLCHAIN_FILE_thumbv6m_none_eabi = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_thumbv6m-none-eabi = None
  CMAKE_GENERATOR_thumbv6m_none_eabi = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_thumbv6m-none-eabi = None
  CMAKE_PREFIX_PATH_thumbv6m_none_eabi = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_thumbv6m-none-eabi = None
  CMAKE_thumbv6m_none_eabi = None
  TARGET_CMAKE = None
  CMAKE = None
  running: cd "target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out/build" && CMAKE_PREFIX_PATH="" "cmake" ".cargo/git/checkouts/wamr-rust-sdk-a60624a35074c840/83efde0/crates/wamr-sys/wasm-micro-runtime" "-DWAMR_BUILD_AOT=1" "-DWAMR_BUILD_INTERP=1" "-DWAMR_BUILD_FAST_INTERP=1" "-DWAMR_BUILD_JIT=0" "-DWAMR_BUILD_BULK_MEMORY=1" "-DWAMR_BUILD_REF_TYPES=1" "-DWAMR_BUILD_SIMD=1" "-DWAMR_BUILD_LIBC_WASI=1" "-DWAMR_BUILD_LIBC_BUILTIN=1" "-DCMAKE_SYSTEM_NAME=none" "-DCMAKE_SYSTEM_PROCESSOR=arm" "-DCMAKE_INSTALL_PREFIX=target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -mthumb -march=armv6s-m" "-DCMAKE_C_COMPILER=/usr/bin/arm-none-eabi-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -mthumb -march=armv6s-m" "-DCMAKE_CXX_COMPILER=/usr/bin/arm-none-eabi-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -mthumb -march=armv6s-m" "-DCMAKE_ASM_COMPILER=/usr/bin/arm-none-eabi-gcc" "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
  -- The C compiler identification is GNU 13.2.1
  -- The CXX compiler identification is GNU 13.2.1
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/bin/arm-none-eabi-gcc
  -- Check for working C compiler: /usr/bin/arm-none-eabi-gcc - broken
  -- Configuring incomplete, errors occurred!

  --- stderr
  System is unknown to cmake, create:
  Platform/none to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.
  System is unknown to cmake, create:
  Platform/none to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  System is unknown to cmake, create:
  Platform/none to use this system, please post your config file on discourse.cmake.org so it can be added to cmake
  CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
    The C compiler

      "/usr/bin/arm-none-eabi-gcc"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: 'target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out/build/CMakeFiles/CMakeScratch/TryCompile-zBseL8'
      
      Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/make -f Makefile cmTC_5bad6/fast
      /usr/bin/make  -f CMakeFiles/cmTC_5bad6.dir/build.make CMakeFiles/cmTC_5bad6.dir/build
      make[1]: Entering directory 'target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out/build/CMakeFiles/CMakeScratch/TryCompile-zBseL8'
      Building C object CMakeFiles/cmTC_5bad6.dir/testCCompiler.c.obj
      /usr/bin/arm-none-eabi-gcc   -ffunction-sections -fdata-sections -mthumb -march=armv6s-m  -o CMakeFiles/cmTC_5bad6.dir/testCCompiler.c.obj -c target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out/build/CMakeFiles/CMakeScratch/TryCompile-zBseL8/testCCompiler.c
      Linking C executable cmTC_5bad6
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5bad6.dir/link.txt --verbose=1
      /usr/bin/arm-none-eabi-gcc  -ffunction-sections -fdata-sections -mthumb -march=armv6s-m  CMakeFiles/cmTC_5bad6.dir/testCCompiler.c.obj -o cmTC_5bad6
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-exit.o): in function `exit':
      exit.c:(.text.exit+0x16): undefined reference to `_exit'
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-writer.o): in function `_write_r':
      writer.c:(.text._write_r+0x10): undefined reference to `_write'
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-closer.o): in function `_close_r':
      closer.c:(.text._close_r+0xc): undefined reference to `_close'
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-lseekr.o): in function `_lseek_r':
      lseekr.c:(.text._lseek_r+0x10): undefined reference to `_lseek'
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-readr.o): in function `_read_r':
      readr.c:(.text._read_r+0x10): undefined reference to `_read'
      /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/bin/ld: /usr/bin/../lib/gcc/arm-none-eabi/13.2.1/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-sbrkr.o): in function `_sbrk_r':
      sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
      collect2: error: ld returned 1 exit status
      make[1]: *** [CMakeFiles/cmTC_5bad6.dir/build.make:99: cmTC_5bad6] Error 1
      make[1]: Leaving directory 'target/thumbv6m-none-eabi/debug/build/wamr-sys-b5227011006dca32/out/build/CMakeFiles/CMakeScratch/TryCompile-zBseL8'
      make: *** [Makefile:127: cmTC_5bad6/fast] Error 2

I don't know if the error could be inside the build.rs in wamr-sys? I'm not sure how to debug this, thus any help is very much appreciated.

@Zelzahn
Copy link
Author

Zelzahn commented Apr 23, 2024

I think maybe this blog post (PSA: Cortex-M Breakage (LLD as the default linker)) could be relevant.

@lum1n0us
Copy link
Collaborator

If it is me, I will start to use /usr/bin/arm-none-eabi-gcc manually compile a file without interference of cmake and rust. If this step is fine, you will know the problem is about rust configuration. Or else, the problem is about compilation toolchain.

$ /usr/bin/arm-none-eabi-gcc -o hello ./hello_world.c

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

2 participants