mirror of
https://github.com/nasa/trick.git
synced 2025-01-29 15:43:57 +00:00
ICG fails to compile on Mac when using clang/llvm 3.8.1. #271
Modified the makefile to define LIBCLANG_MAJOR, LIBCLANG_MINOR, and LIBCLANG_PATCHLEVEL based on the llvm-config executable in the llvm directory pointed to by the configuration. These new variable names are independent of the __clang_major__, etc. variables we were defining only in Linux. Using these names, we can reduce the clang version checks to a single consistent set of version numbers. We don't have to deal with the different version numbers assigned by Apple.
This commit is contained in:
parent
df94af17df
commit
f7d1ff6376
@ -39,11 +39,9 @@ void HeaderSearchDirs::AddCompilerBuiltInSearchDirs () {
|
||||
#if __linux
|
||||
std::stringstream icg_dir ;
|
||||
icg_dir << LLVM_HOME << "/lib/clang/" ;
|
||||
icg_dir << __clang_major__ << "." << __clang_minor__ ;
|
||||
#if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ >= 4))
|
||||
#ifdef __clang_patchlevel__
|
||||
icg_dir << "." << __clang_patchlevel__ ;
|
||||
#endif
|
||||
icg_dir << LIBCLANG_MAJOR << "." << LIBCLANG_MINOR ;
|
||||
#ifdef LIBCLANG_PATCHLEVEL
|
||||
icg_dir << "." << LIBCLANG_PATCHLEVEL ;
|
||||
#endif
|
||||
icg_dir << "/include" ;
|
||||
char * resolved_path = realpath(icg_dir.str().c_str(), NULL ) ;
|
||||
|
@ -426,11 +426,7 @@ void PrintAttributes::printIOMakefile() {
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "ifeq ($(IS_CC_CLANG), 0)" << std::endl ;
|
||||
makefile_io_src << " TRICK_SYSTEM_CXXFLAGS += -Wno-unused-local-typedefs" << std::endl ;
|
||||
makefile_io_src << " GCCVERSIONGTEQ48 := $(shell perl -e 'printf \"\%d\\n\", " <<
|
||||
"($(GCC_MAJOR)>4)||(($(GCC_MAJOR)==4)&&($(GCC_MINOR)>=8)) ;' )" << std::endl ;
|
||||
makefile_io_src << " ifeq ($(GCCVERSIONGTEQ48), 1)" << std::endl ;
|
||||
makefile_io_src << " TRICK_SYSTEM_CXXFLAGS += -Wno-unused-but-set-variable" << std::endl ;
|
||||
makefile_io_src << " endif" << std::endl ;
|
||||
makefile_io_src << "endif" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "ifdef TRICK_VERBOSE_BUILD" << std::endl ;
|
||||
|
@ -64,12 +64,10 @@ Most of the main program is pieced together from examples on the web. We are doi
|
||||
*/
|
||||
int main( int argc , char * argv[] ) {
|
||||
|
||||
#if (__clang_major__ >= 6) || ((__clang_major__ == 3) && (__clang_minor__ >= 5))
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||
clang::TargetOptions to;
|
||||
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
|
||||
clang::TargetOptions * to = new clang::TargetOptions() ;
|
||||
#else
|
||||
clang::TargetOptions to;
|
||||
clang::TargetOptions * to = new clang::TargetOptions() ;
|
||||
#endif
|
||||
clang::CompilerInstance ci;
|
||||
|
||||
@ -82,13 +80,6 @@ int main( int argc , char * argv[] ) {
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
/*
|
||||
if ( show_units ) {
|
||||
list_units() ;
|
||||
return 0 ;
|
||||
}
|
||||
*/
|
||||
|
||||
if ( input_file_names.empty() ) {
|
||||
std::cerr << "No header file specified" << std::endl ;
|
||||
return 1 ;
|
||||
@ -98,9 +89,6 @@ int main( int argc , char * argv[] ) {
|
||||
clang::DiagnosticOptions & diago = ci.getDiagnosticOpts() ;
|
||||
diago.ShowColors = 1 ;
|
||||
ci.getDiagnostics().setIgnoreAllWarnings(true) ;
|
||||
#if ( GCC_MAJOR == 4 ) && ( GCC_MINOR <= 2 )
|
||||
ci.getDiagnostics().setSuppressAllDiagnostics() ;
|
||||
#endif
|
||||
|
||||
// Set all of the defaults to c++
|
||||
clang::CompilerInvocation::setLangDefaults(ci.getLangOpts() , clang::IK_CXX) ;
|
||||
@ -110,15 +98,13 @@ int main( int argc , char * argv[] ) {
|
||||
ci.getLangOpts().CPlusPlus11 = true ;
|
||||
|
||||
// Set the default target architecture
|
||||
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||
to.Triple = llvm::sys::getDefaultTargetTriple();
|
||||
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
|
||||
to->Triple = llvm::sys::getDefaultTargetTriple();
|
||||
#else
|
||||
to.Triple = llvm::sys::getDefaultTargetTriple();
|
||||
to->Triple = llvm::sys::getDefaultTargetTriple();
|
||||
#endif
|
||||
|
||||
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||
std::shared_ptr<clang::TargetOptions> shared_to = std::make_shared<clang::TargetOptions>(to) ;
|
||||
clang::TargetInfo *pti = clang::TargetInfo::CreateTargetInfo(ci.getDiagnostics(), shared_to);
|
||||
#else
|
||||
@ -129,7 +115,7 @@ int main( int argc , char * argv[] ) {
|
||||
// Create all of the necessary managers.
|
||||
ci.createFileManager();
|
||||
ci.createSourceManager(ci.getFileManager());
|
||||
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||
ci.createPreprocessor(clang::TU_Complete);
|
||||
#else
|
||||
ci.createPreprocessor();
|
||||
@ -146,7 +132,7 @@ int main( int argc , char * argv[] ) {
|
||||
// Tell the preprocessor to use its default predefines
|
||||
clang::PreprocessorOptions & ppo = ci.getPreprocessorOpts() ;
|
||||
ppo.UsePredefines = true;
|
||||
#if (__clang_major__ == 3) && (__clang_minor__ >= 8)
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 8))
|
||||
pp.getBuiltinInfo().initializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts());
|
||||
#else
|
||||
pp.getBuiltinInfo().InitializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts());
|
||||
@ -167,7 +153,7 @@ int main( int argc , char * argv[] ) {
|
||||
|
||||
// Tell the compiler to use our ICGASTconsumer
|
||||
ICGASTConsumer *astConsumer = new ICGASTConsumer(ci, hsd, cs, pa);
|
||||
#if (__clang_major__ >= 6) || ((__clang_major__ == 3) && (__clang_minor__ >= 6))
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 6))
|
||||
std::unique_ptr<clang::ASTConsumer> unique_ast(astConsumer) ;
|
||||
ci.setASTConsumer(std::move(unique_ast));
|
||||
#else
|
||||
@ -193,7 +179,7 @@ int main( int argc , char * argv[] ) {
|
||||
}
|
||||
// Open up the input file and parse it.
|
||||
const clang::FileEntry *pFile = ci.getFileManager().getFile(input_file_full_path);
|
||||
#if (__clang_major__ >= 6) || ((__clang_major__ == 3) && (__clang_minor__ >= 5))
|
||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||
ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(pFile, clang::SourceLocation(), clang::SrcMgr::C_User));
|
||||
#else
|
||||
ci.getSourceManager().createMainFileID(pFile);
|
||||
|
@ -14,10 +14,6 @@ LLVMLDFLAGS := $(shell $(LLVM_HOME)/bin/llvm-config --ldflags) $(UDUNITS_LDFLAGS
|
||||
|
||||
OBJ_DIR := object_$(TRICK_HOST_CPU)
|
||||
|
||||
ifeq ($(IS_CC_CLANG), 0)
|
||||
CXXFLAGS += -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR)
|
||||
endif
|
||||
|
||||
ICG := ${TRICK_HOME}/bin/trick-ICG
|
||||
|
||||
SOURCES = $(wildcard *.cpp)
|
||||
@ -38,11 +34,12 @@ CLANGLIBS = \
|
||||
-lclangLex \
|
||||
-lclangBasic \
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE),Linux)
|
||||
CXXFLAGS += -D__clang_major__=$(CLANG_MAJOR) -D__clang_minor__=$(CLANG_MINOR)
|
||||
CXXFLAGS += -DLIBCLANG_MAJOR=$(CLANG_MAJOR) -DLIBCLANG_MINOR=$(CLANG_MINOR)
|
||||
ifneq ($(CLANG_PATCHLEVEL),)
|
||||
CXXFLAGS += -D__clang_patchlevel__=$(CLANG_PATCHLEVEL)
|
||||
CXXFLAGS += -DLIBCLANG_PATCHLEVEL=$(CLANG_PATCHLEVEL)
|
||||
endif
|
||||
|
||||
ifeq ($(TRICK_HOST_TYPE),Linux)
|
||||
CLANGLIBS += $(shell $(LLVM_HOME)/bin/llvm-config --libs)
|
||||
ifeq ($(CLANG_MINOR_GTEQ5),1)
|
||||
# Fedora 21 adds -ledit as a system lib, but it isn't installed, or required.
|
||||
|
Loading…
x
Reference in New Issue
Block a user