summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/core/slang-gcc-compiler-util.cpp21
-rw-r--r--source/slang/slang-compiler.cpp42
2 files changed, 52 insertions, 11 deletions
diff --git a/source/core/slang-gcc-compiler-util.cpp b/source/core/slang-gcc-compiler-util.cpp
index c48e779d1..b7cc85cb3 100644
--- a/source/core/slang-gcc-compiler-util.cpp
+++ b/source/core/slang-gcc-compiler-util.cpp
@@ -184,6 +184,16 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
outLineParseResult = LineParseResult::Start;
return SLANG_OK;
}
+
+ if (SLANG_SUCCEEDED(_parseErrorType(split0, outMsg.type)))
+ {
+ // Command line errors can be just contain 'error:' etc. Can be seen on apple/clang
+ outMsg.stage = OutputMessage::Stage::Compile;
+ outMsg.text = split[1].trim();
+ outLineParseResult = LineParseResult::Single;
+ return SLANG_OK;
+ }
+
outLineParseResult = LineParseResult::Ignore;
return SLANG_OK;
}
@@ -193,8 +203,9 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
const auto split1 = split[1].trim();
const auto text = split[2].trim();
- // Check for special handling for clang
- if (split0.startsWith(UnownedStringSlice::fromLiteral("clang")))
+ // Check for special handling for clang (Can be Clang or clang apparently)
+ if (split0.startsWith(UnownedStringSlice::fromLiteral("clang")) ||
+ split0.startsWith(UnownedStringSlice::fromLiteral("Clang")) )
{
// Extract the type
SLANG_RETURN_ON_FAIL(_parseErrorType(split[1].trim(), outMsg.type));
@@ -387,11 +398,11 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
/* static */SlangResult GCCCompilerUtil::calcArgs(const CompileOptions& options, CommandLine& cmdLine)
{
PlatformKind platformKind = (options.platform == PlatformKind::Unknown) ? PlatformUtil::getPlatformKind() : options.platform;
-
- cmdLine.addArg("-fvisibility=hidden");
-
+
if (options.sourceType == SourceType::CPP)
{
+ cmdLine.addArg("-fvisibility=hidden");
+
// Need C++14 for partial specialization
cmdLine.addArg("-std=c++14");
}
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index 8ead63784..5b8643b02 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -768,7 +768,7 @@ namespace Slang
return result;
}
- void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
+ void reportExternalCompileError(const char* compilerName, Severity severity, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
{
StringBuilder builder;
if (compilerName)
@@ -792,10 +792,15 @@ namespace Slang
PlatformUtil::appendResult(res, builder);
}
+ sink->diagnoseRaw(severity, builder.getUnownedSlice());
+ }
+
+ void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink)
+ {
// TODO(tfoley): need a better policy for how we translate diagnostics
// back into the Slang world (although we should always try to generate
// HLSL that doesn't produce any diagnostics...)
- sink->diagnoseRaw(SLANG_FAILED(res) ? Severity::Error : Severity::Warning, builder.getUnownedSlice());
+ reportExternalCompileError(compilerName, SLANG_FAILED(res) ? Severity::Error : Severity::Warning, res, diagnostic, sink);
}
static String _getDisplayPath(DiagnosticSink* sink, SourceFile* sourceFile)
@@ -1341,10 +1346,16 @@ SlangResult dissassembleDXILUsingDXC(
CPPCompiler::CompileOptions options;
+ // Set the source type
+ options.sourceType = (rawSourceLanguage == SourceLanguage::C) ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP;
+
// Generate a path a temporary filename for output module
String modulePath;
SLANG_RETURN_ON_FAIL(File::generateTemporary(UnownedStringSlice::fromLiteral("slang-generated"), modulePath));
+ // Remove the temporary path/file when done
+ temporaryFileSet.add(modulePath);
+
options.modulePath = modulePath;
options.sourceFiles.add(compileSourcePath);
@@ -1483,17 +1494,36 @@ SlangResult dissassembleDXILUsingDXC(
builder << "link ";
}
+ //
+ Severity severity = Severity::Error;
+
switch (msg.type)
{
- case OutputMessage::Type::Error: builder << "error"; break;
- case OutputMessage::Type::Unknown: builder << "warning"; break;
- case OutputMessage::Type::Info: builder << "info"; break;
+ case OutputMessage::Type::Unknown:
+ case OutputMessage::Type::Error:
+ {
+ severity = Severity::Error;
+ builder << "error";
+ break;
+ }
+ case OutputMessage::Type::Warning:
+ {
+ severity = Severity::Warning;
+ builder << "warning";
+ break;
+ }
+ case OutputMessage::Type::Info:
+ {
+ severity = Severity::Note;
+ builder << "info";
+ break;
+ }
default: break;
}
builder << " " << msg.code << ": " << msg.text;
- reportExternalCompileError(compilerText.getBuffer(), SLANG_OK, builder.getUnownedSlice(), sink);
+ reportExternalCompileError(compilerText.getBuffer(), severity, SLANG_OK, builder.getUnownedSlice(), sink);
}
}