Skip to content

Commit 57e9f00

Browse files
authored
Merge pull request #2 from rtfeldman/upgrade-inkwell-debug-info
Upgrade inkwell so we can use debug info
2 parents d0a1ce5 + 0f61b2c commit 57e9f00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3917
-1271
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Hello there! Thank you for taking interest in Inkwell!
2020
* I have updated documentation and doc tests to any modified functions or types as applicable
2121
* I have added tests to cover my changes
2222
* All new and existing tests passed
23-
* I am basing my changes off master, instead of one of the llvm version branches
23+
* I am basing my changes off master, instead of one of the llvm version branches (they're deprecated and no longer necessary)
2424

2525
### Desired
2626

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

3030
## Got Questions?

.travis.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
language: rust
2-
32
sudo: required
43
cache:
54
directories:
65
- /home/travis/.cargo
76

87
before_cache:
9-
- RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
8+
- cargo install cargo-tarpaulin
109
- rm -rf /home/travis/.cargo/registry
1110
include_base: &BASE
1211
addons:
@@ -23,13 +22,11 @@ include_base: &BASE
2322
- libssl-dev
2423
before_install:
2524
- export LLVM_VERSION_DASH=${LLVM_VERSION/./-}
26-
- export LLVM_VERSION_SHORT=${LLVM_VERSION/./}
2725
- export PATH=/usr/lib/llvm-${LLVM_VERSION}/bin/:$HOME/.local/bin:$PATH
2826
- export LLVM_PATH=/usr/share/llvm-${LLVM_VERSION}/cmake/
29-
- sed -i -e 's/llvm-sys = ".*"/llvm-sys = "'${LLVM_VERSION_SHORT}'"/' Cargo.toml
3027
script:
31-
- cargo build --no-default-features --features "target-all,llvm${LLVM_VERSION_DASH}" --color=always
32-
- cargo test --no-default-features --features "target-all,llvm${LLVM_VERSION_DASH}" --verbose --color=always
28+
- cargo build --features "target-all,llvm${LLVM_VERSION_DASH}" --color=always
29+
- cargo test --features "target-all,llvm${LLVM_VERSION_DASH}" --verbose --color=always
3330

3431
matrix:
3532
fast_finish: true
@@ -45,7 +42,7 @@ matrix:
4542
packages:
4643
- *BASE_PACKAGES
4744
- llvm-3.6-dev
48-
rust: nightly-2019-07-25
45+
rust: 1.39.0
4946
dist: trusty
5047
- env:
5148
- LLVM_VERSION="3.7"
@@ -58,7 +55,7 @@ matrix:
5855
packages:
5956
- *BASE_PACKAGES
6057
- llvm-3.7-dev
61-
rust: nightly-2019-07-25
58+
rust: 1.39.0
6259
dist: trusty
6360
- env:
6461
- LLVM_VERSION="3.8"
@@ -71,7 +68,7 @@ matrix:
7168
packages:
7269
- *BASE_PACKAGES
7370
- llvm-3.8-dev
74-
rust: nightly-2019-07-25
71+
rust: 1.39.0
7572
dist: trusty
7673
# 3.9 seems to have a linking issue :/
7774
# - env:
@@ -81,12 +78,13 @@ matrix:
8178
# apt:
8279
# sources:
8380
# - *BASE_SOURCES
84-
# - llvm-toolchain-trusty-3.9
81+
# - sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main'
82+
# key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
8583
# packages:
8684
# - *BASE_PACKAGES
8785
# - llvm-3.9-dev
88-
# rust: nightly-2019-07-25
89-
# dist: trusty
86+
# rust: 1.39.0
87+
# dist: xenial
9088
- env:
9189
- LLVM_VERSION="4.0"
9290
<<: *BASE
@@ -98,7 +96,7 @@ matrix:
9896
packages:
9997
- *BASE_PACKAGES
10098
- llvm-4.0-dev
101-
rust: nightly-2019-07-25
99+
rust: 1.39.0
102100
dist: trusty
103101
- env:
104102
- LLVM_VERSION="5.0"
@@ -111,7 +109,7 @@ matrix:
111109
packages:
112110
- *BASE_PACKAGES
113111
- llvm-5.0-dev
114-
rust: nightly-2019-07-25
112+
rust: 1.39.0
115113
dist: trusty
116114
- env:
117115
- LLVM_VERSION="6.0"
@@ -124,7 +122,7 @@ matrix:
124122
packages:
125123
- *BASE_PACKAGES
126124
- llvm-6.0-dev
127-
rust: nightly-2019-07-25
125+
rust: 1.39.0
128126
dist: trusty
129127
- env:
130128
- LLVM_VERSION="7.0"
@@ -137,7 +135,7 @@ matrix:
137135
packages:
138136
- *BASE_PACKAGES
139137
- llvm-7-dev
140-
rust: nightly-2019-07-25
138+
rust: 1.39.0
141139
dist: trusty
142140
- env:
143141
- LLVM_VERSION="8.0"
@@ -150,7 +148,7 @@ matrix:
150148
packages:
151149
- *BASE_PACKAGES
152150
- llvm-8-dev
153-
rust: nightly-2019-07-25
151+
rust: 1.39.0
154152
dist: trusty
155153
- env:
156154
- LLVM_VERSION="9.0"
@@ -165,7 +163,7 @@ matrix:
165163
packages:
166164
- *BASE_PACKAGES
167165
- llvm-9-dev
168-
rust: nightly-2019-07-25
166+
rust: 1.39.0
169167
dist: bionic
170168
- env:
171169
- LLVM_VERSION="10.0"
@@ -180,7 +178,8 @@ matrix:
180178
packages:
181179
- *BASE_PACKAGES
182180
- llvm-10-dev
183-
rust: nightly-2019-07-25
181+
- libclang-common-10-dev
182+
rust: 1.39.0
184183
dist: bionic
185184
- deploy: # Documentation build; Only latest supported LLVM version for now
186185
provider: pages
@@ -194,7 +193,7 @@ matrix:
194193
- export PATH=/usr/lib/llvm-10/bin/:$HOME/.local/bin:$PATH
195194
- export LLVM_PATH=/usr/share/llvm-10/cmake/
196195
script:
197-
- cargo doc --no-default-features --features "target-all,llvm10-0" --color=always
196+
- cargo doc --no-default-features --features "target-all,llvm10-0,nightly" --color=always
198197
- echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > target/doc/index.html
199198
rust: nightly
200199
name: "GitHub IO Documentation Deployment"
@@ -235,7 +234,7 @@ env:
235234
- RUSTFLAGS="-C link-dead-code -C target-cpu=native -l ffi"
236235

237236
after_success: |
238-
if [[ "$TRAVIS_RUST_VERSION" == nightly-2019-07-25 ]]; then
237+
if [[ "$TRAVIS_RUST_VERSION" == 1.39.0 ]]; then
239238
cargo tarpaulin --features "llvm${LLVM_VERSION_DASH}" --out Xml
240239
bash <(curl -s https://codecov.io/bash)
241240
fi

Cargo.toml

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "inkwell"
33
version = "0.1.0"
44
authors = ["Daniel Kolsoi <[email protected]>"]
55
description = "Inkwell aims to help you pen your own programming languages by safely wrapping llvm-sys."
6+
documentation = "https://thedan64.github.io/inkwell/"
67
repository = "https://github.com/TheDan64/inkwell"
78
readme = "README.md"
89
keywords = ["llvm", "safe", "wrapper"]
@@ -13,20 +14,36 @@ edition = "2018"
1314
[features]
1415
default = ["target-all", "llvm10-0"]
1516
# Please update internal_macros::FEATURE_VERSIONS when adding a new LLVM version
16-
llvm3-6 = []
17-
llvm3-7 = []
18-
llvm3-8 = []
19-
llvm3-9 = []
20-
llvm4-0 = []
21-
llvm5-0 = []
22-
llvm6-0 = []
23-
llvm7-0 = []
24-
llvm8-0 = []
25-
llvm9-0 = []
26-
llvm10-0 = []
17+
llvm3-6 = ["llvm-sys-36"]
18+
llvm3-7 = ["llvm-sys-37"]
19+
llvm3-8 = ["llvm-sys-38"]
20+
llvm3-9 = ["llvm-sys-39"]
21+
llvm4-0 = ["llvm-sys-40"]
22+
llvm5-0 = ["llvm-sys-50"]
23+
llvm6-0 = ["llvm-sys-60"]
24+
llvm7-0 = ["llvm-sys-70"]
25+
llvm8-0 = ["llvm-sys-80"]
26+
llvm9-0 = ["llvm-sys-90"]
27+
llvm10-0 = ["llvm-sys-100"]
2728
# Don't link aganist LLVM libraries. This is useful if another dependency is
28-
# installing LLVM. See llvm-sys for more details.
29-
no-llvm-linking = ["llvm-sys/no-llvm-linking"]
29+
# installing LLVM. See llvm-sys for more details. We can't enable a single
30+
# `no-llvm-linking` feature across the board of llvm versions, as it'll cause
31+
# cargo to try and download and compile them all. See
32+
# https://github.com/rust-lang/cargo/issues/3494
33+
llvm3-6-no-llvm-linking = ["llvm3-6", "llvm-sys-36/no-llvm-linking"]
34+
llvm3-7-no-llvm-linking = ["llvm3-7", "llvm-sys-37/no-llvm-linking"]
35+
llvm3-8-no-llvm-linking = ["llvm3-8", "llvm-sys-38/no-llvm-linking"]
36+
llvm3-9-no-llvm-linking = ["llvm3-9", "llvm-sys-39/no-llvm-linking"]
37+
llvm4-0-no-llvm-linking = ["llvm4-0", "llvm-sys-40/no-llvm-linking"]
38+
llvm5-0-no-llvm-linking = ["llvm5-0", "llvm-sys-50/no-llvm-linking"]
39+
llvm6-0-no-llvm-linking = ["llvm6-0", "llvm-sys-60/no-llvm-linking"]
40+
llvm7-0-no-llvm-linking = ["llvm7-0", "llvm-sys-70/no-llvm-linking"]
41+
llvm8-0-no-llvm-linking = ["llvm8-0", "llvm-sys-80/no-llvm-linking"]
42+
llvm9-0-no-llvm-linking = ["llvm9-0", "llvm-sys-90/no-llvm-linking"]
43+
llvm10-0-no-llvm-linking = ["llvm10-0", "llvm-sys-100/no-llvm-linking"]
44+
# Don't force linking to libffi on non-windows platforms. Without this feature
45+
# inkwell always links to libffi on non-windows platforms.
46+
no-libffi-linking = []
3047
target-x86 = []
3148
target-arm = []
3249
target-mips = []
@@ -42,6 +59,7 @@ target-sparc = []
4259
target-bpf = []
4360
target-lanai = []
4461
target-webassembly = []
62+
target-riscv = []
4563
target-all = [
4664
"target-x86",
4765
"target-arm",
@@ -57,17 +75,29 @@ target-all = [
5775
"target-sparc",
5876
"target-bpf",
5977
"target-lanai",
60-
"target-webassembly"
78+
"target-webassembly",
79+
"target-riscv"
6180
]
6281
experimental = ["static-alloc"]
82+
nightly = ["inkwell_internals/nightly"]
6383

6484
[dependencies]
6585
either = "1.5"
66-
inkwell_internals = { path = "./internal_macros", version = "0.1.0" }
86+
inkwell_internals = { path = "./internal_macros", version = "0.2.0" }
6787
libc = "0.2"
68-
llvm-sys = "100.0.1"
69-
once_cell = "1.2"
70-
parking_lot = "0.10"
88+
llvm-sys-36 = { package = "llvm-sys", version = "36.3", optional = true }
89+
llvm-sys-37 = { package = "llvm-sys", version = "37.3", optional = true }
90+
llvm-sys-38 = { package = "llvm-sys", version = "38.3", optional = true }
91+
llvm-sys-39 = { package = "llvm-sys", version = "39.3", optional = true }
92+
llvm-sys-40 = { package = "llvm-sys", version = "40.4", optional = true }
93+
llvm-sys-50 = { package = "llvm-sys", version = "50.4", optional = true }
94+
llvm-sys-60 = { package = "llvm-sys", version = "60.6", optional = true }
95+
llvm-sys-70 = { package = "llvm-sys", version = "70.4", optional = true }
96+
llvm-sys-80 = { package = "llvm-sys", version = "80.3", optional = true }
97+
llvm-sys-90 = { package = "llvm-sys", version = "90.2", optional = true }
98+
llvm-sys-100 = { package = "llvm-sys", version = "100.2", optional = true }
99+
once_cell = "1.4.1"
100+
parking_lot = "0.11"
71101
regex = "1"
72102
static-alloc = { version = "0.2", optional = true }
73103

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,31 @@
55
[![codecov](https://codecov.io/gh/TheDan64/inkwell/branch/master/graph/badge.svg)](https://codecov.io/gh/TheDan64/inkwell)
66
[![lines of code](https://tokei.rs/b1/github/TheDan64/inkwell)](https://github.com/Aaronepower/tokei)
77
[![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)
8-
![Minimum rustc 1.36](https://img.shields.io/badge/rustc-1.36+-brightgreen.svg)
8+
![Minimum rustc 1.39](https://img.shields.io/badge/rustc-1.39+-brightgreen.svg)
99

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

1212
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.
1313

1414
## Requirements
1515

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

2020
## Usage
2121

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

2425
```toml
2526
[dependencies]
26-
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "llvm3-7" }
27+
inkwell = { git = "https://github.com/TheDan64/inkwell", branch = "master", features = ["llvm10-0"] }
2728
```
2829

2930
Supported versions:
3031

31-
| LLVM Version | GitHub Branch |
32+
| LLVM Version | Cargo Feature Flag |
3233
| :----------: | :-----------: |
3334
| 3.6.x | llvm3-6 |
3435
| 3.7.x | llvm3-7 |
@@ -39,6 +40,11 @@ Supported versions:
3940
| 6.0.x | llvm6-0 |
4041
| 7.0.x | llvm7-0 |
4142
| 8.0.x | llvm8-0 |
43+
| 9.0.x | llvm9-0 |
44+
| 10.0.x | llvm10-0 |
45+
46+
Please be aware that we may make breaking changes on master from time to time since we are
47+
pre-v1.0.0, in compliance with semver. Please prefer a crates.io release whenever possible!
4248

4349
## Documentation
4450

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fn main() {
2-
if cfg!(not(target_os = "windows")) {
2+
if cfg!(all(not(target_os = "windows"), not(feature = "no-libffi-linking"))) {
33
println!("cargo:rustc-link-lib=dylib=ffi");
44
}
55
}

examples/kaleidoscope/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use self::inkwell::context::Context;
2626
use self::inkwell::module::Module;
2727
use self::inkwell::passes::PassManager;
2828
use self::inkwell::types::BasicTypeEnum;
29-
use self::inkwell::values::{BasicValueEnum, FloatValue, FunctionValue, PointerValue};
29+
use self::inkwell::values::{BasicValue, BasicValueEnum, FloatValue, FunctionValue, PointerValue};
3030
use self::inkwell::{OptimizationLevel, FloatPredicate};
3131

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

9898
/// Lexes and returns the next `Token` from the source code.

internal_macros/Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "inkwell_internals"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = ["Daniel Kolsoi <[email protected]>"]
55
description = "Internal macro crate for inkwell"
66
edition = "2018"
@@ -9,9 +9,12 @@ readme = "README.md"
99
license = "Apache-2.0"
1010

1111
[dependencies]
12-
quote = "0.6"
13-
syn = { version = "0.15", features = ["full", "fold"] }
14-
proc-macro2 = "0.4"
12+
quote = "1.0"
13+
syn = { version = "1.0", features = ["full", "fold"] }
14+
proc-macro2 = "1.0"
1515

1616
[lib]
1717
proc-macro = true
18+
19+
[features]
20+
nightly = []

0 commit comments

Comments
 (0)