-
I'm trying to wrap a header depending on another (and using its definitions), but I don't want to include any of its definitions as I'll have wrapped that header separately. I used to do so with the While looking into this, it even seems that dependent headers get wrapper entirely, even though the toml documentation states that So concretely, function wrap(name, headers...; library="lib$name", defines=[], include_dirs=[])
options = load_options(joinpath(@__DIR__, "wrap.toml"))
options["general"]["library_name"] = library
options["general"]["output_file_path"] = "lib$(name).jl"
args = get_default_args()
for include_dir in include_dirs
push!(args, "-I$include_dir")
end
ctx = create_context([headers...], args, options)
build!(ctx)
return options["general"]["output_file_path"]
end
process("sycl", joinpath(dirname(@__DIR__), "deps", "sycl.h");
include_dirs=[dirname(dirname(oneAPI_Level_Zero_Headers_jll.ze_api))],
library="liboneapilib", modname="sycl")
#pragma once
#include <stddef.h>
#include <level_zero/ze_api.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct syclPlatform_st *syclPlatform_t;
int syclPlatformCreate(syclPlatform_t *obj, ze_driver_handle_t driver);
int syclPlatformDestroy(syclPlatform_t obj);
...
#ifdef __cplusplus
}
#endif
so using CEnum
const ze_bool_t = UInt8
mutable struct _ze_driver_handle_t end
# also all method definitions
# at the very end, there's the wrappers for sycl.h
mutable struct syclPlatform_st end
const syclPlatform_t = Ptr{syclPlatform_st}
function syclPlatformCreate(obj, driver)
ccall((:syclPlatformCreate, liboneapilib), Cint,
(Ptr{syclPlatform_t}, ze_driver_handle_t),
obj, driver)
end
function syclPlatformDestroy(obj)
ccall((:syclPlatformDestroy, liboneapilib), Cint,
(syclPlatform_t,),
obj)
end So summarized:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
With To generate self-contained and light-weighted Julia code, the default behavior(with But there are cases that can not be handled with the LLVM.jl needs to ignore everything in a dependent header. In this case, we need to loop through all of the nodes and manually mark and ignore those not required nodes. |
Beta Was this translation helpful? Give feedback.
-
The new API exposes the whole DAG of the TUs, so users can apply any custom passes after the codegen stage. |
Beta Was this translation helpful? Give feedback.
With
is_local_header_only=false
, all decls in a translation unit will be picked up, including all decls in the current header and dependent headers(both system headers and non-system headers).To generate self-contained and light-weighted Julia code, the default behavior(with
is_local_header_only=true
) of Clang.jl is only to pick up those decls used in the system headers. Any header can be treated as a system header if we pass the include directory flag as-isystem$include_dir
instead of-I include_dir
.But there are cases that can not be handled with the
-isystem
hack, for example,https://github.com/maleadt/LLVM.jl/blob/9155a8c30d6743197728e63c167d078167f34725/res/wrap_llvmextra.jl#L23…