diff --git a/.gitignore b/.gitignore index 03dfbb3..0f7ad73 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ /include/ /templates/ /configure/*.local +/configure/CONFIG_SITE.Common.* O.*/ *.orig *.log diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 3fb5197..7ab42d8 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -43,7 +43,3 @@ CHECK_RELEASE = YES # MSVC - skip defining min()/max() macros and enable APIs USR_CPPFLAGS_WIN32 += -DNOMINMAX -D_WIN32_WINNT=_WIN32_WINNT_VISTA - -ifneq ($(filter-out msvc,$(CMPLR_CLASS)),) -USR_CXXFLAGS += -std=c++11 -endif diff --git a/configure/Makefile b/configure/Makefile index c8652b6..19aebd4 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -8,3 +8,18 @@ CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) CFG += CONFIG_PVXS_VERSION include $(TOP)/configure/RULES + +ifdef T_A +install: $(TOP)/configure/CONFIG_SITE.Common.$(T_A) + +$(TOP)/configure/CONFIG_SITE.Common.$(T_A): toolchain.c + $(PREPROCESS.cpp) + +else +clean: cleanToolchain + +.PHONY: cleanToolchain +cleanToolchain: + $(RM) $(wildcard CONFIG_SITE.Common.*) + +endif diff --git a/configure/toolchain.c b/configure/toolchain.c new file mode 100644 index 0000000..f6faece --- /dev/null +++ b/configure/toolchain.c @@ -0,0 +1,37 @@ +/* Compiler inspection + * + * expanded as configure/CONFIG_SITE.Common.* + */ +#define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) + +CONFIG_LOADED=YES + +#if __GNUC__ +/* also true for clang */ +GNUISH=YES +USR_CXXFLAGS += -std=c++11 +#endif + +#if __GNUC__ && !__clang__ +#define GCC_VERSION VERSION_INT(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__, 0) + +/* LTO takes a nice chunk out of the .so text size, but blows up the .a size */ +#if GCC_VERSION>=VERSION_INT(4,9,0,0) +OPT_CFLAGS_YES += -flto +OPT_CXXFLAGS_YES += -flto +USR_LDFLAGS += -flto +#endif + +/* Compress debug information on ELF targets for ~25%-50% reduction in .so and .a file size + * (C++ debug info is Huuuge!) + */ +#if __ELF__ && GCC_VERSION>=VERSION_INT(5,0,0,0) +USR_CFLAGS += -gz=zlib +USR_CXXFLAGS += -gz=zlib +/* Actually a binutils feature, which we can't detect. + * Assume binutils upgrade follow gcc + */ +USR_LDFLAGS += -Wl,--compress-debug-sections=zlib +#endif + +#endif /* __GNUC__ */ diff --git a/src/Makefile b/src/Makefile index 9d448fd..a4cee2a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,28 +7,22 @@ include $(TOP)/configure/CONFIG USR_CPPFLAGS += -DPVXS_API_BUILDING -ifneq (,$(filter gcc clang,$(CMPLR_CLASS))) +ifdef T_A +ifneq ($(CONFIG_LOADED),YES) +$(error Toolchain inspection failed $(MAKEFILE_LIST)) +endif +endif +ifeq ($(GNUISH),YES) # we explicitly mark dllimport/export anyway. # So hide our internal symbols to speed up linking/loading on all targets. USR_CFLAGS += -fvisibility=hidden USR_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden - -# Compress debug information on ELF targets for ~25%-50% reduction in .so and .a file size -# (C++ debug info is Huuuge!) -#USR_CFLAGS_Linux += -gz=zlib -#USR_CXXFLAGS_Linux += -gz=zlib -#USR_LDFLAGS_Linux += -Wl,--compress-debug-sections=zlib - -# LTO takes a nice chunk out of the .so text size, but blows up the .a size -#USR_CXXFLAGS += -flto -#USR_LDFLAGS += -flto +endif # fault on any undefined symbols (eg. from missing LIB_SYS_LIBS) # breaks on older ncurses (circa RHEL6) not using the INPUT() trick to pull in libtinfo.so -USR_LDFLAGS_Linux += -Wl,--no-undefined -Wl,--no-allow-shlib-undefined - -endif +#USR_LDFLAGS_Linux += -Wl,--no-undefined -Wl,--no-allow-shlib-undefined EXPANDVARS += PVXS_MAJOR_VERSION EXPANDVARS += PVXS_MINOR_VERSION