Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A wired variable name for library if output header file #7040

Closed
GinShio opened this issue Dec 18, 2024 · 3 comments
Closed

A wired variable name for library if output header file #7040

GinShio opened this issue Dec 18, 2024 · 3 comments
Labels
bug Bug, regression, crash
Milestone

Comments

@GinShio
Copy link

GinShio commented Dec 18, 2024

Description
If compile an exported function to header file, I got a bad variable name that is g_lib.no::entry.
It cannot be used in C or C++ source code:

const unsigned char g_lib.no::entry[] = {
  /* binary code */
};

Steps to Reproduce
shader:

export uint32_t f(uint32_t input) { return input; }

command:

dxc -O3 -T lib_6_8 -HV 2021 -Fh test.dxil.h test.hlsl
dxc -O3 -T lib_6_8 -HV 2021 -spirv -fspv-target-env=universal1.5 -Fh test.spv.h test.hlsl

Desired behavior
A good name can be used in C/C++. e.g. g_lib_no__entry.

Environment

  • DXC version: libdxcompiler.so: 1.8(dev;4662-416fab6b); libdxil.so: 1.8
  • Host Operating System: openSUSE Linux Tumbleweed
@GinShio GinShio added bug Bug, regression, crash needs-triage Awaiting triage labels Dec 18, 2024
@llvm-beanz llvm-beanz added this to the Backlog milestone Dec 18, 2024
@llvm-beanz llvm-beanz removed the needs-triage Awaiting triage label Dec 18, 2024
@llvm-beanz llvm-beanz moved this to Triaged in HLSL Triage Dec 18, 2024
@llvm-beanz
Copy link
Collaborator

This is a really odd feature that I didn't know existed. I imagine there is a reasonable workaround using #embed. This has likely been broken forever so it will be low priority for us to address.

@llvm-beanz
Copy link
Collaborator

For context what is happening here is that library shaders have no entry, so the entry is getting the name "no::entry", which when munged into the variable is odd.

There is a DXC flag -Vn which can be used to specify a specific variable name to use. I would recommend using that flag as a workaround for this issue.

@GinShio
Copy link
Author

GinShio commented Dec 19, 2024

This is a really odd feature that I didn't know existed. I imagine there is a reasonable workaround using #embed.

Yes, #embed is a good idea, but we cannot use C23 now...

There is a DXC flag -Vn which can be used to specify a specific variable name to use. I would recommend using that flag as a workaround for this issue.

Thanks a lot! It woks fine.

@GinShio GinShio closed this as completed Dec 19, 2024
@llvm-beanz llvm-beanz modified the milestones: Backlog, Dormant Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash
Projects
Archived in project
Development

No branches or pull requests

2 participants