From c8626dff3fedd86cf697e49aec00c9e17c9015d8 Mon Sep 17 00:00:00 2001 From: Zachary Michaels Date: Wed, 11 Jun 2014 13:13:43 -0400 Subject: Gcc 4.9 LTO fix The new lto format requires use of the gcc-provided gcc-ar and gcc-ranlib binaries. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28130e566..8b1e61a51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,11 @@ else() else() set(WARNINGS "${WARNINGS} -Wlogical-op -Wno-error=maybe-uninitialized") endif() + # Since gcc 4.9 the LTO format is non-standard (slim), so we need the gcc-specific ar and ranlib binaries + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.0)) + set(CMAKE_AR "gcc-ar") + set(CMAKE_RANLIB "gcc-ranlib") + endif() if(MINGW) set(WARNINGS "${WARNINGS} -Wno-error=unused-value") set(MINGW_FLAG "-DWIN32_LEAN_AND_MEAN") -- cgit v1.2.3 From e84f39ae54f4f6715b2ef68d6a12b18d89df722d Mon Sep 17 00:00:00 2001 From: Zachary Michaels Date: Wed, 11 Jun 2014 13:15:23 -0400 Subject: Link to pthreads on non-apple unix --- CMakeLists.txt | 7 ++++++- src/CMakeLists.txt | 8 ++++---- tests/CMakeLists.txt | 14 +++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b1e61a51..86a5267b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ function(set_static_flags) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") endif() endfunction(set_static_flags) - + include_directories(src contrib/epee/include external "${CMAKE_BINARY_DIR}/version") if(APPLE) @@ -21,6 +21,11 @@ endif() set(STATIC ${MSVC} CACHE BOOL "Link libraries statically") +if (UNIX AND NOT APPLE) + # Note that at the time of this writing the -Wstrict-prototypes flag added below will make this fail + find_package(Threads REQUIRED) +endif() + if(MSVC) add_definitions("/bigobj /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4345 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61c04711b..e4e682b99 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,13 +30,13 @@ add_library(cryptonote_core ${CRYPTONOTE_CORE}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) add_executable(simpleminer ${MINER}) -target_link_libraries(daemon rpc cryptonote_core crypto common upnpc-static ${Boost_LIBRARIES}) -target_link_libraries(connectivity_tool cryptonote_core crypto common ${Boost_LIBRARIES}) -target_link_libraries(simpleminer cryptonote_core crypto common ${Boost_LIBRARIES}) +target_link_libraries(daemon rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(connectivity_tool cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(simpleminer cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) add_executable(simplewallet ${SIMPLEWALLET} ) -target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common upnpc-static ${Boost_LIBRARIES}) +target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_dependencies(daemon version) add_dependencies(rpc version) add_dependencies(simplewallet version) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 855b4d808..1d0c91dc9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -31,16 +31,16 @@ add_executable(unit_tests ${UNIT_TESTS}) add_executable(net_load_tests_clt net_load_tests/clt.cpp) add_executable(net_load_tests_srv net_load_tests/srv.cpp) -target_link_libraries(core_proxy cryptonote_core common crypto upnpc-static ${Boost_LIBRARIES}) -target_link_libraries(coretests cryptonote_core common crypto ${Boost_LIBRARIES}) +target_link_libraries(core_proxy cryptonote_core common crypto upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(coretests cryptonote_core common crypto ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) target_link_libraries(difficulty-tests cryptonote_core) -target_link_libraries(functional_tests cryptonote_core wallet common crypto ${Boost_LIBRARIES}) +target_link_libraries(functional_tests cryptonote_core wallet common crypto ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) target_link_libraries(hash-tests crypto) target_link_libraries(hash-target-tests crypto cryptonote_core) -target_link_libraries(performance_tests cryptonote_core common crypto ${Boost_LIBRARIES}) -target_link_libraries(unit_tests cryptonote_core common crypto gtest_main ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${Boost_LIBRARIES}) -target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${Boost_LIBRARIES}) +target_link_libraries(performance_tests cryptonote_core common crypto ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(unit_tests cryptonote_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_clt cryptonote_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) +target_link_libraries(net_load_tests_srv cryptonote_core common crypto gtest_main ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) if(NOT MSVC) set_property(TARGET gtest gtest_main unit_tests net_load_tests_clt net_load_tests_srv APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") -- cgit v1.2.3 From 6bee34e4a67ee5c38b240e05a0f7c28d3ba4099f Mon Sep 17 00:00:00 2001 From: Zachary Michaels Date: Thu, 12 Jun 2014 15:38:28 -0400 Subject: Fix to disable LTO for Clang The previous code was assuming Apple == Clang. This change should both enable LTO when using gcc on Apple and fix Clang when using it on other platforms. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86a5267b2..6f084ba22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ else() set(DEBUG_FLAGS "-g3 -O0") endif() set(RELEASE_FLAGS "-Ofast -DNDEBUG -Wno-unused-variable") - if(NOT APPLE) + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # There is a clang bug that does not allow to compile code that uses AES-NI intrinsics if -flto is enabled set(RELEASE_FLAGS "${RELEASE_FLAGS} -flto") endif() -- cgit v1.2.3