Skip to content

Track Slang module imports as dependencies - #28

Open
abe-nv wants to merge 1 commit into
NVIDIA-RTX:mainfrom
abe-nv:abekin/slang-import-dependencies
Open

abe-nv wants to merge 1 commit into
NVIDIA-RTX:mainfrom
abe-nv:abekin/slang-import-dependencies

Conversation

@abe-nv

@abe-nv abe-nv commented Oct 28, 2026

Copy link
Copy Markdown

Problem

The hierarchical update-time scan only follows #include lines. An entry point compiled with Slang is therefore not rebuilt when a module it imports changes, and projects end up working around it with blocks like

#if 0
#include "Module.slang"   // dependency tracking only
#endif

in their entry-point files.

Change

For Slang sources (--slang, or .slang / .slangh files) the scan also follows

  • import Foo; and __exported import Foo;
  • import Foo.Bar; (resolved as Foo/Bar.slang)
  • import "Foo.slang";
  • __include Foo; / __include "Foo.slang";

resolved like #include: relative to the including file, then through the -I directories, recursively. A module that is not a file on those paths is provided by the compiler itself (or fails there with a proper diagnostic), so it is skipped, with a note in --verbose mode, instead of the hard error #include gets. Non-Slang sources are unaffected; the Metal toolchain-header exception still applies to #include only.

Testing

Linux, Slang 2026.20, SPIR-V, in the RTX Neural Shading SDK (entry points importing module chains three levels deep):

  • steady state: no recompilation
  • touching a module imported by two optimizer entry points recompiles exactly those two permutations
  • touching a module imported by the training kernels and self-tests recompiles exactly those entry points, including through an import inside a #if and through an imported module that itself imports the touched one
  • the #if 0 #include workarounds could be removed from the SDK shaders

🤖 Generated with Claude Code

The hierarchical update-time scan only followed #include lines, so an entry
point compiled with Slang was not rebuilt when a module it imports changed.
Projects worked around it with "#if 0 / #include "Module.slang" / #endif"
blocks in the entry-point files.

For Slang sources (--slang, or .slang/.slangh files) the scan now also follows
"import Foo;", "__exported import Foo;", "import Foo.Bar;" (Foo/Bar.slang),
"import \"Foo.slang\";" and "__include Foo;", resolved like #include: relative
to the including file, then through the -I directories, recursively. A module
that is not a file on those paths is provided by the compiler itself (or fails
there with a proper diagnostic), so it is skipped with a note in --verbose mode
instead of the hard error #include gets.
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.

1 participant