Bug#789267: libgtest-dev: inconsistency with GTEST_HAS_PTHREAD in library interface leads to crashes on non-linux
Control: tags -1 + patch Hi! Finally got to this one, On 24.06.2015 06:43, Steve M. Robbins wrote: Current libgtest-dev has two different means to determine if GTEST_HAS_PTHREAD is defined: one in CMake rules [1] and second one in the header [2]. When they don't match [3], I have never used the CMake files, but in /usr/src/gtest/CMakeLists.txt, I see: config_compiler_and_linker() # Defined in internal_utils.cmake. and as far as I can see, that macro unconditionally defines GTEST_HAS_PTHREAD in cxx_base_flags. As long as the build uses these flags, it will override the logic in the header. So I don't see the issue. Can you elaborate further? Sure. Those flags are used for compiling libgtest, yes, but not for anything else that links to libgtest. For each target, CMake maintains two sets of compile definitions: one it uses for compiling the target itself, and another one which is passed (transitively unless specified otherwise) to targets which link themselves to this one. And the second one is missing. If you prefer, I can try to produce a patch. Yes, patch is always nice. Ack, a patch and a test case attached. -- Eugene V. Lyubimkin aka JackYF, JID: jackyf(maildog)jabber.fsfe.org C++ GNU/Linux userspace developer, Debian Developer --- gt-cmakelists 2015-07-18 16:17:22.150909549 +0300 +++ /usr/src/gtest/CMakeLists.txt 2015-07-18 16:53:53.725776982 +0300 @@ -68,6 +68,7 @@ # are used for other targets, to ensure that gtest can be compiled by a user # aggressive about warnings. cxx_library(gtest ${cxx_strict} src/gtest-all.cc) +target_compile_options(gtest INTERFACE ${cxx_public}) cxx_library(gtest_main ${cxx_strict} src/gtest_main.cc) target_link_libraries(gtest_main gtest) --- gt-internal-utils 2015-07-18 16:30:19.190762682 +0300 +++ /usr/src/gtest/cmake/internal_utils.cmake 2015-07-18 16:58:22.703110769 +0300 @@ -42,6 +42,11 @@ endif() endmacro() +macro(set_public_compiler_definitions) + string(REGEX MATCHALL -DGTEST_HAS_[^ ]*( |$) list_of_definitions ${cxx_default}) + string(REPLACEcxx_public ${list_of_definitions}) +endmacro() + # Defines the compiler/linker flags used to build Google Test and # Google Mock. You can tweak these definitions to suit your need. A # variable's value is empty before it's explicitly assigned to. @@ -120,6 +125,7 @@ # For building the gtest libraries. set(cxx_strict ${cxx_default} ${cxx_strict_flags}) + set_public_compiler_definitions() endmacro() # Defines the gtest gtest_main libraries. User tests should link testcase.tar.gz Description: application/gzip
Bug#789267: libgtest-dev: inconsistency with GTEST_HAS_PTHREAD in library interface leads to crashes on non-linux
On June 19, 2015 02:31:33 PM you wrote: Current libgtest-dev has two different means to determine if GTEST_HAS_PTHREAD is defined: one in CMake rules [1] and second one in the header [2]. When they don't match [3], I have never used the CMake files, but in /usr/src/gtest/CMakeLists.txt, I see: config_compiler_and_linker() # Defined in internal_utils.cmake. and as far as I can see, that macro unconditionally defines GTEST_HAS_PTHREAD in cxx_base_flags. As long as the build uses these flags, it will override the logic in the header. So I don't see the issue. Can you elaborate further? If you prefer, I can try to produce a patch. Yes, patch is always nice. Thanks, -Steve signature.asc Description: This is a digitally signed message part.
Bug#789267: libgtest-dev: inconsistency with GTEST_HAS_PTHREAD in library interface leads to crashes on non-linux
Package: libgtest-dev Version: 1.7.0-3 Severity: normal Dear Maintainer, Current libgtest-dev has two different means to determine if GTEST_HAS_PTHREAD is defined: one in CMake rules [1] and second one in the header [2]. When they don't match [3], the static library and the client code might be compiled with different value of this define. This, in turn, leads to the crashes because the definition of ThreadLocal class are different depending on the value of GTEST_HAS_PTHREAD. A possible solution would be to always declare CMake-determined defines as a public interface of gtest target, so everything which links gtest will get those defines as well. For this case, something along the lines target_compile_definitions(gtest PUBLIC -DGTEST_HAS_PTHREAD) If you prefer, I can try to produce a patch. [1] /usr/src/gtest/cmake/internal_utils.cmake:108 [2] /usr/include/gtest/internal/gtest-port.h:(473-481) [3] e.g. on our non-linux architectures -- System Information: Debian Release: 8.0 APT prefers unstable APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores) Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org