Using OrdinaryDiffEq.jl as a native ODE solver library from Rust with JuliaC --trim

trimming doesn’t work with Enzyme but no trimming seems to work

using Enzyme

function juliafunc(x)
    return sum(x)
end

Base.@ccallable function cjuliafunc(px::Ptr{Float64},xlen::UInt64)::Float64
    x = unsafe_wrap(Vector{Float64},px,(xlen,))
    juliafunc(x)
end

Base.@ccallable function cjuliagrad(pg::Ptr{Float64},px::Ptr{Float64},xlen::UInt64) ::Cvoid
    g = unsafe_wrap(Vector{Float64},pg,(xlen,))
    x = unsafe_wrap(Vector{Float64},px,(xlen,))
    fill!(g,0.0)
    Enzyme.autodiff(Enzyme.Reverse,juliafunc,Duplicated(x,g))
    return Cvoid()
end
#[link(name = "ssplib", kind = "dylib")]
unsafe extern "C" {
    fn cjuliafunc(
        px: *mut f64,
        xlen: usize
    ) -> f64;
    fn cjuliagrad(
        pg: *mut f64,
        px: *mut f64,
        xlen: usize
    ) -> ();
}
fn main() {
    let mut x = vec![0.1;100];
    let s = unsafe {
        cjuliafunc(x.as_mut_ptr(), x.len())
    };
    println!("{}",s);
    let mut g = vec![0.0;100];
    unsafe {
        cjuliagrad(g.as_mut_ptr(),x.as_mut_ptr(), x.len())
    };
    println!("{:?}",g);
}
juliac --output-lib ssplib --project="." ssprk.jl  
ln -sf ssplib.dylib libssplib.dylib     
RUSTFLAGS="-L native=$(pwd) -C link-arg=-Wl,-rpath,$(pwd)" cargo run --release

gives

10
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

however since no trimming if I bundle its pretty big

juliac --output-lib ssplib --project="." ssprk.jl   --bundle
yolhan@Mac testrs % du -sh ./lib
526M    ./lib
yolhan@Mac testrs % du -sh ./share
 29M    ./share