summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-dxc-compiler.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-05-21 18:41:54 -0400
committerGitHub <noreply@github.com>2021-05-21 15:41:54 -0700
commit172538fdb418f7a2faab1f5a410f3b2cb8e18ba5 (patch)
treeb17fd1cae7ace4bb3f2dbdd4ad29f4f57df0b286 /source/compiler-core/slang-dxc-compiler.cpp
parent0389546b0b065303d3c6874891a9fab4428910b9 (diff)
Downstream option handling (#1850)
* #include an absolute path didn't work - because paths were taken to always be relative. * Added SourceLoc handling for command line parsing. * Fix typo in debug. * Fix issue around the DiagnosticSink used in options parsing not having a writer available - by having DiagnosticSink parenting. * Small rename for clarity. * WIP extracting command line args for downstream tools. * Unit tests/bug fixes around extracting args. * Use DownstreamArgs in the EndToEndCompileRequest * Passing downstream compiler options downstream. * Fix issue with endToEndReq being nullptr. * Fix issue with diagnostics number change. * Small improvements to how the source line is displayed if it's too long. Default to 120, as suggested in previous review. Co-authored-by: T. Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'source/compiler-core/slang-dxc-compiler.cpp')
-rw-r--r--source/compiler-core/slang-dxc-compiler.cpp37
1 files changed, 23 insertions, 14 deletions
diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp
index 7e7850780..0b46bd09e 100644
--- a/source/compiler-core/slang-dxc-compiler.cpp
+++ b/source/compiler-core/slang-dxc-compiler.cpp
@@ -212,14 +212,23 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
0,
dxcSourceBlob.writeRef()));
- WCHAR const* args[16];
- UINT32 argCount = 0;
+ List<const WCHAR*> args;
+
+ // Add all compiler specific options
+ List<OSString> compilerSpecific;
+ compilerSpecific.setCount(options.compilerSpecificArguments.getCount());
+
+ for (Index i = 0; i < options.compilerSpecificArguments.getCount(); ++i)
+ {
+ compilerSpecific[i] = options.compilerSpecificArguments[i].toWString();
+ args.add(compilerSpecific[i]);
+ }
// TODO: deal with
bool treatWarningsAsErrors = false;
if (treatWarningsAsErrors)
{
- args[argCount++] = L"-WX";
+ args.add(L"-WX");
}
switch (options.matrixLayout)
@@ -228,7 +237,7 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
break;
case SLANG_MATRIX_LAYOUT_ROW_MAJOR:
- args[argCount++] = L"-Zpr";
+ args.add(L"-Zpr");
break;
}
@@ -238,7 +247,7 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
break;
case FloatingPointMode::Precise:
- args[argCount++] = L"-Gis"; // "force IEEE strictness"
+ args.add(L"-Gis"); // "force IEEE strictness"
break;
}
@@ -247,10 +256,10 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
default:
break;
- case OptimizationLevel::None: args[argCount++] = L"-Od"; break;
- case OptimizationLevel::Default: args[argCount++] = L"-O1"; break;
- case OptimizationLevel::High: args[argCount++] = L"-O2"; break;
- case OptimizationLevel::Maximal: args[argCount++] = L"-O3"; break;
+ case OptimizationLevel::None: args.add(L"-Od"); break;
+ case OptimizationLevel::Default: args.add(L"-O1"); break;
+ case OptimizationLevel::High: args.add(L"-O2"); break;
+ case OptimizationLevel::Maximal: args.add(L"-O3"); break;
}
switch (options.debugInfoType)
@@ -259,7 +268,7 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
break;
default:
- args[argCount++] = L"-Zi";
+ args.add(L"-Zi");
break;
}
@@ -278,14 +287,14 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
// work on mainline Clang. Thus the only option we have available
// is the big hammer of turning off *all* warnings coming from dxc.
//
- args[argCount++] = L"-no-warnings";
+ args.add(L"-no-warnings");
OSString wideEntryPointName = options.entryPointName.toWString();
OSString wideProfileName = options.profileName.toWString();
if (options.flags & CompileOptions::Flag::EnableFloat16)
{
- args[argCount++] = L"-enable-16bit-types";
+ args.add(L"-enable-16bit-types");
}
SearchDirectoryList searchDirectories;
@@ -303,8 +312,8 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr
sourcePath.begin(),
wideEntryPointName.begin(),
wideProfileName.begin(),
- args,
- argCount,
+ args.getBuffer(),
+ UINT32(args.getCount()),
nullptr, // `#define`s
0, // `#define` count
&includeHandler, // `#include` handler