finally fix cross-LTO on windows builds

pull/1140/head
Rick V 4 years ago
parent 4cd7a22ca3
commit dbc559d4ff
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

@ -13,9 +13,10 @@ option(USE_AVX2 "enable avx2 code" OFF)
option(USE_NETNS "enable networking namespace support. Linux only" OFF)
option(NATIVE_BUILD "optimise for host system and FPU" ON)
option(EMBEDDED_CFG "optimise for older hardware or embedded systems" OFF)
if (NOT MSVC)
option(STATIC_LINK "link statically against dependencies" OFF)
option(STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads" OFF)
if (WIN32)
option(STATIC_LINK_RUNTIME "link statically against compiler runtime, standard library and pthreads" OFF)
else()
option(STATIC_LINK "link statically against dependencies" OFF)
endif()
option(SHADOW "use shadow testing framework. linux only" OFF)
option(XSAN "use sanitiser, if your system has it" OFF)

@ -13,7 +13,12 @@ file(MAKE_DIRECTORY ${LIBSODIUM_PREFIX}/include)
include(ExternalProject)
include(ProcessorCount)
set(SODIUM_CONFIGURE ./configure --prefix=${LIBSODIUM_PREFIX} --enable-static --disable-shared CC=${CMAKE_C_COMPILER})
if (CMAKE_C_COMPILER_ARG1)
set(SODIUM_CONFIGURE ./configure --prefix=${LIBSODIUM_PREFIX} --enable-static --disable-shared CC=${CMAKE_C_COMPILER} CPPFLAGS=${CMAKE_C_COMPILER_ARG1})
else()
set(SODIUM_CONFIGURE ./configure --prefix=${LIBSODIUM_PREFIX} --enable-static --disable-shared CC=${CMAKE_C_COMPILER})
endif()
if (LIBSODIUM_CROSS_TARGET)
set(SODIUM_CONFIGURE ${SODIUM_CONFIGURE} --target=${LIBSODIUM_CROSS_TARGET} --host=${LIBSODIUM_CROSS_TARGET})
endif()

@ -1,38 +1,14 @@
# This is now Win32 exclusive, other platforms can use static_link
if(NOT STATIC_LINK_RUNTIME)
return()
endif()
# not supported on Solaris - system libraries are not available as archives
# LTO is supported only for native builds
if(SOLARIS)
link_libraries( -static-libstdc++ -static-libgcc )
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
add_compile_options(-static -flto)
else()
add_compile_options(-static)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(APPLE)
link_libraries( -flto)
else()
link_libraries( -static -static-libstdc++ -pthread -flto )
endif()
return()
endif()
if(NOT CMAKE_CROSSCOMPILING)
set(CMAKE_AR "gcc-ar")
if (CMAKE_C_COMPILER_AR)
add_compile_options(-flto)
set(CMAKE_AR ${CMAKE_C_COMPILER_AR})
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "true")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_FINISH "true")
link_libraries( -flto -static-libstdc++ -static-libgcc -static ${CMAKE_CXX_FLAGS} ${CRYPTO_FLAGS} )
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endif()

Loading…
Cancel
Save