From bda4fa4200db8756b68dc76e016e49ae92ea018f Mon Sep 17 00:00:00 2001 From: sofia Date: Mon, 31 Jul 2023 00:35:46 +0300 Subject: [PATCH] Move stuff around, add comment about compiling LLVM --- .vscode/settings.json | 5 ++ Cargo.lock | 84 +++++++++++++++++++++++++++++++ Cargo.toml | 2 + README.md | 61 ++++++++++++++++++++++ easiest.reid => reid/easiest.reid | 0 easy.reid => reid/easy.reid | 0 hard.reid => reid/hard.reid | 0 medium.reid => reid/medium.reid | 0 src/main.rs | 8 +-- 9 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 README.md rename easiest.reid => reid/easiest.reid (100%) rename easy.reid => reid/easy.reid (100%) rename hard.reid => reid/hard.reid (100%) rename medium.reid => reid/medium.reid (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..352a626 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "rust-analyzer.linkedProjects": [ + "./Cargo.toml" + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index df6e7a4..c158548 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,90 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "llvm-sys" +version = "160.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf51981ac0622b10fe4790763e3de1f3d68a0ee4222e03accaaab6731bd508d" +dependencies = [ + "cc", + "lazy_static", + "libc", + "regex", + "semver", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "regex" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + [[package]] name = "reid" version = "0.1.0" +dependencies = [ + "llvm-sys", +] + +[[package]] +name = "semver" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" diff --git a/Cargo.toml b/Cargo.toml index d0e8d97..9e665a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +llvm-sys = "160" diff --git a/README.md b/README.md new file mode 100644 index 0000000..90d6e21 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# Reid-LLVM +Attempt at re-creating Reid, this time using LLVM. + +## Various notes in order to get this working properly +This is what worked for me, might not (probably) work for you, depending on +various versions of various libraries. + +### Compiling LLVM 16.0.0 + +#### Context +Context for my computer. I am on ArchLinux, and here are some libraries and +their current versions that I have installed as of compiling, I'm not sure what +of them are relevant, if any, but saving them here still feels like a good idea +for the future: +- `cmake 3.27.0-1` +- `lib32-llvm-libs 15.0.7-1` +- `llvm 15.0.7-3` +- `llvm-libs 15.0.7-3` +- `gcc 13.1.1-2` +- `gcc-libs 13.1.1-2` +- `lib32-gcc-libs 13.1.1-2` +- `lld 15.0.7-2` +- `lldb 15.0.7-3` +- `clang 15.0.7-9` +- `make 4.4.1-2` +- `automake 1.16.5-2` + +#### Commands + +```sh +wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/llvm-16.0.0.src.tar.xz +wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/cmake-16.0.0.src.tar.xz + +tar xvf llvm-16.0.0.src.tar.xz +tar xvf cmake-16.0.0.src.tar.xz + +mv cmake-16.0.0.src cmake + +cd llvm-16.0.0.src + +cmake -B build -DCMAKE_INSTALL_PREFIX=$HOME/llvm-16 -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_INCLUDE_TESTS=OFF + +make -j8 +``` + +*Also Note:* Building LLVM with `Ninja` was not successful for me, but this +method was. Ninja may be successful with you, to try it, add `-G Ninja` to the +`cmake`-command, and instead of `make` run `ninja install`. + +### Building this crate itself + +Assuming `llvm-16.0.0.src` from the previous step was at +`/path/llvm-16.0.0.src`, building this crate can be done via the following command: + +```sh +LLVM_SYS_160_PREFIX=/path/llvm-16.0.0.src/build cargo build +``` + +## In conclusion +Good luck! It took me a good 10 hours to figure this out for myself, I sure hope +these instructions help both myself and someone else in the future! \ No newline at end of file diff --git a/easiest.reid b/reid/easiest.reid similarity index 100% rename from easiest.reid rename to reid/easiest.reid diff --git a/easy.reid b/reid/easy.reid similarity index 100% rename from easy.reid rename to reid/easy.reid diff --git a/hard.reid b/reid/hard.reid similarity index 100% rename from hard.reid rename to reid/hard.reid diff --git a/medium.reid b/reid/medium.reid similarity index 100% rename from medium.reid rename to reid/medium.reid diff --git a/src/main.rs b/src/main.rs index 8a557df..744da99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ use crate::{lexer::Token, parser::TopLevelStatement, token_stream::TokenStream}; -pub static EASIEST: &str = include_str!("../easiest.reid"); -pub static EASY: &str = include_str!("../easy.reid"); -pub static MEDIUM: &str = include_str!("../medium.reid"); -pub static HARD: &str = include_str!("../hard.reid"); +pub static EASIEST: &str = include_str!("../reid/easiest.reid"); +pub static EASY: &str = include_str!("../reid/easy.reid"); +pub static MEDIUM: &str = include_str!("../reid/medium.reid"); +pub static HARD: &str = include_str!("../reid/hard.reid"); mod lexer; mod parser;