diff options
-rw-r--r-- | CMakeLists.txt | 77 | ||||
-rwxr-xr-x | scripts/buildtests.sh | 5 | ||||
-rw-r--r-- | src/libicalss/icalssyacc.c | 10 | ||||
-rw-r--r-- | src/libicalss/icalssyacc.y | 4 |
4 files changed, 66 insertions, 30 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dab41307..5debd85a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,10 @@ # Default=false (build shared and static libs) # Takes precedence over STATIC_ONLY # +# -DENABLE_LTO_BUILD=[true|false] +# Build a link-time optimized version (requires gcc or clang) +# Default=false (do not build a link time optimized version) +# # -DGOBJECT_INTROSPECTION=[true|false] # Set to build GObject introspection "typelib" files # Requires GObject Introspection development package v0.6.7 or higher @@ -478,6 +482,32 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") endif() +######################################################## + +option(WITH_CXX_BINDINGS "Build the C++ bindings." True) +if(WITH_CXX_BINDINGS) + enable_language(CXX) + if(CMAKE_CXX_COMPILER) + add_definitions(-DWITH_CXX_BINDINGS) + else() + message(STATUS + "Warning: Building the C++ bindings is not possible since a C++ compiler could not be found. " + "Turning-off C++ bindings" + ) + set(WITH_CXX_BINDINGS False) + endif() +endif() +add_feature_info( + "Option WITH_CXX_BINDINGS" + WITH_CXX_BINDINGS + "build the C++ bindings. Requires a C++ compiler" +) + +#some test programs need to know if we are using 32-bit time +if(SIZEOF_TIME_T EQUAL 4) + set(USE_32BIT_TIME_T TRUE) +endif() + ################ Developer Options ##################### option(ABI_DUMPER "Build for abi-dumper." False) if(ABI_DUMPER) @@ -540,31 +570,34 @@ if(THREAD_SANITIZER) endif() endif() -######################################################## - -option(WITH_CXX_BINDINGS "Build the C++ bindings." True) -if(WITH_CXX_BINDINGS) - enable_language(CXX) - if(CMAKE_CXX_COMPILER) - add_definitions(-DWITH_CXX_BINDINGS) +option(ENABLE_LTO_BUILD "Build a link-time optimized version." False) +if(ENABLE_LTO_BUILD) + if(CMAKE_COMPILER_IS_GNUCC) + include(CheckCCompilerFlag) + check_c_compiler_flag(-flto HAVE_CC_COMPILER_LTO) + if(HAVE_CC_COMPILER_LTO) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlto-type-mismatch -flto -fuse-linker-plugin") + set(CMAKE_AR "gcc-ar") + set(CMAKE_RANLIB "gcc-ranlib") + else() + message(FATAL_ERROR + "Your C compiler ${CMAKE_C_COMPILER_ID} does not support the LTO building.") + endif() + if(WITH_CXX_BINDINGS AND CMAKE_COMPILER_IS_GNUCXX) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-flto HAVE_CXX_COMPILER_LTO) + if(HAVE_CXX_COMPILER_LTO) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wlto-type-mismatch -flto -fuse-linker-plugin") + else() + message(FATAL_ERROR + "Your C++ compiler ${CMAKE_CXX_COMPILER_ID} does not support LTO building.") + endif() + endif() else() - message(STATUS - "Warning: Building the C++ bindings is not possible since a C++ compiler could not be found. " - "Turning-off C++ bindings" - ) - set(WITH_CXX_BINDINGS False) + message(FATAL_ERROR + "Build link-time optimization using a non-GCC compiler is currently not supported.") endif() endif() -add_feature_info( - "Option WITH_CXX_BINDINGS" - WITH_CXX_BINDINGS - "build the C++ bindings. Requires a C++ compiler" -) - -#some test programs need to know if we are using 32-bit time -if(SIZEOF_TIME_T EQUAL 4) - set(USE_32BIT_TIME_T TRUE) -endif() ################# build subdirs ######################## diff --git a/scripts/buildtests.sh b/scripts/buildtests.sh index 668c6918..7cb3d988 100755 --- a/scripts/buildtests.sh +++ b/scripts/buildtests.sh @@ -253,7 +253,7 @@ CPPCHECK() { -D gmtime_r="" \ -D size_t="unsigned long" \ -D bswap32="" \ - -D PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP="" \ + -D PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP=0 \ -D _unused="(void)" \ -D _deprecated="(void)" \ -D F_OK=0 \ @@ -479,6 +479,7 @@ BDIR="" CMAKEOPTS="-DCMAKE_BUILD_TYPE=Debug -DGOBJECT_INTROSPECTION=False -DICAL_GLIB=False -DICAL_BUILD_DOCS=False" UUCCMAKEOPTS="$CMAKEOPTS -DCMAKE_DISABLE_FIND_PACKAGE_ICU=True" TZCMAKEOPTS="$CMAKEOPTS -DUSE_BUILTIN_TZDATA=True" +LTOCMAKEOPTS="$CMAKEOPTS -DENABLE_LTO_BUILD=True" #Static code checkers KRAZY @@ -495,6 +496,7 @@ CLANGTIDY test2builtin "$TZCMAKEOPTS" GCC_BUILD test1 "" GCC_BUILD test2 "$CMAKEOPTS" GCC_BUILD test3 "$UUCCMAKEOPTS" +GCC_BUILD test4 "$LTOCMAKEOPTS" if (test "`uname -s`" = "Linux") then echo "Temporarily disable cross-compile tests" @@ -508,6 +510,7 @@ GCC_BUILD test2builtin "$TZCMAKEOPTS" CLANG_BUILD test1 "" CLANG_BUILD test2 "$CMAKEOPTS" CLANG_BUILD test3 "$UUCCMAKEOPTS" +#CLANG_BUILD test4 "$LTOCMAKEOPTS" if (test "`uname -s`" = "Linux") then echo "Temporarily disable cross-compile tests" diff --git a/src/libicalss/icalssyacc.c b/src/libicalss/icalssyacc.c index 47b5b851..dc3f0894 100644 --- a/src/libicalss/icalssyacc.c +++ b/src/libicalss/icalssyacc.c @@ -153,8 +153,8 @@ extern struct icalgauge_impl *icalss_yy_gauge; -#define YYPARSE_PARAM yy_globals -#define YYLEX_PARAM yy_globals +//#define YYPARSE_PARAM yy_globals +//#define YYLEX_PARAM yy_globals #define YY_EXTRA_TYPE icalgauge_impl* @@ -881,7 +881,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - + #if YYERROR_VERBOSE @@ -1092,7 +1092,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar) } } #endif /* YYERROR_VERBOSE */ - + /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1124,7 +1124,7 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - + /* Prevent warnings from -Wmissing-prototypes. */ diff --git a/src/libicalss/icalssyacc.y b/src/libicalss/icalssyacc.y index 8524b4c3..41a8e04b 100644 --- a/src/libicalss/icalssyacc.y +++ b/src/libicalss/icalssyacc.y @@ -31,8 +31,8 @@ extern struct icalgauge_impl *icalss_yy_gauge; -#define YYPARSE_PARAM yy_globals -#define YYLEX_PARAM yy_globals +//#define YYPARSE_PARAM yy_globals +//#define YYLEX_PARAM yy_globals #define YY_EXTRA_TYPE icalgauge_impl* |