Skip to content

Commit 807de3e

Browse files
authored
Merge branch 'master' into chore/refactor-build-rs
2 parents 824969b + 0c81fc7 commit 807de3e

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

.clangd

-2
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/target
44
compile_commands.json
55
doc
6+
.clangd

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ Read the documentation at https://danacus.gitlab.io/tblgen-rs/tblgen/.
1313

1414
## Supported LLVM Versions
1515

16-
An installation of LLVM is required to use this crate. Both LLVM 16 and 17 are supported and can be selected using feature flags.
16+
An installation of LLVM is required to use this crate. Both LLVM 16, 17 and 18 are supported and can be selected using feature flags.
1717

1818
The `TABLEGEN_<version>_PREFIX` environment variable can be used to specify a custom directory of the LLVM installation.

build.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ fn run() -> Result<(), Box<dyn Error>> {
6464
println!("cargo:rustc-link-lib={}", name);
6565
}
6666

67-
env::set_var("CXXFLAGS", llvm_config("--cxxflags")?);
68-
env::set_var("CFLAGS", llvm_config("--cflags")?);
6967
println!("cargo:rustc-link-search={}", &env::var("OUT_DIR")?);
7068

7169
cc::Build::new()
@@ -78,8 +76,9 @@ fn run() -> Result<(), Box<dyn Error>> {
7876
.cpp(true)
7977
.include("cc/include")
8078
.include(llvm_config("--includedir")?)
81-
// .flag("-MJcompile_commands.o.json")
82-
.opt_level(3)
79+
.flag(&llvm_config("--cxxflags")?)
80+
.flag("-Wno-unused-parameter")
81+
.std("c++17")
8382
.compile("CTableGen");
8483

8584
println!("cargo:rustc-link-lib=static=CTableGen");

cc/lib/RecordKeeper.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ void tableGenRecordKeeperFree(TableGenRecordKeeperRef rk_ref) {
1919

2020
TableGenRecordKeeperIteratorRef
2121
tableGenRecordKeeperGetFirstClass(TableGenRecordKeeperRef rk_ref) {
22-
auto *it = new RecordMap::const_iterator(unwrap(rk_ref)->getClasses().begin());
22+
auto *it =
23+
new RecordMap::const_iterator(unwrap(rk_ref)->getClasses().begin());
2324
if (*it == unwrap(rk_ref)->getClasses().end()) {
2425
return nullptr;
2526
}
@@ -95,9 +96,9 @@ TableGenRecordRef tableGenRecordKeeperGetDef(TableGenRecordKeeperRef rk_ref,
9596
TableGenRecordVectorRef
9697
tableGenRecordKeeperGetAllDerivedDefinitions(TableGenRecordKeeperRef rk_ref,
9798
TableGenStringRef className) {
98-
return wrap(new ctablegen::RecordVector(
99-
std::move(unwrap(rk_ref)->getAllDerivedDefinitions(
100-
StringRef(className.data, className.len)))));
99+
return wrap(
100+
new ctablegen::RecordVector(unwrap(rk_ref)->getAllDerivedDefinitions(
101+
StringRef(className.data, className.len))));
101102
}
102103

103104
TableGenRecordRef tableGenRecordVectorGet(TableGenRecordVectorRef vec_ref,

src/string_ref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'a> From<&'a str> for StringRef<'a> {
3737
fn from(value: &'a str) -> Self {
3838
unsafe {
3939
StringRef::from_raw(TableGenStringRef {
40-
data: value.as_ptr() as *const i8,
40+
data: value.as_ptr() as *const _,
4141
len: value.len(),
4242
})
4343
}
@@ -54,6 +54,6 @@ impl<'a> TryFrom<StringRef<'a>> for &'a str {
5454

5555
impl<'a> From<StringRef<'a>> for &'a [u8] {
5656
fn from(value: StringRef<'a>) -> Self {
57-
unsafe { std::slice::from_raw_parts(value.raw.data as *const u8, value.raw.len) }
57+
unsafe { std::slice::from_raw_parts(value.raw.data as *const _, value.raw.len) }
5858
}
5959
}

tools/setup.sh

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ brew install llvm@$llvm_version
99

1010
echo TABLEGEN_180_PREFIX=$(brew --prefix llvm@$llvm_version) >>$GITHUB_ENV
1111
echo PATH=$TABLEGEN_180_PREFIX/bin:$PATH >>$GITHUB_ENV
12+
echo LIBRARY_PATH=$(brew --prefix)/lib:$LIBRARY_PATH >>$GITHUB_ENV
13+
echo LD_LIBRARY_PATH=$(brew --prefix)/lib:$LD_LIBRARY_PATH >>$GITHUB_ENV

0 commit comments

Comments
 (0)