Wilfred / bfc

An industrial-grade brainfuck compiler
https://bfc.wilfred.me.uk
GNU General Public License v2.0
508 stars 30 forks source link

cargo build --release returns errors E0503 and E0592 (cannot use `state` because it was mutably borrowed) #34

Closed Ning1253 closed 4 years ago

Ning1253 commented 4 years ago

Hi, this project looks amazing!! I wanted to see whether I could make some cool and pretty fast bf programs with it, but I'm not really familiar with rust or LLVM, so I just followed the instructions you gave in building the files. However after running cargo build --release, I received the errors in the title - I also tried running cmd with administrator, but since I don't really know anything about the languages that was pretty much all I could do. Would you have any idea what would cause this?

PS - If you actually reply, that'll be so awesome, since it will mean you will still be looking at this github page after 4 years!! Dedication and a half.

Wilfred commented 4 years ago

I can't reproduce this with 1.46.0 or nightly "rustc 1.48.0-nightly (623fb90b5 2020-09-26)". What version did you build with?

Ning1253 commented 4 years ago

Ok so you talking about version made me think about trying to update cargo, since I had briefly seen the command somewhere whilst trying to search up how to fix the error. I did so, and to my surprise, the error went away! However now it shows another error, which this time I could not fix: "error: failed to run custom build command for llvm-sys v100.2.0", llvm-sys v100.2.0 being the new version after it was updated.

PS - The versions I am using: Rust 1.46.0, cargo is up to date, LLVM 8.0.0 . PPS - Damn it's really cool that you actually replied!! Solid commitment to a project! PPPS - I attatched the output from the command, since I can't make heads or tails of it - the llvm-config file which it says is missing IS actually missing, but I couldn't find online anywhere to download this file.

log.txt

Wilfred commented 4 years ago

llvm-config is a command that's part of LLVM itself. llvm-sys is just a wrapper around the LLVM version installed on your system.

Do you have LLVM installed? What is the contents of C:\Program Files\LLVM\bin\?

Ning1253 commented 4 years ago

Well it has a bunch of files, starting with "api-ms-win-core..." and going to the .exe s. However there is no llvm-config in that folder, nor in any other folder in that directory -

it has a bunch of others, but not that one.

folder

Lxixnxuxs commented 4 years ago

Hi @Ning1253, regarding your question, I assume that you are using Windows and tried to install LLVM-8 via the Installer Executable. In Fact, this is the problem, because it wont install llvm-config.exe (as explained here: https://stackoverflow.com/questions/17096804/where-is-llvm-config-in-windows). You now have two options:

Ning1253 commented 4 years ago

I might try the Ubuntu subsystem then, thank you very much for looking into this!! I’ll update if I can get it to work 

Ning1253 commented 4 years ago

Update: I've installed the ubuntu subsystem, and installed rustup and llvm, as well as llvmenv, but now I get an error which I seem to remember having gotten before, saying that "LLVM_SYS_100_PREFIX" does not point to a valid installation, or something along those lines. I seem to remember fixing this, but I can't remember how...

Lxixnxuxs commented 4 years ago

This Error-Message basically says that either your LLVM installation failed or that you haven't set up your enviroment variables properly. This is a detailed instruction on how to compile the bfc on a Linux Subsystem:

  1. Install Ubuntu 18.04 LTS Subsystem from Windows Store
  2. Download the LLVM Prebuilt binary for Ubuntu 18.04 (https://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz) and copy this file to your Ubuntu Filesystem
  3. Extract it(with tar -xf <pathtotarget>.tar.xz) and add thebinfolder, inside the extracted directory, permanently to your Path enviroment variable (https://opensource.com/article/17/6/set-path-linux)
  4. Install Rust on your Linux Subsystem with curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  5. Restart the Ubuntu-Shell and check if you've done all right by executing cargo and llvm-config. Both commands should produce an output different to command not found
  6. Run sudo apt-get update && sudo apt install build-essential zlib1g-dev libtinfo-dev libxml2-dev
  7. Clone this repo and compile it as described in Readme (cargo build --release)
Ning1253 commented 4 years ago

omg thank you so much for this!!! I should be free to compile it this afternoon, thank you so much! This is so much clearer than anything else I could find online, thanks a lot!!

Ning1253 commented 4 years ago

Update: sorry to cause you so much trouble, but now I am getting the error error: could not compile 'llvm-sys'. . The problem is that once again, I can't find any solution to this online - it seems to be a problem with the path again since error: No suitable version of LLVM was found system-wide or pointed to by LLVM_SYS_100_PREFIX. is once again showing. However, just in case I even locally set path as well as set it permamently - llvm-config works when I type it in, giving me the command options, so that works. Cargo also works, and llvm-config --version return LLVM 8.0.0 .

So once again I'm not really sure what to do from here.

Ning1253 commented 4 years ago

Nevermind, I got it to work, time to have fun!! Thank you so much for the help, it's really nice of you to put in so much effort for this!

Lxixnxuxs commented 4 years ago

You're welcome. @Wilfred I think this issue can be closed now.

Wilfred commented 4 years ago

@Lxixnxuxs I've pushed 93f58fe which adds support for LLVM 10 :)