Skip to content

Embed built-in headers in library binary#8445

Open
llvm-beanz wants to merge 5 commits into
microsoft:mainfrom
llvm-beanz:cbieneman/embed-hlsl-headers
Open

Embed built-in headers in library binary#8445
llvm-beanz wants to merge 5 commits into
microsoft:mainfrom
llvm-beanz:cbieneman/embed-hlsl-headers

Conversation

@llvm-beanz
Copy link
Copy Markdown
Collaborator

This change modifies the dxcompiler library build to embed built-in headers as binary data in the library, and it connects the include handler such that angle bracket (<>) includes will resolve against the built-in headers if corresponding headers are not found on the filesystem.

This allows users to override the headers by pointing to local copies on the filesystem, but also allows users to not worry about distributing the files with their compiler.

The main tradeoff here is a larger compiler binary since we're embedding some big chunks of static data.

This has some small changes to the Vulkan/SPIRV code since it will encourage angle bracket (<>) includes for built-in headers.

Fixes #8311

This change modifies the dxcompiler library build to embed built-in
headers as binary data in the library, and it connects the include
handler such that angle bracket (`<>`) includes will resolve against
the built-in headers if corresponding headers are not found on the
filesystem.

This allows users to override the headers by pointing to local copies
on the filesystem, but also allows users to not worry about
distributing the files with their compiler.

The main tradeoff here is a larger compiler binary since we're
embedding some big chunks of static data.
This is a cleanup to make the existing tests use the built-in headers
rather than finding them on the filesystem.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Copy Markdown
Member

@hekota hekota left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +90 to +92
# Carry the generated .inc files as an explicit dependency of the
# library target so they're produced before HLSLEmbeddedHeaders.cpp is
# compiled.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please point me to where is the dependency declared? I can't find it...

Comment thread utils/embed_header.py
Comment on lines +14 to +16
The generated file declares a single variable named ``Data`` at namespace
scope. The intent is for the file to be ``#include``-ed inside a wrapping
namespace by the consumer.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The generated file declares a single variable named ``Data`` at namespace
scope. The intent is for the file to be ``#include``-ed inside a wrapping
namespace by the consumer.
The generated file declares a single variable named ``Data`` at file
scope. The intent is for the file to be ``#include``-ed inside a wrapping
namespace by the consumer.

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

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

[SM6.10] Distribute LinAlg Headers

2 participants