mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 21:27:54 +00:00
1308 gcc ver (#1309)
* add correct GCC verno to ICG for llvm >= 10 Co-authored-by: Jacqueline Deans <jndeans@jslal0520121056.jsc.nasa.gov> Co-authored-by: Deans <jdeans289@gmail.com>
This commit is contained in:
parent
790ec56816
commit
3cd2a1606f
@ -245,7 +245,7 @@ AC_DEFUN([AX_GCC_VERSION], [
|
|||||||
AS_IF([test "x$GCC" = "xyes"],[
|
AS_IF([test "x$GCC" = "xyes"],[
|
||||||
AS_IF([test "x$ax_gcc_version_option" != "xno"],[
|
AS_IF([test "x$ax_gcc_version_option" != "xno"],[
|
||||||
AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
|
AC_CACHE_CHECK([gcc version],[ax_cv_gcc_version],[
|
||||||
ax_cv_gcc_version="`$CC -dumpversion`"
|
ax_cv_gcc_version="`$CC -dumpfullversion -dumpversion`"
|
||||||
AS_IF([test "x$ax_cv_gcc_version" = "x"],[
|
AS_IF([test "x$ax_cv_gcc_version" = "x"],[
|
||||||
ax_cv_gcc_version=""
|
ax_cv_gcc_version=""
|
||||||
])
|
])
|
||||||
|
@ -47,5 +47,6 @@ USE_ER7_UTILS = @USE_ER7_UTILS@
|
|||||||
LIBXML = @LIBXML@
|
LIBXML = @LIBXML@
|
||||||
|
|
||||||
PREFIX ?= @prefix@
|
PREFIX ?= @prefix@
|
||||||
|
TRICK_GCC_VERSION = @GCC_VERSION@
|
||||||
CONFIG_MK = 1
|
CONFIG_MK = 1
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Utilities.hh"
|
#include "Utilities.hh"
|
||||||
|
|
||||||
@ -191,3 +192,39 @@ std::string underline(const std::string& text, unsigned length) {
|
|||||||
std::string quote(const std::string& text) {
|
std::string quote(const std::string& text) {
|
||||||
return "\"" + text + "\"";
|
return "\"" + text + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// This function will accept version numbers with Major, Major.Minor, or Major.Minor.Patch.
|
||||||
|
// It removes non-numerical prefixes or postfixes to the version number. The return value
|
||||||
|
// is an int with the format MMmmpp, which is what llvm LangOpts.gnucversion expects.
|
||||||
|
// If there is a problem or no verno is provided, it returns the default value.
|
||||||
|
int gccVersionToIntOrDefault(const char* verno, int def) {
|
||||||
|
const int buffersize = 32;
|
||||||
|
// need mutable characters for strtok
|
||||||
|
char verbuf[buffersize];
|
||||||
|
if(verno == nullptr || verno[0] == '\0' || strlen(verno) >= buffersize) {
|
||||||
|
// Invalid GCC version string, returning default GCC version
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
strcpy(verbuf, verno);
|
||||||
|
const int len = strlen(verbuf);
|
||||||
|
const char* majMinPatch[3] = {"0", "0", "0"};
|
||||||
|
// Setting non-numerals to the delimeter (might catch vernos with prefix or postfix)
|
||||||
|
for(int i = 0; i < len; i++) {
|
||||||
|
if(verbuf[i] < '0' || verbuf[i] > '9') {
|
||||||
|
verbuf[i] = '.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char* next = strtok(verbuf, ".");
|
||||||
|
for(int i = 0; next != nullptr && i < 3; i++) {
|
||||||
|
majMinPatch[i] = next;
|
||||||
|
next = strtok(nullptr, ".");
|
||||||
|
}
|
||||||
|
// This is the format that LLVM expects for the version number
|
||||||
|
int result = 10000*atoi(majMinPatch[0]) + 100*atoi(majMinPatch[1]) + atoi(majMinPatch[2]);
|
||||||
|
if(result > 999999) {
|
||||||
|
std::cerr << "Warning: GCC_VERSION is invalid version number: " << result << ". Setting ICG to use default GCC version: " << def << std::endl;
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -28,5 +28,6 @@ std::string underline(const std::string& text);
|
|||||||
std::string underline(const std::string& text, unsigned length);
|
std::string underline(const std::string& text, unsigned length);
|
||||||
std::string quote(const std::string& text);
|
std::string quote(const std::string& text);
|
||||||
std::string & replace_special_chars( std::string & str);
|
std::string & replace_special_chars( std::string & str);
|
||||||
|
int gccVersionToIntOrDefault(const char* verno, int def);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -64,8 +64,14 @@ void set_lang_opts(clang::CompilerInstance & ci) {
|
|||||||
ci.getLangOpts().DoubleSquareBracketAttributes = true ;
|
ci.getLangOpts().DoubleSquareBracketAttributes = true ;
|
||||||
#endif
|
#endif
|
||||||
// Activate C++17 parsing
|
// Activate C++17 parsing
|
||||||
|
#ifdef TRICK_GCC_VERSION
|
||||||
|
const char * gcc_version = TRICK_GCC_VERSION;
|
||||||
|
#else
|
||||||
|
const char * gcc_version = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (LIBCLANG_MAJOR >= 10)
|
#if (LIBCLANG_MAJOR >= 10)
|
||||||
ci.getLangOpts().GNUCVersion = true ;
|
ci.getLangOpts().GNUCVersion = gccVersionToIntOrDefault(gcc_version, 40805);
|
||||||
ci.getLangOpts().CPlusPlus17 = true ;
|
ci.getLangOpts().CPlusPlus17 = true ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ endif
|
|||||||
|
|
||||||
ifeq ($(TRICK_HOST_TYPE),Linux)
|
ifeq ($(TRICK_HOST_TYPE),Linux)
|
||||||
CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs)
|
CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs)
|
||||||
|
CXXFLAGS += -DTRICK_GCC_VERSION=\"$(TRICK_GCC_VERSION)\"
|
||||||
ifeq ($(CLANG_MINOR_GTEQ5),1)
|
ifeq ($(CLANG_MINOR_GTEQ5),1)
|
||||||
# Fedora 21 adds -ledit as a system lib, but it isn't installed, or required.
|
# Fedora 21 adds -ledit as a system lib, but it isn't installed, or required.
|
||||||
CLANGLIBS += $(filter-out -ledit,$(shell $(LLVM_HOME)/bin/llvm-config --system-libs))
|
CLANGLIBS += $(filter-out -ledit,$(shell $(LLVM_HOME)/bin/llvm-config --system-libs))
|
||||||
|
Loading…
Reference in New Issue
Block a user