Skip to content

Commit

Permalink
Merge pull request TheDan64#2 from rtfeldman/upgrade-inkwell-debug-info
Browse files Browse the repository at this point in the history
Upgrade inkwell so we can use debug info
  • Loading branch information
folkertdev authored Nov 17, 2020
2 parents d0a1ce5 + 0f61b2c commit 57e9f00
Show file tree
Hide file tree
Showing 62 changed files with 3,917 additions and 1,271 deletions.
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Hello there! Thank you for taking interest in Inkwell!
* I have updated documentation and doc tests to any modified functions or types as applicable
* I have added tests to cover my changes
* All new and existing tests passed
* I am basing my changes off master, instead of one of the llvm version branches
* I am basing my changes off master, instead of one of the llvm version branches (they're deprecated and no longer necessary)

### Desired

* I have ran clippy and updated portions of code pertaining to my changes
* I have ran `cargo clippy` and updated portions of code pertaining to my changes
* I will keep my code reasonably up to date via rebasing over merging whenever possible (This helps avoid unnecessary merge commits)

## Got Questions?
Expand Down
41 changes: 20 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
language: rust

sudo: required
cache:
directories:
- /home/travis/.cargo

before_cache:
- RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
- cargo install cargo-tarpaulin
- rm -rf /home/travis/.cargo/registry
include_base: &BASE
addons:
Expand All @@ -23,13 +22,11 @@ include_base: &BASE
- libssl-dev
before_install:
- export LLVM_VERSION_DASH=${LLVM_VERSION/./-}
- export LLVM_VERSION_SHORT=${LLVM_VERSION/./}
- export PATH=/usr/lib/llvm-${LLVM_VERSION}/bin/:$HOME/.local/bin:$PATH
- export LLVM_PATH=/usr/share/llvm-${LLVM_VERSION}/cmake/
- sed -i -e 's/llvm-sys = ".*"/llvm-sys = "'${LLVM_VERSION_SHORT}'"/' Cargo.toml
script:
- cargo build --no-default-features --features "target-all,llvm${LLVM_VERSION_DASH}" --color=always
- cargo test --no-default-features --features "target-all,llvm${LLVM_VERSION_DASH}" --verbose --color=always
- cargo build --features "target-all,llvm${LLVM_VERSION_DASH}" --color=always
- cargo test --features "target-all,llvm${LLVM_VERSION_DASH}" --verbose --color=always

matrix:
fast_finish: true
Expand All @@ -45,7 +42,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-3.6-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="3.7"
Expand All @@ -58,7 +55,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-3.7-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="3.8"
Expand All @@ -71,7 +68,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-3.8-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
# 3.9 seems to have a linking issue :/
# - env:
Expand All @@ -81,12 +78,13 @@ matrix:
# apt:
# sources:
# - *BASE_SOURCES
# - llvm-toolchain-trusty-3.9
# - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main'
# key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
# packages:
# - *BASE_PACKAGES
# - llvm-3.9-dev
# rust: nightly-2019-07-25
# dist: trusty
# rust: 1.39.0
# dist: xenial
- env:
- LLVM_VERSION="4.0"
<<: *BASE
Expand All @@ -98,7 +96,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-4.0-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="5.0"
Expand All @@ -111,7 +109,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-5.0-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="6.0"
Expand All @@ -124,7 +122,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-6.0-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="7.0"
Expand All @@ -137,7 +135,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-7-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="8.0"
Expand All @@ -150,7 +148,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-8-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: trusty
- env:
- LLVM_VERSION="9.0"
Expand All @@ -165,7 +163,7 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-9-dev
rust: nightly-2019-07-25
rust: 1.39.0
dist: bionic
- env:
- LLVM_VERSION="10.0"
Expand All @@ -180,7 +178,8 @@ matrix:
packages:
- *BASE_PACKAGES
- llvm-10-dev
rust: nightly-2019-07-25
- libclang-common-10-dev
rust: 1.39.0
dist: bionic
- deploy: # Documentation build; Only latest supported LLVM version for now
provider: pages
Expand All @@ -194,7 +193,7 @@ matrix:
- export PATH=/usr/lib/llvm-10/bin/:$HOME/.local/bin:$PATH
- export LLVM_PATH=/usr/share/llvm-10/cmake/
script:
- cargo doc --no-default-features --features "target-all,llvm10-0" --color=always
- cargo doc --no-default-features --features "target-all,llvm10-0,nightly" --color=always
- echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > target/doc/index.html
rust: nightly
name: "GitHub IO Documentation Deployment"
Expand Down Expand Up @@ -235,7 +234,7 @@ env:
- RUSTFLAGS="-C link-dead-code -C target-cpu=native -l ffi"

after_success: |
if [[ "$TRAVIS_RUST_VERSION" == nightly-2019-07-25 ]]; then
if [[ "$TRAVIS_RUST_VERSION" == 1.39.0 ]]; then
cargo tarpaulin --features "llvm${LLVM_VERSION_DASH}" --out Xml
bash <(curl -s https://codecov.io/bash)
fi
Expand Down
66 changes: 48 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "inkwell"
version = "0.1.0"
authors = ["Daniel Kolsoi <thadan64@gmail.com>"]
description = "Inkwell aims to help you pen your own programming languages by safely wrapping llvm-sys."
documentation = "https://thedan64.github.io/inkwell/"
repository = "https://github.com/TheDan64/inkwell"
readme = "README.md"
keywords = ["llvm", "safe", "wrapper"]
Expand All @@ -13,20 +14,36 @@ edition = "2018"
[features]
default = ["target-all", "llvm10-0"]
# Please update internal_macros::FEATURE_VERSIONS when adding a new LLVM version
llvm3-6 = []
llvm3-7 = []
llvm3-8 = []
llvm3-9 = []
llvm4-0 = []
llvm5-0 = []
llvm6-0 = []
llvm7-0 = []
llvm8-0 = []
llvm9-0 = []
llvm10-0 = []
llvm3-6 = ["llvm-sys-36"]
llvm3-7 = ["llvm-sys-37"]
llvm3-8 = ["llvm-sys-38"]
llvm3-9 = ["llvm-sys-39"]
llvm4-0 = ["llvm-sys-40"]
llvm5-0 = ["llvm-sys-50"]
llvm6-0 = ["llvm-sys-60"]
llvm7-0 = ["llvm-sys-70"]
llvm8-0 = ["llvm-sys-80"]
llvm9-0 = ["llvm-sys-90"]
llvm10-0 = ["llvm-sys-100"]
# Don't link aganist LLVM libraries. This is useful if another dependency is
# installing LLVM. See llvm-sys for more details.
no-llvm-linking = ["llvm-sys/no-llvm-linking"]
# installing LLVM. See llvm-sys for more details. We can't enable a single
# `no-llvm-linking` feature across the board of llvm versions, as it'll cause
# cargo to try and download and compile them all. See
# https://github.com/rust-lang/cargo/issues/3494
llvm3-6-no-llvm-linking = ["llvm3-6", "llvm-sys-36/no-llvm-linking"]
llvm3-7-no-llvm-linking = ["llvm3-7", "llvm-sys-37/no-llvm-linking"]
llvm3-8-no-llvm-linking = ["llvm3-8", "llvm-sys-38/no-llvm-linking"]
llvm3-9-no-llvm-linking = ["llvm3-9", "llvm-sys-39/no-llvm-linking"]
llvm4-0-no-llvm-linking = ["llvm4-0", "llvm-sys-40/no-llvm-linking"]
llvm5-0-no-llvm-linking = ["llvm5-0", "llvm-sys-50/no-llvm-linking"]
llvm6-0-no-llvm-linking = ["llvm6-0", "llvm-sys-60/no-llvm-linking"]
llvm7-0-no-llvm-linking = ["llvm7-0", "llvm-sys-70/no-llvm-linking"]
llvm8-0-no-llvm-linking = ["llvm8-0", "llvm-sys-80/no-llvm-linking"]
llvm9-0-no-llvm-linking = ["llvm9-0", "llvm-sys-90/no-llvm-linking"]
llvm10-0-no-llvm-linking = ["llvm10-0", "llvm-sys-100/no-llvm-linking"]
# Don't force linking to libffi on non-windows platforms. Without this feature
# inkwell always links to libffi on non-windows platforms.
no-libffi-linking = []
target-x86 = []
target-arm = []
target-mips = []
Expand All @@ -42,6 +59,7 @@ target-sparc = []
target-bpf = []
target-lanai = []
target-webassembly = []
target-riscv = []
target-all = [
"target-x86",
"target-arm",
Expand All @@ -57,17 +75,29 @@ target-all = [
"target-sparc",
"target-bpf",
"target-lanai",
"target-webassembly"
"target-webassembly",
"target-riscv"
]
experimental = ["static-alloc"]
nightly = ["inkwell_internals/nightly"]

[dependencies]
either = "1.5"
inkwell_internals = { path = "./internal_macros", version = "0.1.0" }
inkwell_internals = { path = "./internal_macros", version = "0.2.0" }
libc = "0.2"
llvm-sys = "100.0.1"
once_cell = "1.2"
parking_lot = "0.10"
llvm-sys-36 = { package = "llvm-sys", version = "36.3", optional = true }
llvm-sys-37 = { package = "llvm-sys", version = "37.3", optional = true }
llvm-sys-38 = { package = "llvm-sys", version = "38.3", optional = true }
llvm-sys-39 = { package = "llvm-sys", version = "39.3", optional = true }
llvm-sys-40 = { package = "llvm-sys", version = "40.4", optional = true }
llvm-sys-50 = { package = "llvm-sys", version = "50.4", optional = true }
llvm-sys-60 = { package = "llvm-sys", version = "60.6", optional = true }
llvm-sys-70 = { package = "llvm-sys", version = "70.4", optional = true }
llvm-sys-80 = { package = "llvm-sys", version = "80.3", optional = true }
llvm-sys-90 = { package = "llvm-sys", version = "90.2", optional = true }
llvm-sys-100 = { package = "llvm-sys", version = "100.2", optional = true }
once_cell = "1.4.1"
parking_lot = "0.11"
regex = "1"
static-alloc = { version = "0.2", optional = true }

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@
[![codecov](https://codecov.io/gh/TheDan64/inkwell/branch/master/graph/badge.svg)](https://codecov.io/gh/TheDan64/inkwell)
[![lines of code](https://tokei.rs/b1/github/TheDan64/inkwell)](https://github.com/Aaronepower/tokei)
[![Join the chat at https://gitter.im/inkwell-rs/Lobby](https://badges.gitter.im/inkwell-rs/Lobby.svg)](https://gitter.im/inkwell-rs/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Minimum rustc 1.36](https://img.shields.io/badge/rustc-1.36+-brightgreen.svg)
![Minimum rustc 1.39](https://img.shields.io/badge/rustc-1.39+-brightgreen.svg)

**I**t's a **N**ew **K**ind of **W**rapper for **E**xposing **LL**VM (*S*afely)

Inkwell aims to help you pen your own programming languages by safely wrapping llvm-sys. It provides a more strongly typed interface than the underlying LLVM API so that certain types of errors can be caught at compile time instead of at LLVM's runtime. This means we are trying to replicate LLVM IR's strong typing as closely as possible. The ultimate goal is to make LLVM safer from the rust end and a bit easier to learn (via documentation) and use.

## Requirements

* Rust 1.36+
* Rust 1.39+
* Rust Stable, Beta, or Nightly
* LLVM 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7.0, or 8.0
* LLVM 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, or 10.0

## Usage

You'll need to point your Cargo.toml to a branch corresponding to a supported LLVM version:
You'll need to point your Cargo.toml to an existing preview crate on crates.io or the master
branch with a corresponding LLVM feature flag:

```toml
[dependencies]
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "llvm3-7" }
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm10-0"] }
```

Supported versions:

| LLVM Version | GitHub Branch |
| LLVM Version | Cargo Feature Flag |
| :----------: | :-----------: |
| 3.6.x | llvm3-6 |
| 3.7.x | llvm3-7 |
Expand All @@ -39,6 +40,11 @@ Supported versions:
| 6.0.x | llvm6-0 |
| 7.0.x | llvm7-0 |
| 8.0.x | llvm8-0 |
| 9.0.x | llvm9-0 |
| 10.0.x | llvm10-0 |

Please be aware that we may make breaking changes on master from time to time since we are
pre-v1.0.0, in compliance with semver. Please prefer a crates.io release whenever possible!

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fn main() {
if cfg!(not(target_os = "windows")) {
if cfg!(all(not(target_os = "windows"), not(feature = "no-libffi-linking"))) {
println!("cargo:rustc-link-lib=dylib=ffi");
}
}
4 changes: 2 additions & 2 deletions examples/kaleidoscope/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use self::inkwell::context::Context;
use self::inkwell::module::Module;
use self::inkwell::passes::PassManager;
use self::inkwell::types::BasicTypeEnum;
use self::inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, PointerValue};
use self::inkwell::values::{BasicValue, BasicValueEnum, FloatValue, FunctionValue, PointerValue};
use self::inkwell::{OptimizationLevel, FloatPredicate};

use crate::Token::*;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub struct Lexer<'a> {
impl<'a> Lexer<'a> {
/// Creates a new `Lexer`, given its source `input`.
pub fn new(input: &'a str) -> Lexer<'a> {
Lexer { input: input, chars: Box::new(input.chars().peekable()), pos: 0 }
Lexer { input, chars: Box::new(input.chars().peekable()), pos: 0 }
}

/// Lexes and returns the next `Token` from the source code.
Expand Down
11 changes: 7 additions & 4 deletions internal_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "inkwell_internals"
version = "0.1.0"
version = "0.2.0"
authors = ["Daniel Kolsoi <thadan64@gmail.com>"]
description = "Internal macro crate for inkwell"
edition = "2018"
Expand All @@ -9,9 +9,12 @@ readme = "README.md"
license = "Apache-2.0"

[dependencies]
quote = "0.6"
syn = { version = "0.15", features = ["full", "fold"] }
proc-macro2 = "0.4"
quote = "1.0"
syn = { version = "1.0", features = ["full", "fold"] }
proc-macro2 = "1.0"

[lib]
proc-macro = true

[features]
nightly = []
Loading

0 comments on commit 57e9f00

Please sign in to comment.