inkwell 0.8.0 -> 0.9.0
All checks were successful
Hydra nac3artiq-msys2 Hydra build #200230 of artiq:nac3:nac3artiq-msys2
Hydra nac3artiq-msys2-pkg Hydra build #200231 of artiq:nac3:nac3artiq-msys2-pkg
Hydra nac3artiq-profile Hydra build #200232 of artiq:nac3:nac3artiq-profile
Hydra nac3artiq Hydra build #200229 of artiq:nac3:nac3artiq
All checks were successful
Hydra nac3artiq-msys2 Hydra build #200230 of artiq:nac3:nac3artiq-msys2
Hydra nac3artiq-msys2-pkg Hydra build #200231 of artiq:nac3:nac3artiq-msys2-pkg
Hydra nac3artiq-profile Hydra build #200232 of artiq:nac3:nac3artiq-profile
Hydra nac3artiq Hydra build #200229 of artiq:nac3:nac3artiq
This commit was merged in pull request #772.
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -479,22 +479,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "inkwell"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1def4112dfb2ce2993db7027f7acdb43c1f4ee1c70a082a2eef306ed5d0df365"
|
||||
checksum = "7decbc9dfa45a4a827a6ff7b822c113b1285678a937e84213417d4ca8a095782"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"inkwell_internals",
|
||||
"libc",
|
||||
"llvm-sys",
|
||||
"once_cell",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inkwell_internals"
|
||||
version = "0.13.0"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63736175c9a30ea123f7018de9f26163e0b39cd6978990ae486b510c4f3bad69"
|
||||
checksum = "6cfe97ee860815a90ed17e09639513269e39420a7440f3f4c996f238c514cf8d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -39,7 +39,6 @@ NAC3 and ARTIQ-10 work without major issues on OpenBSD, but need to be compiled
|
||||
```
|
||||
pkg_add rust llvm-16.0.6 patchelf
|
||||
ln -s /usr/local/bin/clang-16 /usr/local/bin/clang-irrt
|
||||
ln -s /usr/local/bin/llvm-as-16 /usr/local/bin/llvm-as-irrt
|
||||
LLVM_SYS_160_PREFIX=/usr/local cargo build --release
|
||||
patchelf --set-rpath /usr/local/llvm16/lib target/release/libnac3artiq.so
|
||||
patchelf --set-rpath /usr/local/llvm16/lib target/release/nac3standalone
|
||||
|
||||
@@ -121,9 +121,8 @@ The build process (in `nac3core/build.rs`):
|
||||
1. Compile `irrt.cpp` to LLVM IR using `clang-irrt` targeting `wasm32` (to get target-independent IR).
|
||||
2. Filter the IR with regexes to keep only function definitions, declarations, type definitions, and globals.
|
||||
3. Strip debug metadata.
|
||||
4. Assemble to bitcode with `llvm-as-irrt`.
|
||||
5. Embed the bitcode via `include_bytes!()`.
|
||||
4. Embed the IR via `include_bytes!()`.
|
||||
|
||||
At compile time, `load_irrt()` parses this embedded bitcode into an LLVM module and initializes exception ID globals. The module is then linked into the final output.
|
||||
At compile time, `load_irrt()` parses this embedded IR into an LLVM module and initializes exception ID globals. The module is then linked into the final output.
|
||||
|
||||
To debug IRRT issues, set `DEBUG_DUMP_IRRT=1` when building nac3core. This writes `irrt.ll` (raw) and `irrt-filtered.ll` (after regex filtering) to the build output directory.
|
||||
|
||||
@@ -12,8 +12,7 @@ $ nix develop --command zsh # or use your preferred shell
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
The Nix flake provides LLVM 16, `clang-irrt`, `llvm-as-irrt`, and all other
|
||||
dependencies.
|
||||
The Nix flake provides LLVM, `clang-irrt`, and all other dependencies.
|
||||
|
||||
### PGO Build
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ strum = "0.28"
|
||||
strum_macros = "0.28"
|
||||
|
||||
[dependencies.inkwell]
|
||||
version = "0.8"
|
||||
version = "0.9"
|
||||
default-features = false
|
||||
features = ["llvm19-1-prefer-dynamic", "target-x86", "target-arm", "target-riscv", "no-libffi-linking"]
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::{
|
||||
fs::File,
|
||||
io::Write,
|
||||
path::Path,
|
||||
process::{Command, Stdio},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use regex::Regex;
|
||||
@@ -37,7 +37,7 @@ fn main() {
|
||||
let irrt_cpp_path = irrt_dir.join("irrt.cpp");
|
||||
|
||||
/*
|
||||
* HACK: Sadly, clang doesn't let us emit generic LLVM bitcode.
|
||||
* HACK: Sadly, clang doesn't let us emit generic LLVM IR.
|
||||
* Compiling for WASM (wasm32 for 32-bit, wasm64 for 64-bit) and
|
||||
* filtering the output with regex is the closest we can get.
|
||||
*/
|
||||
@@ -139,21 +139,6 @@ fn main() {
|
||||
file.write_all(wasm64_filtered_output.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
let mut llvm_as = Command::new("llvm-as-irrt")
|
||||
.stdin(Stdio::piped())
|
||||
.arg("-o")
|
||||
.arg(out_dir.join("irrt32.bc"))
|
||||
.spawn()
|
||||
.unwrap();
|
||||
llvm_as.stdin.as_mut().unwrap().write_all(wasm32_filtered_output.as_bytes()).unwrap();
|
||||
assert!(llvm_as.wait().unwrap().success());
|
||||
|
||||
let mut llvm_as = Command::new("llvm-as-irrt")
|
||||
.stdin(Stdio::piped())
|
||||
.arg("-o")
|
||||
.arg(out_dir.join("irrt64.bc"))
|
||||
.spawn()
|
||||
.unwrap();
|
||||
llvm_as.stdin.as_mut().unwrap().write_all(wasm64_filtered_output.as_bytes()).unwrap();
|
||||
assert!(llvm_as.wait().unwrap().success());
|
||||
File::create(out_dir.join("irrt32.ll")).unwrap().write_all(wasm32_filtered_output.as_bytes()).unwrap();
|
||||
File::create(out_dir.join("irrt64.ll")).unwrap().write_all(wasm64_filtered_output.as_bytes()).unwrap();
|
||||
}
|
||||
|
||||
@@ -36,17 +36,18 @@ pub fn load_irrt<'ctx>(
|
||||
) -> Module<'ctx> {
|
||||
let target = target.create_target_machine();
|
||||
let size_t = ctx.ptr_sized_int_type(&target.get_target_data(), None);
|
||||
let bitcode_buf = MemoryBuffer::create_from_memory_range(
|
||||
if size_t == ctx.i64_type() {
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/irrt64.bc"))
|
||||
} else if size_t == ctx.i32_type() {
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/irrt32.bc"))
|
||||
} else {
|
||||
unreachable!("Unsupported size_t type bit width, must be either 32-bit or 64-bit")
|
||||
},
|
||||
"irrt_bitcode_buffer",
|
||||
);
|
||||
let irrt_mod = Module::parse_bitcode_from_buffer(&bitcode_buf, ctx).unwrap();
|
||||
let ir_bytes: &[u8] = if size_t == ctx.i64_type() {
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/irrt64.ll"))
|
||||
} else if size_t == ctx.i32_type() {
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/irrt32.ll"))
|
||||
} else {
|
||||
unreachable!("Unsupported size_t type bit width, must be either 32-bit or 64-bit")
|
||||
};
|
||||
let mut ir_bytes = ir_bytes.to_vec();
|
||||
// inkwell 0.9 requires nul-terminated input
|
||||
ir_bytes.push(b'\0');
|
||||
let ir_buf = MemoryBuffer::create_from_memory_range_copy(&ir_bytes, "irrt_ir_buffer");
|
||||
let irrt_mod = ctx.create_module_from_ir(ir_buf).unwrap();
|
||||
let inline_attr = Attribute::get_named_enum_kind_id("alwaysinline");
|
||||
for symbol in &[
|
||||
"__nac3_int_exp_int32_t",
|
||||
|
||||
@@ -132,7 +132,6 @@ in rec {
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${llvm}/bin/clang${exe_suffix} $out/bin/clang-irrt${exe_suffix}
|
||||
ln -s ${llvm}/bin/llvm-as${exe_suffix} $out/bin/llvm-as-irrt${exe_suffix}
|
||||
'';
|
||||
clang = wrapCCWith rec {
|
||||
cc = stdenv.mkDerivation {
|
||||
|
||||
Reference in New Issue
Block a user