LoginSignup
5
1

More than 3 years have passed since last update.

RustでArduinoやりたくて、Lチカするまでのエラー

Posted at

途中で飽きちゃったんだけど、下書きにあっても邪魔なので投稿しときます

RustでArduinoを動かして見たいと思い、avr-rustというAVRをサポートしたRustがあるので、使って見ようと思いました。

環境はMacOS

avr-rustのビルドとインストール

avr-rustのソースをとってくる
$ git clone https://github.com/avr-rust/rust.git
buildディレクトリを作る
$ cd rust
$ mkdir build && cd build
Makefileを作る
$ ../rust/configure \
  --enable-debug \
  --disable-docs \
  --enable-llvm-assertions \
  --enable-debug-assertions \
  --enable-optimize \
  --prefix=/opt/avr-rust
コンパイラをbuild
$ make
$ make install
toolchainを登録
$ rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage1'))
avr-toolchainを有効に
rustup default avr-toolchain

私はmakeでエラーが出ました。

haruka:rust haru$ make
Updating submodules
    Finished dev [unoptimized] target(s) in 0.0 secs
Building stage0 std artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
    Finished release [optimized] target(s) in 0.0 secs
Copying stage0 std from stage0 (x86_64-apple-darwin -> x86_64-apple-darwin / x86_64-apple-darwin)
Building stage0 test artifacts (x86_64-apple-darwin -> x86_64-apple-darwin)
    Finished release [optimized] target(s) in 0.0 secs
Copying stage0 test from stage0 (x86_64-apple-darwin -> x86_64-apple-darwin / x86_64-apple-darwin)
Building LLVM for x86_64-apple-darwin
running: "cmake" "/Users/haru/rust/src/llvm" "-DLLVM_ENABLE_ASSERTIONS=ON" "-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend;MSP430;Sparc;NVPTX;Hexagon" "-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=AVR" "-DLLVM_INCLUDE_EXAMPLES=OFF" "-DLLVM_INCLUDE_TESTS=OFF" "-DLLVM_INCLUDE_DOCS=OFF" "-DLLVM_ENABLE_ZLIB=OFF" "-DWITH_POLLY=OFF" "-DLLVM_ENABLE_TERMINFO=OFF" "-DLLVM_ENABLE_LIBEDIT=OFF" "-DLLVM_PARALLEL_COMPILE_JOBS=4" "-DLLVM_TARGET_ARCH=x86_64" "-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-apple-darwin" "-DLLVM_LINK_LLVM_DYLIB=ON" "-DCMAKE_C_COMPILER=cc" "-DCMAKE_CXX_COMPILER=c++" "-DCMAKE_C_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64 -stdlib=libc++" "-DCMAKE_CXX_FLAGS=-ffunction-sections -fdata-sections -fPIC -m64 -stdlib=libc++" "-DCMAKE_INSTALL_PREFIX=/Users/haru/rust/build/x86_64-apple-darwin/llvm" "-DCMAKE_BUILD_TYPE=Release"
CMake Deprecation Warning at CMakeLists.txt:15 (cmake_policy):
  The OLD behavior for policy CMP0051 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- Found libtool - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
CMake Warning at CMakeLists.txt:140 (message):
  Job pooling is only available with Ninja generators.


-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Sphinx disabled.
-- Go bindings enabled.
-- Found ld64 - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-apple-darwin17.5.0
-- LLVM default target triple: x86_64-apple-darwin
-- Building with -fPIC
CMake Error at CMakeLists.txt:612 (message):
  Python 2.7 or newer is required


-- Configuring incomplete, errors occurred!
See also "/Users/haru/rust/build/x86_64-apple-darwin/llvm/build/CMakeFiles/CMakeOutput.log".
See also "/Users/haru/rust/build/x86_64-apple-darwin/llvm/build/CMakeFiles/CMakeError.log".
thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /Users/haru/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.25/src/lib.rs:599:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
    finished in 0.975
failed to run: /Users/haru/rust/build/bootstrap/debug/bootstrap build
Build completed unsuccessfully in 0:00:10
make: *** [all] Error 1

Python 2.7 or newer is requiredと書いていますが、Python3だからPython2.7よりは新しいからいいじゃんと思って、原因が不明でした。

しかし、avr-rustのRUST_README.mdを見ると、python 2.7 (but not 3.x)と書いてあったので、Python3だめじゃんとなり、
ちょうどPyenvで2.7がローカルにあったので2.7でやって見るとうまくいきました。

原因は Pythonのバージョン

toolchainの登録でもエラー

toolchainを登録
$ rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage1'))

realpathコマンドがMacOSにはないのでインストール

$ brew install coreutils

これで、avr-rustのインストールはおっけー。

Lチカをしたい

多分できるんだよな

5
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1