NSC preprocess diagnostics and output fixes#1018
Merged
AnastaZIuk merged 12 commits intomasterfrom Mar 17, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a set of real NSC problems that showed up during external preprocess usage.
tools/nscCTest flownsc -Ptext output by using one shared render path and proper Wave#pragma oncesupport instead of CLI-only cleanup hacksDetails
Builtin unmounting
ISystem::unmountBuiltins()no longer guesses what to remove from the global archive cache by matching path strings.Builtin bootstrap mounts are now tracked explicitly in a dedicated builtin mount registry while normal resolution still uses the same global archive cache as before.
That keeps normal archive lookup semantics unchanged for users while making builtin teardown deterministic and regression-testable.
NSC self-test and CI
nscnow exposes--self-test-unmount-builtins.The self-test creates the system state, verifies that builtin bootstrap mounts exist, calls
unmountBuiltins(), and then checks that the builtin mount registry is empty.This is wired into the existing
tools/nscCTest flow with--output-on-failureso CI failures print the full test output.Wave preprocess diagnostics
Wave preprocess failures now print much better diagnostics, including:
This makes the ugly
Unknown exception caught! Shader preprocessing failed.class of reports much easier to debug.Text preprocess output
The text output used by
nsc -Pnow uses the same shared preprocess render path as the rest of HLSL preprocessing.Whitespace and newline reconstruction is handled in the common Wave output renderer.
This also enables real Wave
#pragma oncehandling in our custom context instead of stripping#pragma oncelater from CLI output text. That fixes cases where#pragma onceleaked into preprocessed output while still preserving downstream pragmas such as DXC diagnostic pragmas.In practice this fixes the dumb text-output failures caused by token concatenation around directives and missing trailing newlines, including cases around
#pragma onceand files ending directly on directives like#endif.Validation
Local Debug validation included:
cmake --build build/dynamic --target nsc --config Debug -- /mctest --test-dir build/dynamic/tools/nsc -C Debug --output-on-failure -R "^(NBL_NSC_INSTALL_RUNTIMES_TEST|NBL_NSC_INSTALL_EXECUTABLES_TEST|NBL_NSC_COMPILE_AT_EXE_CWD_TEST|NBL_NSC_COMPILE_CUSTOM_CWD_TEST|NBL_NSC_DUMP_BUILD_INFO_TEST|NBL_NSC_SELF_TEST_UNMOUNT_BUILTINS)$"nsc -Psmoke tests for newline-sensitive directive cases#pragma onceno longer leaks into-Poutput while DXC pragmas still pass throughThanks
Thanks to @Themperror for the repros and for surfacing the external
nsc -Pfailure cases. Those reports made the broken diagnostics and text-output handling much easier to pin down.