From be1c21fc513f00298d63498974334f8d78123bff Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 17 Aug 2011 13:57:46 -0600 Subject: [PATCH 1/4] o changed the build system so that we can implement functionality which is compiler specific in a separate file for each compiler. This will avoid accumulating MxN ifdef's where M is the number of OS and N is the number of comilers (worst case). This will make it easier to find code that is compiler specific centralizing all of it under libCom/osi/compiler. That should make it mush easier to port EPICS to run on a new compiler. o refactored compilerDependencies.h into code that is compiler specific (one libCom/osi/compiler/xxx/compilerDependent.h for each comiler) and code that isnt libCom/osi/compilerDependencies.h (this is a new location and is no longer in libCom/misc). --- configure/CONFIG.gnuCommon | 2 + configure/CONFIG_COMMON | 22 +++- configure/RULES_BUILD | 6 +- .../os/CONFIG.solarisCommon.solarisCommon | 2 + ...CONFIG.win32-x86-borland.win32-x86-borland | 2 + configure/os/CONFIG.win32-x86.win32-x86 | 2 + src/libCom/Makefile | 3 +- src/libCom/misc/compilerDependencies.h | 104 ------------------ .../osi/compiler/borland/compilerSpecific.h | 55 +++++++++ .../osi/compiler/clang/compilerSpecific.h | 59 ++++++++++ .../osi/compiler/default/compilerSpecific.h | 45 ++++++++ .../osi/compiler/gcc/compilerSpecific.h | 59 ++++++++++ .../osi/compiler/msvc/compilerSpecific.h | 57 ++++++++++ src/libCom/osi/compilerDependencies.h | 47 ++++++++ 14 files changed, 355 insertions(+), 110 deletions(-) delete mode 100644 src/libCom/misc/compilerDependencies.h create mode 100644 src/libCom/osi/compiler/borland/compilerSpecific.h create mode 100644 src/libCom/osi/compiler/clang/compilerSpecific.h create mode 100644 src/libCom/osi/compiler/default/compilerSpecific.h create mode 100644 src/libCom/osi/compiler/gcc/compilerSpecific.h create mode 100644 src/libCom/osi/compiler/msvc/compilerSpecific.h create mode 100644 src/libCom/osi/compilerDependencies.h diff --git a/configure/CONFIG.gnuCommon b/configure/CONFIG.gnuCommon index f0548024e..94d1286e0 100644 --- a/configure/CONFIG.gnuCommon +++ b/configure/CONFIG.gnuCommon @@ -12,6 +12,8 @@ GNU = YES +CMPLR_CLASS = gcc + GNU_BIN = $(GNU_DIR)/bin GNU_LIB = $(GNU_DIR)/lib diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 4bd8737f3..72d9d4e9f 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -133,11 +133,14 @@ POSIX_YES = os/posix GENERIC_SRC_DIRS = .. $(SRC_DIRS) OS_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ $(addprefix $(dir)/, os/$(OS_CLASS) $(POSIX_$(POSIX)) os/default )) -ALL_SRC_DIRS = $(OS_SRC_DIRS) $(GENERIC_SRC_DIRS) +CMPLR_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ + $(addprefix $(dir)/, compiler/$(CMPLR_CLASS) compiler/default )) +ALL_SRC_DIRS = $(CMPLR_SRC_DIRS) $(OS_SRC_DIRS) $(GENERIC_SRC_DIRS) #-------------------------------------------------- # compile line include directories INSTALL_INCLUDES += \ + -I$(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS) \ -I$(INSTALL_INCLUDE)/os/$(OS_CLASS) \ -I$(INSTALL_INCLUDE) SRC_INCLUDES = -I$(COMMON_DIR) $(addprefix -I, $(wildcard $(ALL_SRC_DIRS))) @@ -379,24 +382,35 @@ INSTALL_PERMISSIONS = 444 # # auto determine the directory paths that things are installed to # RULES: -# 1) found in any one of several os specific area +# 0) found in any one of several compiler specific paths +# => install to $(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS) +# 1) not found in (0) and found in any one of several OS specific paths # => install to $(INSTALL_INCLUDE)/os/$(OS_CLASS) -# 2) not foundin (1) and found in generic area +# 2) not found in (1) and found in generic paths # => install to $(INSTALL_INCLUDE) # 3) not found in (1) or (2) then may be (not yet) computer generated # => install into $(INSTALL_INCLUDE)/os/$(OS_CLASS) and let # build rules work on vpath # # These rules guarantee that the users include from -# no more than two directories +# no more than three directories # INSTALL_INC += $(foreach inc, $(INC), \ $(firstword \ + $(CMPLR_INSTALL_INC) \ $(OS_INSTALL_INC) \ $(GENERIC_INSTALL_INC) \ $(GENERATED_INSTALL_INC) ) ) INSTALL_INC += $(addprefix $(INSTALL_INCLUDE)/os/$(OS_CLASS)/, $(INC_$(OS_CLASS)) ) +# +# Rule 0 +# +CMPLR_INSTALL_INC = $(addprefix $(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS)/, $(INSTALL_INC_jjj) ) +INSTALL_INC_jjj = $(foreach dir, $(CMPLR_SRC_DIRS), $(INSTALL_INC_iii) ) +INSTALL_INC_iii = $(subst $(dir)/, , $(INSTALL_INC_hhh) ) +INSTALL_INC_hhh = $(wildcard $(addsuffix /$(inc), $(dir)) ) + # # Rule 1 # diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index f7247a5be..b861e00e6 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -415,7 +415,11 @@ $(INSTALL_INCLUDE)/% : % @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) $(INSTALL_INCLUDE)/os/$(OS_CLASS)/% : % - $(ECHO) "Installing os dependent include file $@" + $(ECHO) "Installing OS dependent include file $@" + @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) + +$(INSTALL_INCLUDE)/compiler/$(CMPLR_CLASS)/% : % + $(ECHO) "Installing compiler dependent include file $@" @$(INSTALL) -d -m $(INSTALL_PERMISSIONS) $< $(@D) $(INSTALL_DOC)/%: % diff --git a/configure/os/CONFIG.solarisCommon.solarisCommon b/configure/os/CONFIG.solarisCommon.solarisCommon index c38fc92d8..117957575 100644 --- a/configure/os/CONFIG.solarisCommon.solarisCommon +++ b/configure/os/CONFIG.solarisCommon.solarisCommon @@ -7,6 +7,8 @@ # Sites may override these definitions in CONFIG_SITE.solaris-sparc.solaris-sparc #------------------------------------------------------- +CMPLR_CLASS = solStudio + SPARCWORKS = /opt/SUNWspro GNU = NO diff --git a/configure/os/CONFIG.win32-x86-borland.win32-x86-borland b/configure/os/CONFIG.win32-x86-borland.win32-x86-borland index 8e7845192..26235c3bd 100644 --- a/configure/os/CONFIG.win32-x86-borland.win32-x86-borland +++ b/configure/os/CONFIG.win32-x86-borland.win32-x86-borland @@ -7,6 +7,8 @@ # Sites may override these definitions in CONFIG_SITE.win32-x86-borland.win32-x86-borland #------------------------------------------------------- +CMPLR_CLASS = borland + # Win32 valid build types and include directory suffixes VALID_BUILDS = Host Ioc diff --git a/configure/os/CONFIG.win32-x86.win32-x86 b/configure/os/CONFIG.win32-x86.win32-x86 index 4f55f943d..2daf2a103 100644 --- a/configure/os/CONFIG.win32-x86.win32-x86 +++ b/configure/os/CONFIG.win32-x86.win32-x86 @@ -11,6 +11,8 @@ VALID_BUILDS = Host Ioc +CMPLR_CLASS = msvc + # convert UNIX path to native path PATH_FILTER = $(subst /,\\,$(1)) diff --git a/src/libCom/Makefile b/src/libCom/Makefile index 57c2f7ab0..092345d4a 100644 --- a/src/libCom/Makefile +++ b/src/libCom/Makefile @@ -136,7 +136,6 @@ INC += epicsExport.h INC += unixFileName.h INC += locationException.h INC += ipAddrToAsciiAsynchronous.h -INC += compilerDependencies.h INC += epicsUnitTest.h INC += testMain.h SRCS += aToIPAddr.c @@ -195,6 +194,8 @@ INC += devLib.h INC += devLibVME.h INC += devLibVMEImpl.h INC += osdVME.h +INC += compilerDependencies.h +INC += compilerSpecific.h SRCS += epicsThread.cpp SRCS += epicsMutex.cpp diff --git a/src/libCom/misc/compilerDependencies.h b/src/libCom/misc/compilerDependencies.h deleted file mode 100644 index 4d451469e..000000000 --- a/src/libCom/misc/compilerDependencies.h +++ /dev/null @@ -1,104 +0,0 @@ - -/*************************************************************************\ -* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -/* - * Author: - * Jeffrey O. Hill - * johill@lanl.gov - */ - -#ifndef compilerDependencies_h -#define compilerDependencies_h - -/* - * This is an attempt to move all tests identifying what features a - * compiler supports into one file. - * - * Since this is a compiler, and not os dependent, issue then ifdefs - * are used. The ifdefs allow us to make the default assumption that - * standards incompliance issues will be fixed by future compiler - * releases. - */ - -#ifdef __cplusplus - -/* - * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete - * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification - */ - -#if defined ( _MSC_VER ) -# if _MSC_VER >= 1200 /* visual studio 6.0 or later */ -# define CXX_PLACEMENT_DELETE -# endif -# if _MSC_VER > 1300 /* some release after visual studio 7 we hope */ -# define CXX_THROW_SPECIFICATION -# endif -#elif defined ( __HP_aCC ) -# if _HP_aCC > 33300 -# define CXX_PLACEMENT_DELETE -# endif -# define CXX_THROW_SPECIFICATION -#elif defined ( __BORLANDC__ ) -# if __BORLANDC__ >= 0x600 -# define CXX_PLACEMENT_DELETE -# endif -# define CXX_THROW_SPECIFICATION -#elif defined ( __GNUC__ ) -# if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) -# define CXX_THROW_SPECIFICATION -# endif -# if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 ) -# define CXX_PLACEMENT_DELETE -# endif -#else -# define CXX_PLACEMENT_DELETE -# define CXX_THROW_SPECIFICATION -#endif - -/* - * usage: void func () epicsThrows (( std::bad_alloc, std::logic_error )) - */ -#if defined ( CXX_THROW_SPECIFICATION ) -# define epicsThrows(X) throw X -#else -# define epicsThrows(X) -#endif - -/* - * usage: epicsPlacementDeleteOperator (( void *, myMemoryManager & )) - */ -#if defined ( CXX_PLACEMENT_DELETE ) -# define epicsPlacementDeleteOperator(X) void operator delete X; -#else -# define epicsPlacementDeleteOperator(X) -#endif - -#endif /* __cplusplus */ - -/* - * Enable format-string checking if possible - */ -#ifdef __GNUC__ -# define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) -#else -# define EPICS_PRINTF_STYLE(f,a) -#endif - -/* - * Deprecation marker - */ -#ifdef __GNUC__ -# define EPICS_DEPRECATED __attribute__((deprecated)) -#else -# define EPICS_DEPRECATED -#endif - -#endif /* ifndef compilerDependencies_h */ diff --git a/src/libCom/osi/compiler/borland/compilerSpecific.h b/src/libCom/osi/compiler/borland/compilerSpecific.h new file mode 100644 index 000000000..9a86e1aae --- /dev/null +++ b/src/libCom/osi/compiler/borland/compilerSpecific.h @@ -0,0 +1,55 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerSpecific_h +#define compilerSpecific_h + +#ifndef __BORLANDC__ +# error compiler/borland/compilerSpecific.h is only for use with the Borland compiler +#endif + +#ifdef __cplusplus + +/* + * in general we dont like ifdefs but they do allow us to check the + * compiler version and make the optimistic assumption that + * standards incompliance issues will be fixed by future compiler + * releases + */ + +/* + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification + */ +#if __BORLANDC__ >= 0x600 +# define CXX_PLACEMENT_DELETE +#endif + +#define CXX_THROW_SPECIFICATION + +#endif /* __cplusplus */ + +/* + * Enable format-string checking if possible + */ +#define EPICS_PRINTF_STYLE(f,a) + +/* + * Deprecation marker + */ +#define EPICS_DEPRECATED + +#endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/clang/compilerSpecific.h b/src/libCom/osi/compiler/clang/compilerSpecific.h new file mode 100644 index 000000000..881c30f42 --- /dev/null +++ b/src/libCom/osi/compiler/clang/compilerSpecific.h @@ -0,0 +1,59 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerSpecific_h +#define compilerSpecific_h + +#ifndef __clang__ +# error compiler/clang/compilerSpecific.h is only for use with the clang compiler +#endif + +/* + * WARNING: the current state of this file is only based on reading clang manuals + * and has not actually been tested with the compiler + */ +#pragma warning compiler/clang/compilerSpecific.h is based on reading the manual, but hasnt been tested with the clang compiler + +#ifdef __cplusplus + +/* + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification + */ +#define CXX_PLACEMENT_DELETE +#define CXX_THROW_SPECIFICATION + +#endif /* __cplusplus */ + +/* + * Enable format-string checking if possible + */ +#if __has_attribute(format) +# define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) +#else +# define EPICS_PRINTF_STYLE +#endif + +/* + * Deprecation marker if possible + */ +#if __has_attribute(deprecated) +# define EPICS_DEPRECATED __attribute__((deprecated)) +#else +# define EPICS_DEPRECATED +#endif + +#endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/default/compilerSpecific.h b/src/libCom/osi/compiler/default/compilerSpecific.h new file mode 100644 index 000000000..da2a21acc --- /dev/null +++ b/src/libCom/osi/compiler/default/compilerSpecific.h @@ -0,0 +1,45 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerSpecific_h +#define compilerSpecific_h + +#ifdef __cplusplus + +/* + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification + * + * (our default guess is that the compiler implements the C++ 97 standard) + */ +#define CXX_THROW_SPECIFICATION +#define CXX_PLACEMENT_DELETE + +#endif /* __cplusplus */ + +/* + * Enable format-string checking if possible + * (our default guess is that the compiler doesnt implement non-standard extensions) + */ +#define EPICS_PRINTF_STYLE(f,a) + +/* + * Deprecation marker + * (our default guess is that the compiler doesnt implement non-standard extensions) + */ +#define EPICS_DEPRECATED + +#endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/gcc/compilerSpecific.h b/src/libCom/osi/compiler/gcc/compilerSpecific.h new file mode 100644 index 000000000..f30b696b5 --- /dev/null +++ b/src/libCom/osi/compiler/gcc/compilerSpecific.h @@ -0,0 +1,59 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerSpecific_h +#define compilerSpecific_h + +#ifndef __GNUC__ +# error compiler/gcc/compilerSpecific.h is only for use with the gnu compiler +#endif + +#ifdef __cplusplus + +/* + * in general we dont like ifdefs but they do allow us to check the + * compiler version and make the optimistic assumption that + * standards incompliance issues will be fixed by future compiler + * releases + */ + +/* + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification + */ + +#if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) +# define CXX_THROW_SPECIFICATION +#endif + +#if __GNUC__ > 2 || ( __GNUC__ == 2 && __GNUC_MINOR__ >= 96 ) +# define CXX_PLACEMENT_DELETE +#endif + +#endif /* __cplusplus */ + +/* + * Enable format-string checking if possible + */ +#define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) + +/* + * Deprecation marker if possible + */ + +#define EPICS_DEPRECATED __attribute__((deprecated)) + +#endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/msvc/compilerSpecific.h b/src/libCom/osi/compiler/msvc/compilerSpecific.h new file mode 100644 index 000000000..64ebf915f --- /dev/null +++ b/src/libCom/osi/compiler/msvc/compilerSpecific.h @@ -0,0 +1,57 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerSpecific_h +#define compilerSpecific_h + +#ifndef _MSC_VER +# error compiler/msvc/compilerSpecific.h is only for use with the Microsoft compiler +#endif + +#ifdef __cplusplus + +/* + * in general we dont like ifdefs but they do allow us to check the + * compiler version and make the optimistic assumption that + * standards incompliance issues will be fixed by future compiler + * releases + */ + +/* + * CXX_PLACEMENT_DELETE - defined if compiler supports placement delete + * CXX_THROW_SPECIFICATION - defined if compiler supports throw specification + */ +#if _MSC_VER >= 1200 /* visual studio 6.0 or later */ +# define CXX_PLACEMENT_DELETE +#endif + +#if _MSC_VER > 1300 /* some release after visual studio 7 we hope */ +# define CXX_THROW_SPECIFICATION +#endif + +#endif /* __cplusplus */ + +/* + * Enable format-string checking if possible + */ +#define EPICS_PRINTF_STYLE(f,a) + +/* + * Deprecation marker + */ +#define EPICS_DEPRECATED + +#endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compilerDependencies.h b/src/libCom/osi/compilerDependencies.h new file mode 100644 index 000000000..7f2acc699 --- /dev/null +++ b/src/libCom/osi/compilerDependencies.h @@ -0,0 +1,47 @@ + +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: + * Jeffrey O. Hill + * johill@lanl.gov + */ + +#ifndef compilerDependencies_h +#define compilerDependencies_h + +#include "compilerSpecific.h" + +#ifdef __cplusplus + +/* + * usage: void func () epicsThrows (( std::bad_alloc, std::logic_error )) + * + * Note: now a widely accepted concensus (ref Meyers and C++ faq) is that + * one should avoid using throw specifications in C++ code + */ +#if defined ( CXX_THROW_SPECIFICATION ) +# define epicsThrows(X) throw X +#else +# define epicsThrows(X) +#endif + +/* + * usage: epicsPlacementDeleteOperator (( void *, myMemoryManager & )) + */ +#if defined ( CXX_PLACEMENT_DELETE ) +# define epicsPlacementDeleteOperator(X) void operator delete X; +#else +# define epicsPlacementDeleteOperator(X) +#endif + +#endif /* __cplusplus */ + +#endif /* ifndef compilerDependencies_h */ From a05348d63ef195fd0242a452ee581b6df79f2f0b Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 19 Aug 2011 14:43:35 -0600 Subject: [PATCH 2/4] merged andrews merge to R3.15 --- src/libCom/osi/compiler/gcc/compilerSpecific.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libCom/osi/compiler/gcc/compilerSpecific.h b/src/libCom/osi/compiler/gcc/compilerSpecific.h index f30b696b5..3dc505c29 100644 --- a/src/libCom/osi/compiler/gcc/compilerSpecific.h +++ b/src/libCom/osi/compiler/gcc/compilerSpecific.h @@ -53,7 +53,10 @@ /* * Deprecation marker if possible */ - -#define EPICS_DEPRECATED __attribute__((deprecated)) +#if (__GNUC__ > 2) +# define EPICS_DEPRECATED __attribute__((deprecated)) +#else +# define EPICS_DEPRECATED +#endif #endif /* ifndef compilerSpecific_h */ From 1862b33328aea90ee3d083c47885770479a83f2e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 31 Aug 2011 17:32:32 -0500 Subject: [PATCH 3/4] configure: Adjust instructions for switching to clang --- configure/os/CONFIG_SITE.Common.darwin-x86 | 8 ++++---- configure/os/CONFIG_SITE.Common.linux-x86 | 8 +++++++- configure/os/CONFIG_SITE.Common.linux-x86_64 | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/configure/os/CONFIG_SITE.Common.darwin-x86 b/configure/os/CONFIG_SITE.Common.darwin-x86 index cefe9bdde..dc0e0206a 100644 --- a/configure/os/CONFIG_SITE.Common.darwin-x86 +++ b/configure/os/CONFIG_SITE.Common.darwin-x86 @@ -14,9 +14,9 @@ ARCH_CLASS = i386 #ARCH_CLASS = x86_64 #ARCH_CLASS = i386 x86_64 -# # Uncomment the followings lines to build with CLANG instead of GCC. # -#CC = clang -#CCC = clang++ -#GNU_LDLIBS_YES = +#GNU = NO +#CMPLR_CLASS = clang +#CC = clang +#CCC = clang++ diff --git a/configure/os/CONFIG_SITE.Common.linux-x86 b/configure/os/CONFIG_SITE.Common.linux-x86 index 19a5794c9..6760e2309 100644 --- a/configure/os/CONFIG_SITE.Common.linux-x86 +++ b/configure/os/CONFIG_SITE.Common.linux-x86 @@ -32,5 +32,11 @@ COMMANDLINE_LIBRARY = READLINE # Needs -lcurses (older versions) #COMMANDLINE_LIBRARY = READLINE_CURSES - OP_SYS_CFLAGS += -g + +# Uncomment the followings lines to build with CLANG instead of GCC. +# +#GNU = NO +#CMPLR_CLASS = clang +#CC = clang +#CCC = clang++ diff --git a/configure/os/CONFIG_SITE.Common.linux-x86_64 b/configure/os/CONFIG_SITE.Common.linux-x86_64 index 9d3bbd132..8095c9f2a 100644 --- a/configure/os/CONFIG_SITE.Common.linux-x86_64 +++ b/configure/os/CONFIG_SITE.Common.linux-x86_64 @@ -32,5 +32,11 @@ COMMANDLINE_LIBRARY = READLINE # Needs -lcurses (older versions) #COMMANDLINE_LIBRARY = READLINE_CURSES - OP_SYS_CFLAGS += -g + +# Uncomment the followings lines to build with CLANG instead of GCC. +# +#GNU = NO +#CMPLR_CLASS = clang +#CC = clang +#CCC = clang++ From 2def6a3d805671fe33bcca4da3e10c43f0652694 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 31 Aug 2011 17:35:18 -0500 Subject: [PATCH 4/4] Move default macros to compilerDependencies.h Added check in gcc-specific header to error if __clang__ defined Some versions of clang don't support __has_attribute() --- .../osi/compiler/borland/compilerSpecific.h | 10 ------- .../osi/compiler/clang/compilerSpecific.h | 28 ++++++------------- .../osi/compiler/default/compilerSpecific.h | 12 -------- .../osi/compiler/gcc/compilerSpecific.h | 8 ++++-- .../osi/compiler/msvc/compilerSpecific.h | 10 ------- src/libCom/osi/compilerDependencies.h | 17 ++++++++++- 6 files changed, 30 insertions(+), 55 deletions(-) diff --git a/src/libCom/osi/compiler/borland/compilerSpecific.h b/src/libCom/osi/compiler/borland/compilerSpecific.h index 9a86e1aae..9251bfe29 100644 --- a/src/libCom/osi/compiler/borland/compilerSpecific.h +++ b/src/libCom/osi/compiler/borland/compilerSpecific.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -42,14 +41,5 @@ #endif /* __cplusplus */ -/* - * Enable format-string checking if possible - */ -#define EPICS_PRINTF_STYLE(f,a) - -/* - * Deprecation marker - */ -#define EPICS_DEPRECATED #endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/clang/compilerSpecific.h b/src/libCom/osi/compiler/clang/compilerSpecific.h index 881c30f42..9c6b237c5 100644 --- a/src/libCom/osi/compiler/clang/compilerSpecific.h +++ b/src/libCom/osi/compiler/clang/compilerSpecific.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -21,12 +20,6 @@ # error compiler/clang/compilerSpecific.h is only for use with the clang compiler #endif -/* - * WARNING: the current state of this file is only based on reading clang manuals - * and has not actually been tested with the compiler - */ -#pragma warning compiler/clang/compilerSpecific.h is based on reading the manual, but hasnt been tested with the clang compiler - #ifdef __cplusplus /* @@ -39,21 +32,18 @@ #endif /* __cplusplus */ /* - * Enable format-string checking if possible + * __has_attribute() is not supported on all versions of clang yet */ -#if __has_attribute(format) -# define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) -#else -# define EPICS_PRINTF_STYLE -#endif /* - * Deprecation marker if possible + * Enable format-string checking */ -#if __has_attribute(deprecated) -# define EPICS_DEPRECATED __attribute__((deprecated)) -#else -# define EPICS_DEPRECATED -#endif +#define EPICS_PRINTF_STYLE(f,a) __attribute__((format(__printf__,f,a))) + +/* + * Deprecation marker + */ +#define EPICS_DEPRECATED __attribute__((deprecated)) + #endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/default/compilerSpecific.h b/src/libCom/osi/compiler/default/compilerSpecific.h index da2a21acc..f2a3f8c36 100644 --- a/src/libCom/osi/compiler/default/compilerSpecific.h +++ b/src/libCom/osi/compiler/default/compilerSpecific.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -30,16 +29,5 @@ #endif /* __cplusplus */ -/* - * Enable format-string checking if possible - * (our default guess is that the compiler doesnt implement non-standard extensions) - */ -#define EPICS_PRINTF_STYLE(f,a) - -/* - * Deprecation marker - * (our default guess is that the compiler doesnt implement non-standard extensions) - */ -#define EPICS_DEPRECATED #endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/gcc/compilerSpecific.h b/src/libCom/osi/compiler/gcc/compilerSpecific.h index 3dc505c29..efd17e4b2 100644 --- a/src/libCom/osi/compiler/gcc/compilerSpecific.h +++ b/src/libCom/osi/compiler/gcc/compilerSpecific.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -20,6 +19,10 @@ #ifndef __GNUC__ # error compiler/gcc/compilerSpecific.h is only for use with the gnu compiler #endif + +#ifdef __clang__ +# error compiler/gcc/compilerSpecific.h is not for use with the clang compiler +#endif #ifdef __cplusplus @@ -55,8 +58,7 @@ */ #if (__GNUC__ > 2) # define EPICS_DEPRECATED __attribute__((deprecated)) -#else -# define EPICS_DEPRECATED #endif + #endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compiler/msvc/compilerSpecific.h b/src/libCom/osi/compiler/msvc/compilerSpecific.h index 64ebf915f..587d534c7 100644 --- a/src/libCom/osi/compiler/msvc/compilerSpecific.h +++ b/src/libCom/osi/compiler/msvc/compilerSpecific.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -44,14 +43,5 @@ #endif /* __cplusplus */ -/* - * Enable format-string checking if possible - */ -#define EPICS_PRINTF_STYLE(f,a) - -/* - * Deprecation marker - */ -#define EPICS_DEPRECATED #endif /* ifndef compilerSpecific_h */ diff --git a/src/libCom/osi/compilerDependencies.h b/src/libCom/osi/compilerDependencies.h index 7f2acc699..c91133996 100644 --- a/src/libCom/osi/compilerDependencies.h +++ b/src/libCom/osi/compilerDependencies.h @@ -1,4 +1,3 @@ - /*************************************************************************\ * Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. @@ -44,4 +43,20 @@ #endif /* __cplusplus */ + +#ifndef EPICS_PRINTF_STYLE +/* + * No format-string checking + */ +# define EPICS_PRINTF_STYLE(f,a) +#endif + +#ifndef EPICS_DEPRECATED +/* + * No deprecation markers + */ +#define EPICS_DEPRECATED +#endif + + #endif /* ifndef compilerDependencies_h */