immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.95k stars 234 forks source link

Cannot build on nix #1045

Closed HKalbasi closed 9 months ago

HKalbasi commented 10 months ago

I tried nix-shell and got this error for cargo build:

user@nixos ~/o/c2rust (master)> cargo build
   Compiling c2rust-ast-exporter v0.18.0 (/home/user/oss/c2rust/c2rust-ast-exporter)
error: failed to run custom build command for `c2rust-ast-exporter v0.18.0 (/home/user/oss/c2rust/c2rust-ast-exporter)`

Caused by:
  process didn't exit successfully: `/home/user/oss/c2rust/target/debug/build/c2rust-ast-exporter-62cbe6e61d2826ca/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
  CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
  CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
  HOST_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = Some("/nix/store/gwf21xyl0x0bhgapi66avzf6qmddr44s-patchelf-0.15.0:/nix/store/a4iwnvqy7y3lmgg56wh96wsdqv6zq8rk-clang-wrapper-11.1.0:/nix/store/88bh6zy2sbkj83jcpvmzgqf74213wk2f-binutils-wrapper-2.40:/nix/store/ssaph43cwi2a1vjap3qviiw8mkcpxi51-compiler-rt-libc-11.1.0-dev:/nix/store/27n0d9n2gh3giwrf40ahgz7kzrqd3x6a-compiler-rt-libc-11.1.0:/nix/store/jzfa947q6wvkwmy7f3rnll66gzwv9m9s-cmake-3.25.3:/nix/store/b1sa6d6w5yywj5vww4q7y2z98y0lla46-llvm-11.1.0-dev:/nix/store/pzis69n8rva6rxkkp5vp4c4mklxgp5yf-ncurses-6.4-dev:/nix/store/wnblw3rp0qr0z6wyzhaahch3mkk42gmi-ncurses-6.4:/nix/store/j0zwp9zygvadcly9dxpm0f4ga7h0n8c9-zlib-1.2.13-dev:/nix/store/8mw6ssjspf8k1ija88cfldmxlbarl1bb-zlib-1.2.13:/nix/store/n91xw684k6kc7q7wq6ap9mb6sjgbvbps-llvm-11.1.0-lib:/nix/store/bs0zvg5zvjnf4wpidmxjpyavi6pzjxfb-llvm-11.1.0:/nix/store/h55j9wkhjnqizhxa5g1jacg855lm3fj2-openssl-3.0.12-dev:/nix/store/06smgwbr9747nxvars7i2fa1p0ckyrhc-openssl-3.0.12-bin:/nix/store/1hp1qrqzw51b2qhbi6py6i9qz2fhql3r-openssl-3.0.12:/nix/store/7l5gbdz3rcab57r24arg61i4vavpf2cz-pkg-config-wrapper-0.29.2:/nix/store/n5fr2ppq4i3hdjbbf4636gk54s07022v-python3-3.10.13:/nix/store/yf98i7q4jia1x9xjz9q31wgqy3qj3qcm-rustup-1.26.0")
  CMAKE_x86_64-unknown-linux-gnu = None
  CMAKE_x86_64_unknown_linux_gnu = None
  HOST_CMAKE = None
  CMAKE = None
  running: "cmake" "/home/user/oss/c2rust/c2rust-ast-exporter/src" "-DLLVM_DIR=/nix/store/n91xw684k6kc7q7wq6ap9mb6sjgbvbps-llvm-11.1.0-lib/lib/cmake/llvm" "-DClang_DIR=/nix/store/n91xw684k6kc7q7wq6ap9mb6sjgbvbps-llvm-11.1.0-lib/lib/cmake/clang" "-DCMAKE_INSTALL_PREFIX=/home/user/oss/c2rust/target/debug/build/c2rust-ast-exporter-8e5ec6fbe6f94814/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu" "-DCMAKE_C_COMPILER=/nix/store/a4iwnvqy7y3lmgg56wh96wsdqv6zq8rk-clang-wrapper-11.1.0/bin/clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu" "-DCMAKE_CXX_COMPILER=/nix/store/a4iwnvqy7y3lmgg56wh96wsdqv6zq8rk-clang-wrapper-11.1.0/bin/clang++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-linux-gnu" "-DCMAKE_ASM_COMPILER=/nix/store/a4iwnvqy7y3lmgg56wh96wsdqv6zq8rk-clang-wrapper-11.1.0/bin/clang" "-DCMAKE_BUILD_TYPE=Debug"
  -- Could NOT find Clang (missing: Clang_DIR)
  -- Configuring done
  -- Generating done
  -- Build files have been written to: /home/user/oss/c2rust/target/debug/build/c2rust-ast-exporter-8e5ec6fbe6f94814/out/build
  running: "cmake" "--build" "." "--target" "clangAstExporter" "--config" "Debug"
  [  8%] Performing update step for 'tinycbor_build'
  [ 16%] Performing patch step for 'tinycbor_build'
  patching file Makefile
  Reversed (or previously applied) patch detected!  Skipping patch.
  1 out of 1 hunk ignored -- saving rejects to file Makefile.rej
  patching file Makefile.configure
  Reversed (or previously applied) patch detected!  Skipping patch.
  1 out of 1 hunk ignored -- saving rejects to file Makefile.configure.rej
  [ 25%] Performing configure step for 'tinycbor_build'
  [ 33%] Performing build step for 'tinycbor_build'
  [ 41%] Performing install step for 'tinycbor_build'
  [ 50%] Completed 'tinycbor_build'
  [ 66%] Built target tinycbor_build
  [ 75%] Building CXX object CMakeFiles/clangAstExporter.dir/AstExporter.cpp.o

  --- stderr
  make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  make[4]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  /home/user/oss/c2rust/c2rust-ast-exporter/src/AstExporter.cpp:15:10: fatal error: 'clang/Frontend/FrontendActions.h' file not found
  #include "clang/Frontend/FrontendActions.h"
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  make[3]: *** [CMakeFiles/clangAstExporter.dir/build.make:76: CMakeFiles/clangAstExporter.dir/AstExporter.cpp.o] Error 1
  make[2]: *** [CMakeFiles/Makefile2:220: CMakeFiles/clangAstExporter.dir/all] Error 2
  make[1]: *** [CMakeFiles/Makefile2:227: CMakeFiles/clangAstExporter.dir/rule] Error 2
  make: *** [Makefile:189: clangAstExporter] Error 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2

  build script failed, must exit now', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.50/src/lib.rs:1098:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I tried using 23.05 and unstable channels. I guess the shell.nix file is outdated or something.

kkysen commented 10 months ago

Hi! We unfortunately don't have the time or enough people who know nix well enough to maintain any of the nix files for c2rust, so what exists is community maintained and may be out of date or broken in certain cases. We welcome any PR(s) fixing any of these issues, though!