From 7c625afcc08c796da1186d74e2bb5ffef56efd32 Mon Sep 17 00:00:00 2001 From: Michael Ngarimu Date: Wed, 27 Oct 2021 22:07:50 -0700 Subject: [PATCH 1/2] Problem: (Windows) /GL /LTCG breaks builds when the compiler/linker of static library differs from compiler/linker of executable Solution: Enable /GL and /LTCG if and only if building as a Release (i.e. non-DEBUG) DLL. Resolves zeromq/libzmq#4287 --- CMakeLists.txt | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e3d601d..6c983c66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -891,13 +891,6 @@ if(MSVC) string(REGEX REPLACE "/Z.[^:]" "/Z7 " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") string(REGEX REPLACE "/Z.[^:]" "/Z7 " CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") - # Optimization flags. http://msdn.microsoft.com/en-us/magazine/cc301698.aspx - if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG") - endif() endif() # ----------------------------------------------------------------------------- @@ -1319,6 +1312,27 @@ if(MSVC) VS_GLOBAL_RunCodeAnalysis true) endfunction() if(BUILD_SHARED) + # Whole Program Optimization flags. http://msdn.microsoft.com/en-us/magazine/cc301698.aspx + # + # "Finally, there's the subject of libraries. It's possible to create .LIB + # files with code in its IL form. The linker will happily work with these + # .LIB files. Be aware that these libraries will be tied to a specific + # version of the compiler and linker. If you distribute these libraries, + # you'll need to update them if Microsoft changes the format of IL in a + # future release." + # + # /GL and /LTCG can cause problems when libraries built with different + # versions of compiler are later linked into an executable while /LTCG is active. + # https://social.msdn.microsoft.com/Forums/vstudio/en-US/5c102025-c254-4f02-9a51-c775c6cc9f4b/problem-with-ltcg-when-building-a-static-library-in-vs2005?forum=vcgeneral + # + # For this reason, enable only when building a "Release" (e.g. non-DEBUG) DLL. + if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG") + endif() + add_library(libzmq SHARED ${sources} ${public_headers} ${html-docs} ${readme-docs} ${CMAKE_CURRENT_BINARY_DIR}/NSIS.template.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc) if(ENABLE_ANALYSIS) From a6ed5b7a3f0f9c71762475b0870d42c504ea506c Mon Sep 17 00:00:00 2001 From: Michael Ngarimu Date: Thu, 28 Oct 2021 11:28:19 -0700 Subject: [PATCH 2/2] Adding missing RELICENSE file Resolves zeromq/libzmq#4287 --- RELICENSE/thxkiwi.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 RELICENSE/thxkiwi.md diff --git a/RELICENSE/thxkiwi.md b/RELICENSE/thxkiwi.md new file mode 100644 index 00000000..c4cd271e --- /dev/null +++ b/RELICENSE/thxkiwi.md @@ -0,0 +1,15 @@ +# Permission to Relicense under MPLv2 or any other share-alike OSI approved license chosen by the current ZeroMQ BDFL + +This is a statement by MICHAEL NGARIMU +that grants permission to relicense its copyrights in the libzmq C++ +library (ZeroMQ) under the Mozilla Public License v2 (MPLv2) or any other +share-alike Open Source Initiative approved license chosen by the current +ZeroMQ BDFL (Benevolent Dictator for Life). + +A portion of the commits made by the Github handle "thxkiwi", with +commit author "Michael Ngarimu ", are copyright of Michael Ngarimu. +This document hereby grants the libzmq project team to relicense libzmq, +including all past, present and future contributions of the author listed above. + +Michael Ngarimu +2021/10/28 \ No newline at end of file