Skip to content

NSC preprocess diagnostics and output fixes#1018

Merged
AnastaZIuk merged 12 commits intomasterfrom
nscFixes
Mar 17, 2026
Merged

NSC preprocess diagnostics and output fixes#1018
AnastaZIuk merged 12 commits intomasterfrom
nscFixes

Conversation

@AnastaZIuk
Copy link
Member

@AnastaZIuk AnastaZIuk commented Mar 17, 2026

Summary

This PR fixes a set of real NSC problems that showed up during external preprocess usage.

  • fixes builtin unmount tracking by recording builtin bootstrap mounts explicitly instead of inferring them from hardcoded paths
  • adds a direct NSC self-test for builtin unmounting and runs it through the existing tools/nsc CTest flow
  • improves Wave preprocess diagnostics so failures print full context and boost diagnostics
  • fixes nsc -P text output by using one shared render path and proper Wave #pragma once support instead of CLI-only cleanup hacks

Details

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

nsc now 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/nsc CTest flow with --output-on-failure so CI failures print the full test output.

Wave preprocess diagnostics

Wave preprocess failures now print much better diagnostics, including:

  • preprocessing phase
  • source identifier
  • active macro definition when relevant
  • source trailing-newline state
  • source snippet with caret when available
  • full boost diagnostic information

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 -P now 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 once handling in our custom context instead of stripping #pragma once later from CLI output text. That fixes cases where #pragma once leaked 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 once and files ending directly on directives like #endif.

Validation

Local Debug validation included:

  • cmake --build build/dynamic --target nsc --config Debug -- /m
  • ctest --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)$"
  • direct nsc -P smoke tests for newline-sensitive directive cases
  • direct smoke tests showing that #pragma once no longer leaks into -P output while DXC pragmas still pass through

Thanks

Thanks to @Themperror for the repros and for surfacing the external nsc -P failure cases. Those reports made the broken diagnostics and text-output handling much easier to pin down.

@AnastaZIuk AnastaZIuk changed the title NSC preprocess mode and builtin unmount self-test NSC preprocess diagnostics and output fixes Mar 17, 2026
@AnastaZIuk AnastaZIuk merged commit 0e3b68f into master Mar 17, 2026
24 of 25 checks passed
@AnastaZIuk AnastaZIuk deleted the nscFixes branch March 17, 2026 16:01
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