summaryrefslogtreecommitdiffstats
path: root/source/compiler-core
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-12-07 14:16:28 -0500
committerGitHub <noreply@github.com>2021-12-07 14:16:28 -0500
commit646eecc6af878ea7682c814c15b4e838c3231ee3 (patch)
tree2b77120d2e9ee0dd95b44e4a8ea1e36e4a885285 /source/compiler-core
parent8b3df74758c536db9535903158242dd2350e5265 (diff)
Check g++ version compatibility (#2044)
* #include an absolute path didn't work - because paths were taken to always be relative. * Test gcc >= 5.0 * Disable codegen for reflection tests. * Add parsing options. * Small comment changes to kick CI build.
Diffstat (limited to 'source/compiler-core')
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp24
1 files changed, 22 insertions, 2 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;