Module: Mesa Branch: main Commit: bcd7538d03ef6514c62ca48ea0e43737b1ad41dd URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bcd7538d03ef6514c62ca48ea0e43737b1ad41dd
Author: Antonio Gomes <antoniospg...@gmail.com> Date: Thu Sep 14 19:16:56 2023 -0300 rusticl, meson: Move libc functions to their own crate Reviewed-by: Karol Herbst <kher...@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305> --- .../frontends/rusticl/mesa/compiler/clc/spirv.rs | 1 + .../frontends/rusticl/mesa/util/disk_cache.rs | 1 + src/gallium/frontends/rusticl/meson.build | 35 ++++++++++++++++++---- .../frontends/rusticl/rusticl_libc_bindings.h | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs b/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs index b9b3b725a73..813fff1e014 100644 --- a/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs +++ b/src/gallium/frontends/rusticl/mesa/compiler/clc/spirv.rs @@ -2,6 +2,7 @@ use crate::compiler::nir::*; use crate::pipe::screen::*; use crate::util::disk_cache::*; +use libc_rust_gen::malloc; use mesa_rust_gen::*; use mesa_rust_util::serialize::*; use mesa_rust_util::string::*; diff --git a/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs b/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs index ce272e83d78..ef0619eaa63 100644 --- a/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs +++ b/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs @@ -1,3 +1,4 @@ +use libc_rust_gen::free; use mesa_rust_gen::*; use std::ffi::{c_void, CString}; diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build index 6cff319f780..eff9aef6803 100644 --- a/src/gallium/frontends/rusticl/meson.build +++ b/src/gallium/frontends/rusticl/meson.build @@ -1,4 +1,4 @@ -# Copyright © +# Copyright © # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -221,6 +221,23 @@ rusticl_mesa_bindings_inline_wrapper = static_library( ], ) +rusticl_libc_bindings_rs = rust.bindgen( + input : 'rusticl_libc_bindings.h', + output : 'rusticl_libc_bindings.rs', + dependencies: [ + dep_valgrind, + ], + c_args : [ + rusticl_bindgen_c_args, + pre_args, + ], + args : [ + rusticl_bindgen_args, + '--allowlist-function', 'free', + '--allowlist-function', 'malloc', + ] +) + rusticl_mesa_bindings_rs = rust.bindgen( input : 'rusticl_mesa_bindings.h', output : 'rusticl_mesa_bindings.rs', @@ -240,10 +257,6 @@ rusticl_mesa_bindings_rs = rust.bindgen( ], args : [ rusticl_bindgen_args, - # libc - '--allowlist-function', 'free', - '--allowlist-function', 'malloc', - # mesa utils '--allowlist-function', 'blob_.*', '--allowlist-function', 'disk_cache_.*', @@ -324,6 +337,16 @@ libmesa_rust_gen = static_library( ], ) +libc_rust_gen = static_library( + 'libc_rust_gen', + rusticl_libc_bindings_rs, + gnu_symbol_visibility : 'hidden', + rust_crate_type : 'rlib', + rust_args : [ + rusticl_gen_args, + ], +) + libmesa_rust_util = static_library( 'mesa_rust_util', [libmesa_rust_util_files], @@ -343,6 +366,7 @@ libmesa_rust = static_library( rusticl_args, ], link_with : [ + libc_rust_gen, libmesa_rust_gen, libmesa_rust_util, rusticl_mesa_bindings_inline_wrapper, @@ -368,6 +392,7 @@ librusticl = static_library( rusticl_args, ], link_with : [ + libc_rust_gen, libmesa_rust, libmesa_rust_gen, libmesa_rust_util, diff --git a/src/gallium/frontends/rusticl/rusticl_libc_bindings.h b/src/gallium/frontends/rusticl/rusticl_libc_bindings.h new file mode 100644 index 00000000000..c8b49f26d17 --- /dev/null +++ b/src/gallium/frontends/rusticl/rusticl_libc_bindings.h @@ -0,0 +1 @@ +#include <stdlib.h>