summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp24
-rw-r--r--tools/slang-reflection-test/slang-reflection-test-main.cpp9
-rw-r--r--tools/slang-test/slang-test-main.cpp2
3 files changed, 32 insertions, 3 deletions
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index 5d72e675a..b5c359247 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -205,7 +205,9 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
#include "../slang.h"
^~~~~~~~~~~~
compilation terminated.*/
-
+
+ /* g++: error: unrecognized command line option ‘-std=c++14’ */
+
outDiagnostic.stage = Diagnostic::Stage::Compile;
List<UnownedStringSlice> split;
@@ -257,7 +259,9 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
// Check for special handling for clang (Can be Clang or clang apparently)
if (split0.startsWith(UnownedStringSlice::fromLiteral("clang")) ||
- split0.startsWith(UnownedStringSlice::fromLiteral("Clang")) )
+ split0.startsWith(UnownedStringSlice::fromLiteral("Clang")) ||
+ split0 == UnownedStringSlice::fromLiteral("g++") ||
+ split0 == UnownedStringSlice::fromLiteral("gcc"))
{
// Extract the type
SLANG_RETURN_ON_FAIL(_parseSeverity(split[1].trim(), outDiagnostic.severity));
@@ -654,6 +658,22 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse
RefPtr<DownstreamCompiler> compiler;
if (SLANG_SUCCEEDED(createCompiler(ExecutableLocation(path, "g++"), compiler)))
{
+ // A downstream compiler for Slang must currently support C++14 - such that
+ // the prelude and generated code works.
+ //
+ // The first version of gcc that supports `-std=c++14` is 5.0
+ // https://gcc.gnu.org/projects/cxx-status.html
+ //
+ // If could be argued to allow C/C++ compilations via older versions through an older version
+ // but that requires some more complex behavior, so we don't allow for now.
+
+ auto desc = compiler->getDesc();
+ if (desc.majorVersion < 5)
+ {
+ // If the version isn't 5 or higher, we don't add this version of the compiler.
+ return SLANG_OK;
+ }
+
set->addCompiler(compiler);
}
return SLANG_OK;
diff --git a/tools/slang-reflection-test/slang-reflection-test-main.cpp b/tools/slang-reflection-test/slang-reflection-test-main.cpp
index 0b8e88d68..af6da5113 100644
--- a/tools/slang-reflection-test/slang-reflection-test-main.cpp
+++ b/tools/slang-reflection-test/slang-reflection-test-main.cpp
@@ -1285,6 +1285,15 @@ static SlangResult maybeDumpDiagnostic(SlangResult res, SlangCompileRequest* req
SlangResult performCompilationAndReflection(SlangCompileRequest* request, int argc, const char*const* argv)
{
+ // We don't actually need codegen to get reflection.
+ //
+ // Ideally perhaps this would use a call to
+ // request->setCompileFlags(flags);
+ // But that relies on knowing what flags are set, and there isn't a way to get that, so do it arg way
+
+ const char* noCodeGenArgs[] = { "-no-codegen" };
+ SLANG_RETURN_ON_FAIL(maybeDumpDiagnostic(spProcessCommandLineArguments(request, noCodeGenArgs, SLANG_COUNT_OF(noCodeGenArgs)), request));
+
SLANG_RETURN_ON_FAIL(maybeDumpDiagnostic(spProcessCommandLineArguments(request, &argv[1], argc - 1), request));
SLANG_RETURN_ON_FAIL(maybeDumpDiagnostic(spCompile(request), request));
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index f57fe22a1..685e9dd7a 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -1914,7 +1914,7 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
const auto& diagnostics = compileResult->getDiagnostics();
- // If the actual compilation failed, then the output will be
+ // If the actual compilation failed, then the output will be the summary
if (SLANG_FAILED(diagnostics.result))
{
actualOutput = _calcSummary(diagnostics);