Skip to content

Commit 6d288ed

Browse files
committed
Complete initial LLVM 3.8 support
1 parent 8be883e commit 6d288ed

File tree

8 files changed

+44
-35
lines changed

8 files changed

+44
-35
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ matrix:
7575
on:
7676
branch: master
7777
script:
78-
- cargo doc --no-default-features --features llvm3-7
78+
- cargo doc --no-default-features --features llvm3-8
7979
- echo '<meta http-equiv="refresh" content="1; url=inkwell/index.html">' > target/doc/index.html
8080
after_success:
8181
rust: nightly
@@ -84,11 +84,13 @@ matrix:
8484
sources:
8585
- *BASE_SOURCES
8686
# - llvm-toolchain-precise-3.6
87-
- llvm-toolchain-precise-3.7
87+
# - llvm-toolchain-precise-3.7
88+
- llvm-toolchain-precise-3.8
8889
packages:
8990
- *BASE_PACKAGES
9091
# - llvm-3.6-dev
91-
- llvm-3.7-dev
92+
# - llvm-3.7-dev
93+
- llvm-3.8-dev
9294

9395
env:
9496
global:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l
1414

1515
* Any Rust version released in the last year or so
1616
* Rust Stable, Beta, or Nightly
17-
* LLVM 3.6 or 3.7 (3.8+ support is planned: [#1](https://github.com/TheDan64/inkwell/issues/1))
17+
* LLVM 3.6, 3.7, or 3.8 (3.9+ support is planned: [#1](https://github.com/TheDan64/inkwell/issues/1))
1818

1919
## Usage
2020

@@ -31,6 +31,7 @@ Supported versions:
3131
| :-----------: | :----------: |
3232
| llvm3-6 | llvm3-6 |
3333
| llvm3-7 | llvm3-7 |
34+
| llvm3-8 | llvm3-8 |
3435

3536
In the root of your source code you will have to add an extern crate to begin using Inkwell:
3637

build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7")))]
3+
println!("cargo:rustc-link-lib=dylib=ffi");
4+
}

src/values/metadata_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 12;
1515
#[cfg(feature = "llvm3-7")]
1616
pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 14;
1717
#[cfg(feature = "llvm3-8")]
18-
pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 20; // FIXME
18+
pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 18;
1919

2020
#[derive(PartialEq, Eq, Clone, Copy)]
2121
pub struct MetadataValue {

tests/test_builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,11 @@ fn test_no_builder_double_free2() {
440440
builder.position_at_end(&entry);
441441
builder.build_unreachable();
442442

443-
#[cfg(any(feature = "llvm3-6", feature = "llvm3-7"))]
443+
#[cfg(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8"))]
444444
assert_eq!(module.print_to_string(), &*CString::new("; ModuleID = \'my_mod\'\n\ndefine void @my_fn() {\nentry:\n unreachable\n}\n").unwrap());
445-
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7")))]
446-
assert_eq!(module.print_to_string(), &*CString::new("; ModuleID = \'my_mod\'\nsource_filename = \"my_mod\"\n\ndefine void @my_fn() {\nentry:\n unreachable\n}\n").unwrap());
445+
// llvm 6.0?:
446+
// assert_eq!(module.print_to_string(), &*CString::new("; ModuleID = \'my_mod\'\nsource_filename = \"my_mod\"\n\ndefine void @my_fn() {\nentry:\n unreachable\n}\n").unwrap());
447447

448448
// 2nd Context drops fine
449-
// Builds drops fine
449+
// Builder drops fine
450450
}

tests/test_execution_engine.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ use self::inkwell::OptimizationLevel;
44
use self::inkwell::context::Context;
55
use self::inkwell::execution_engine::FunctionLookupError;
66
use self::inkwell::targets::{InitializationConfig, Target};
7-
use self::inkwell::enable_llvm_pretty_stack_trace;
87

98
#[test]
109
fn test_get_function_address() {
11-
enable_llvm_pretty_stack_trace();
12-
1310
let context = Context::create();
1411
// let module = context.create_module("errors_abound");
1512
let builder = context.create_builder();

tests/test_passes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ fn test_pass_manager_builder() {
112112

113113
pass_manager_builder.populate_module_pass_manager(&module_pass_manager);
114114

115-
// REVIEW: Seems to return true in 3.7, even though no changes were made.
116-
// In 3.6 it returns false. LLVM bug?
117-
#[cfg(feature = "llvm3-6")]
115+
// TODOC: Seems to return true in 3.7, even though no changes were made.
116+
// In 3.6 and 3.8 it returns false. Seems like an LLVM bug
117+
#[cfg(not(feature = "llvm3-7"))]
118118
assert!(!module_pass_manager.run_on_module(&module));
119-
#[cfg(not(feature = "llvm3-6"))]
119+
#[cfg(feature = "llvm3-7")]
120120
assert!(module_pass_manager.run_on_module(&module));
121121

122122
// TODO: Populate LTO pass manager?

tests/test_values.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -400,25 +400,28 @@ fn test_metadata() {
400400
assert_eq!(MetadataValue::get_kind_id("dereferenceable_or_null"), 13);
401401
}
402402

403+
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7")))]
404+
{
405+
assert_eq!(context.get_kind_id("make.implicit"), 14);
406+
assert_eq!(MetadataValue::get_kind_id("make.implicit"), 14);
407+
assert_eq!(context.get_kind_id("unpredictable"), 15);
408+
assert_eq!(MetadataValue::get_kind_id("unpredictable"), 15);
409+
assert_eq!(context.get_kind_id("invariant.group"), 16);
410+
assert_eq!(MetadataValue::get_kind_id("invariant.group"), 16);
411+
assert_eq!(context.get_kind_id("align"), 17);
412+
assert_eq!(MetadataValue::get_kind_id("align"), 17);
413+
}
403414
// TODO: Predefined, but only newer versions we don't support yet
404-
// assert_eq!(context.get_kind_id("make.implicit"), 14);
405-
// assert_eq!(MetadataValue::get_kind_id("make.implicit"), 14);
406-
// assert_eq!(context.get_kind_id("unpredictable"), 15);
407-
// assert_eq!(MetadataValue::get_kind_id("unpredictable"), 15);
408-
// assert_eq!(context.get_kind_id("invariant.group"), 16);
409-
// assert_eq!(MetadataValue::get_kind_id("invariant.group"), 16);
410-
// assert_eq!(context.get_kind_id("align"), 16);
411-
// assert_eq!(MetadataValue::get_kind_id("align"), 16);
412-
// assert_eq!(context.get_kind_id("llvm.loop"), 17);
413-
// assert_eq!(MetadataValue::get_kind_id("llvm.loop"), 17);
414-
// assert_eq!(context.get_kind_id("type"), 18);
415-
// assert_eq!(MetadataValue::get_kind_id("type"), 18);
416-
// assert_eq!(context.get_kind_id("section_prefix"), 19);
417-
// assert_eq!(MetadataValue::get_kind_id("section_prefix"), 19);
418-
// assert_eq!(context.get_kind_id("absolute_symbol"), 20);
419-
// assert_eq!(MetadataValue::get_kind_id("absolute_symbol"), 20);
420-
// assert_eq!(context.get_kind_id("associated"), 21);
421-
// assert_eq!(MetadataValue::get_kind_id("associated"), 21);
415+
// assert_eq!(context.get_kind_id("llvm.loop"), 18);
416+
// assert_eq!(MetadataValue::get_kind_id("llvm.loop"), 18);
417+
// assert_eq!(context.get_kind_id("type"), 19);
418+
// assert_eq!(MetadataValue::get_kind_id("type"), 19);
419+
// assert_eq!(context.get_kind_id("section_prefix"), 20);
420+
// assert_eq!(MetadataValue::get_kind_id("section_prefix"), 20);
421+
// assert_eq!(context.get_kind_id("absolute_symbol"), 21);
422+
// assert_eq!(MetadataValue::get_kind_id("absolute_symbol"), 21);
423+
// assert_eq!(context.get_kind_id("associated"), 22);
424+
// assert_eq!(MetadataValue::get_kind_id("associated"), 22);
422425

423426
assert_eq!(module.get_global_metadata_size("my_string_md"), 0);
424427
assert_eq!(module.get_global_metadata("my_string_md").len(), 0);
@@ -686,7 +689,9 @@ fn test_function_value_no_params() {
686689
assert!(fn_value.get_first_param().is_none());
687690
assert!(fn_value.get_last_param().is_none());
688691
assert!(fn_value.get_nth_param(0).is_none());
689-
#[cfg(not(feature = "llvm3-6"))]
692+
// REVIEW: get_personality_function causes segfault in 3.8 Probably LLVM bug
693+
// if so, should document
694+
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-8")))]
690695
assert!(fn_value.get_personality_function().is_none());
691696
assert!(!fn_value.is_null());
692697
assert!(!fn_value.is_undef());

0 commit comments

Comments
 (0)