summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index bcf857fc8..d4c5812b7 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1103,14 +1103,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
{
preprocessorDefinitions.Add(define.Key, define.Value);
}
- {
- auto linkage = getLinkage();
- for (auto& define : linkage->preprocessorDefinitions)
- {
- preprocessorDefinitions.Add(define.Key, define.Value);
- }
- }
-
+
{
/* TODO(JS): Not totally clear what options should be set here. If we are using the pass through - then using say the defines/includes
all makes total sense. If we are generating C++ code from slang, then should we really be using these values -> aren't they what is
@@ -1168,6 +1161,22 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
sourceLanguage = (SourceLanguage)TypeConvertUtil::getSourceLanguageFromTarget((SlangCompileTarget)sourceTarget);
}
+ // Add any preprocessor definitions associated with the linkage
+ {
+ // TODO(JS): This is somewhat arguable - should defines passed to Slang really be
+ // passed to downstream compilers? It does appear consistent with the behavior if
+ // there is an endToEndReq.
+ //
+ // That said it's very convenient and provides way to control aspects
+ // of downstream compilation.
+
+ auto linkage = getLinkage();
+ for (auto& define : linkage->preprocessorDefinitions)
+ {
+ preprocessorDefinitions.Add(define.Key, define.Value);
+ }
+ }
+
// If we have an extension tracker, we may need to set options such as SPIR-V version
// and CUDA Shader Model.
if (extensionTracker)