diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0057b6..6df56fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - name: Download and install GCC fork if: ${{ matrix.os == 'ubuntu-24.04' }} run: | - curl -LO https://github.com/antoyo/gcc/releases/latest/download/gcc-15.deb + curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb sudo dpkg --force-overwrite -i gcc-15.deb - name: Set env diff --git a/Cargo.toml b/Cargo.toml index 20d3014..932b6ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gccjit" -version = "3.1.1" +version = "3.2.0" authors = ["Sean Gillespie ", "Antoni Boucher "] description = "Higher-level Rust bindings for libgccjit." keywords = ["compiler", "jit", "gcc"] @@ -14,7 +14,7 @@ master = ["gccjit_sys/master"] dlopen = ["gccjit_sys/dlopen"] [dependencies] -gccjit_sys = { version = "1.1.1", path = "gccjit_sys" } +gccjit_sys = { version = "1.2.0", path = "gccjit_sys" } [package.metadata.docs.rs] features = ["master"] diff --git a/gccjit_sys/Cargo.toml b/gccjit_sys/Cargo.toml index a48f1aa..170e2e9 100644 --- a/gccjit_sys/Cargo.toml +++ b/gccjit_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gccjit_sys" -version = "1.1.2" +version = "1.2.0" authors = ["Sean Gillespie ", "Antoni Boucher "] #links = "gccjit" description = "Raw bindings to libgccjit. Companion to the gccjit crate." diff --git a/gccjit_sys/src/lib.rs b/gccjit_sys/src/lib.rs index beea2e9..8988e80 100644 --- a/gccjit_sys/src/lib.rs +++ b/gccjit_sys/src/lib.rs @@ -774,4 +774,10 @@ extern_maybe_dlopen! { #[cfg(feature="master")] fn gcc_jit_type_set_addressable(typ: *mut gcc_jit_type); + + #[cfg(feature="master")] + fn gcc_jit_set_lang_name(lang_name: *const c_char); + + #[cfg(feature="master")] + fn gcc_jit_context_set_filename(ctx: *mut gcc_jit_context, filename: *const c_char); } diff --git a/src/context.rs b/src/context.rs index 4e454db..6e6c931 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1271,6 +1271,16 @@ impl<'ctx> Context<'ctx> { panic!("{}", error); } } + + #[cfg(feature="master")] + pub fn set_filename(&self, filename: &str) { + let c_str = CString::new(filename).unwrap(); + with_lib(|lib| { + unsafe { + lib.gcc_jit_context_set_filename(self.ptr, c_str.as_ptr()); + } + }) + } } impl<'ctx> Drop for Context<'ctx> { diff --git a/src/lib.rs b/src/lib.rs index 1286807..9356310 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,7 +33,7 @@ mod block; #[cfg(feature="master")] mod target_info; -#[cfg(feature="dlopen")] +#[cfg(any(feature="dlopen", feature="master"))] use std::ffi::CStr; #[cfg(feature="dlopen")] use std::sync::OnceLock; @@ -148,3 +148,12 @@ pub static LIB: OnceLock> = OnceLock::new(); // Without the dlopen feature, we avoid using OnceLock as to not have any performance impact. #[cfg(not(feature="dlopen"))] static LIB: Libgccjit = Libgccjit::new(); + +#[cfg(feature="master")] +pub fn set_lang_name(lang_name: &'static CStr) { + unsafe { + with_lib(|lib| { + lib.gcc_jit_set_lang_name(lang_name.as_ptr()); + }); + } +}