Skip to content

Fix the clang issue due to empty structure in the Tracing Layer#432

Open
pratikbariintel wants to merge 3 commits intooneapi-src:masterfrom
pratikbariintel:fix_clang_empty_structure
Open

Fix the clang issue due to empty structure in the Tracing Layer#432
pratikbariintel wants to merge 3 commits intooneapi-src:masterfrom
pratikbariintel:fix_clang_empty_structure

Conversation

@pratikbariintel
Copy link
Contributor

@pratikbariintel pratikbariintel commented Feb 25, 2026

Use void* instead of empty zer_get_default_context_params_t structure for parameter-less callbacks to fix Clang compilation.

Related-To: NEO-17790

Signed-off-by: Pratik Bari pratik.bari@intel.com

A dummy void pointer is added whenever the structure to be generated is
empty.

Related-To: NEO-17790

Signed-off-by: Pratik Bari <pratik.bari@intel.com>
A dummy void pointer is added whenever the structure to be generated is
empty.

Related-To: NEO-17790

Signed-off-by: Pratik Bari <pratik.bari@intel.com>
Use void* instead of empty zer_get_default_context_params_t
structure for parameter-less callbacks to fix Clang compilation.

Related-To: NEO-17790

Signed-off-by: Pratik Bari <pratik.bari@intel.com>

typedef void (ZE_APICALL *zer_pfnGetDefaultContextCb_t)(
zer_get_default_context_params_t* params,
void* params,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need void * params.
If empty params, if possible, lets skip this member variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently all the callbacks defined have the same pattern. In case this field is not required we have to define a new callback pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this data type is used in the exported function call:

ZE_APIEXPORT ze_result_t ZE_APICALL
zelTracerGetDefaultContextRegisterCallback(
zel_tracer_handle_t hTracer,
zel_tracer_reg_t callback_type,
zer_pfnGetDefaultContextCb_t pfnGetDefaultContextCb
);

So while it won't break immediate compilation or exported function ABI, the public struct type zer_pfnGetDefaultContextCb_t is changing in it's struct members. Thinking through this out loud.. The struct remains the same size, and void* also remains the same size.

The problem is the callback itself, the user must typecast it to match our callback data type, i.e. you see this yourself in the test content. It breaks how the user must define the actual callback API. This is my fear that, yes, this breaks ABI compatibility. Can instead of going this route, perhaps insert a placeholder void member; or something into the actual data structure, to avoid the clang warning?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can instead of going this route, perhaps insert a placeholder void member; or something into the actual data structure, to avoid the clang warning?

That would change the size of the structure ? Which might again be an ABI issue.

@joshuaranjan
Copy link

LGTM
Please request Vishnu to review


typedef void (ZE_APICALL *zer_pfnGetDefaultContextCb_t)(
zer_get_default_context_params_t* params,
void* params,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function pointer signature is changed in tracing header.
Just thinking about whether this breaks backward compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants