google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.97k stars 10.18k forks source link

QNX 7.0 cross compile failed with qcc 5.4 #3796

Open hehenihao opened 2 years ago

hehenihao commented 2 years ago

Describe the bug

I want to build a library using on the QNX 7.0, and i can build a one with cmake option -DBUILD_GMOCK=OFF,but fail with -DBUILD_GMOCK=ON

Steps to reproduce the bug

cmake -DCMAKE_TOOLCHAIN_FILE=../qnx_aarch64.cmake -DCMAKE_INSTALL_PREFIX=../install -DBUILD_GMOCK=ON -DCMAKE_SYSTEM_NAME=QNX ..

Does the bug persist in the most recent commit?

yes

What operating system and version are you using?

QNX 7.0

What compiler and version are you using?

QCC 5.4.0

What build system are you using?

cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

derekmauro commented 2 years ago

Can you provide qnx_aarch64.cmake and the error message?

hehenihao commented 2 years ago

Thank you in advance.

I source the qnx env at first

test "$BASH_SOURCE" = "" && echo "This script only can be run from bash" && return SCRIPT_SOURCE=$BASH_SOURCE test "$SCRIPT_SOURCE" = "$0" && echo "Script is being run, should be sourced" && exit 1

HOST_OS=$(uname -s) SCRIPT_DIR=$(dirname "${SCRIPT_SOURCE}") QNX_BASE=$(cd "${SCRIPT_DIR}"; pwd) case "$HOST_OS" in Linux) QNX_HOST=$QNX_BASE/host/linux/x86_64 ;; Darwin) QNX_HOST=$QNX_BASE/host/darwin/x86_64 ;; *) QNX_HOST=$QNX_BASE/host/win64/x86_64 ;; esac

QNX_TARGET=$QNX_BASE/target/qnx7 QNX_CONFIGURATION=$HOME/.qnx MAKEFLAGS=-I$QNX_BASE/target/qnx7/usr/include PATH=$QNX_HOST/usr/bin:$QNX_CONFIGURATION/bin:$QNX_BASE/jre/bin:$PATH

export QNX_TARGET QNX_HOST QNX_CONFIGURATION MAKEFLAGS PATH unset PYTHONPATH


the qnx_aarch64.cmake as the following:

set(QNX_HOST $ENV{QNX_HOST}) set(QNX_TARGET $ENV{QNX_TARGET}) set(PROJECTENV_LIB $ENV{PROJECTENV_LIB})

SET(CMAKE_SYSTEM_NAME QNX) SET(CMAKE_SYSTEM_PROCESSOR aarch64) SET(CMAKE_SYSTEM_VERSION 1) SET(arch gcc_ntoaarch64le) SET(ntoarch aarch64) SET(QNX_PROCESSOR aarch64)

SET(CMAKE_C_COMPILER qcc) SET(CMAKE_C_COMPILER_TARGET ${arch})

SET(CMAKE_CXX_COMPILER qcc -lang-c++) SET(CMAKE_CXX_COMPILER_TARGET ${arch})

SET(CMAKE_ASM_COMPILER qcc -V${arch}) SET(CMAKE_ASM_DEFINE_FLAG "-Wa,--defsym,")

SET(CMAKE_CUDA_COMPILER "${PROJECTENV_LIB}/cuda/cuda-safe-10.2/bin/nvcc") SET(CMAKE_CUDA_FLAGS "--target-directory aarch64-qnx") SET(CUDAToolkit_ROOT "${PROJECTENV_LIB}/cuda/cuda-safe-10.2") SET(CMAKE_CUDA_HOST_COMPILER "ntoaarch64-gcc")

SET(CMAKE_RANLIB ${QNX_HOST}/usr/bin/nto${ntoarch}-ranlib CACHE PATH "QNX ranlib program" FORCE) SET(CMAKE_AR ${QNX_HOST}/usr/bin/nto${ntoarch}-ar CACHE PATH "QNX qr Program" FORCE)

support cross compile stage

SET(CMAKE_STAGING_PREFIX "/tmp/staging")

set(QNX_ARCH "aarch64le") set(NV_PLATFORM_MATHLIB "m") set(QNX_KERNEL_VERSION "7.0.0") set(QNX_COMPILER_VERSION "5.4.0") set(QNX_TOOLS_VARIANT "aarch64-unknown-nto-qnx${QNX_KERNEL_VERSION}")

nv platform lib

set(NV_PLATFORM_SDK_INC "${PROJECTENV_LIB}/pdkLib/include") set(NV_PLATFORM_SDK_LIB_DIR "${PROJECTENV_LIB}/pdkLib/lib-target")

nv bsp lib

set(NV_BSP_INC "${PROJECTENV_LIB}/nvidia-bsp/usr/include") set(NV_BSP_LIB_DIR ${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/usr/lib ${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/lib)

usr lib

set(PROJECT_USR_INC "${PROJECTENV_LIB}/usrLib/include") set(PROJECT_USR_LIB_DIR "${PROJECTENV_LIB}/usrLib/lib")

auto-safety lib

set(PROJECT_AUTO_SAFETY_INC "${PROJECTENV_LIB}/auto-safety/safetysw_common")

set(NV_COMMON_PLATFORM_CFLAGS "-g \ -O2 \ -fomit-frame-pointer \ -fstack-protector-strong \ -Wall")

set(NV_COMMON_PLATFORM_CXXFLAGS "${NV_COMMON_PLATFORM_CFLAGS} \ -isystem ${QNX_HOST}/usr/lib/gcc/${QNX_TOOLS_VARIANT}/${QNX_COMPILER_VERSION}/include \ -isystem ${QNX_TARGET}/usr/include/c++/v1 \ -isystem ${QNX_TARGET}/usr/include/c++/${QNX_COMPILER_VERSION}/${QNX_TOOLS_VARIANT} \ -isystem ${QNX_TARGET}/usr/include \ -I ${NV_PLATFORM_SDK_INC} \ -I ${NV_BSP_INC} \ -I ${PROJECT_USR_INC} \ -I ${PROJECT_AUTO_SAFETY_INC} \ -I /home/sunzhijin/work/fast_dds_src/install/include \ -L /home/sunzhijin/work/fast_dds_src/install/lib \ -L${NV_PLATFORM_SDK_LIB_DIR} \ -Wl,-rpath-link=${NV_PLATFORM_SDK_LIB_DIR} \ -L${PROJECT_USR_LIB_DIR} \ -Wl,-rpath-link=${PROJECT_USR_LIB_DIR} \ -L${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/usr/lib \ -Wl,-rpath-link=${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/usr/lib") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NV_COMMON_PLATFORM_CXXFLAGS} -D_FILE_OFFSET_BITS=64 -D_QNX_SOURCE -D_POSIX_C_SOURCE=200112L -Wp,-Uunix -Wp,-Uunix -Wp,-U__unix -fexceptions -frtti -fPIC -fpermissive")

set(NV_COMMON_PLATFORM_C_FLAGS "${NV_COMMON_PLATFORM_CFLAGS} \ -isystem ${QNX_HOST}/usr/lib/gcc/${QNX_TOOLS_VARIANT}/${QNX_COMPILER_VERSION}/include \ -isystem ${QNX_TARGET}/usr/include \ -isystem ${NV_PLATFORM_SDK_INC} \ -isystem ${NV_BSP_INC} \ -isystem ${PROJECT_USR_INC} \ -I ${PROJECT_AUTO_SAFETY_INC} \ -I /home/sunzhijin/work/fast_dds_src/install/include \ -L /home/sunzhijin/work/fast_dds_src/install/lib \ -L${NV_PLATFORM_SDK_LIB_DIR} \ -Wl,-rpath-link=${NV_PLATFORM_SDK_LIB_DIR} \ -L${PROJECT_USR_LIB_DIR} \ -Wl,-rpath-link=${PROJECT_USR_LIB_DIR} \ -L${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/usr/lib \ -Wl,-rpath-link=${PROJECTENV_LIB}/nvidia-bsp/${QNX_ARCH}/usr/lib") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NV_COMMON_PLATFORM_C_FLAGS} -D_FILE_OFFSET_BITS=64 -D_QNX_SOURCE -D_POSIX_C_SOURCE=200112L -Wp,-Uunix -Wp,-Uunix -Wp,-U__unix ")

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)


error information

[ 25%] Built target gtest [ 37%] Building CXX object googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o In file included from /googletest/googlemock/include/gmock/gmock-actions.h:145:0, from /googletest/googlemock/include/gmock/gmock.h:56, from /googletest/googlemock/src/gmock-all.cc:39: /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: In static member function 'static testing::internal::StlContainerView<Element [N]>::const_reference testing::internal::StlContainerView<Element [N]>::ConstReference(const Element (&)[N])': /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:364:53: warning: there are no arguments to 'RelationToSourceReference' that depend on a template parameter, so a declaration of 'RelationToSourceReference' must be available [-fpermissive] return type(array, N, RelationToSourceReference()); ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: In static member function 'static testing::internal::StlContainerView<Element [N]>::type testing::internal::StlContainerView<Element [N]>::Copy(const Element (&)[N])': /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:367:48: warning: there are no arguments to 'RelationToSourceCopy' that depend on a template parameter, so a declaration of 'RelationToSourceCopy' must be available [-fpermissive] return type(array, N, RelationToSourceCopy()); ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: In static member function 'static testing::internal::StlContainerView<std::1::tuple<T1, T2> >::const_reference testing::internal::StlContainerView<std::1::tuple<T1, T2> >::ConstReference(const std::1::tuple<T1, T2>&)': /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:385:43: warning: there are no arguments to 'RelationToSourceReference' that depend on a template parameter, so a declaration of 'RelationToSourceReference' must be available [-fpermissive] RelationToSourceReference()); ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: In static member function 'static testing::internal::StlContainerView<std::1::tuple<T1, T2> >::type testing::internal::StlContainerView<std::1::tuple<T1, T2> >::Copy(const std::1::tuple<T1, T2>&)': /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:388:78: warning: there are no arguments to 'RelationToSourceCopy' that depend on a template parameter, so a declaration of 'RelationToSourceCopy' must be available [-fpermissive] return type(std::get<0>(array), std::get<1>(array), RelationToSourceCopy()); ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: At global scope: /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:416:37: error: 'IndexSequence' has not been declared auto ApplyImpl(F&& f, Tuple&& args, IndexSequence) ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:416:50: error: expected ',' or '...' before '<' token auto ApplyImpl(F&& f, Tuple&& args, IndexSequence) ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:426:5: error: 'MakeIndexSequence' was not declared in this scope MakeIndexSequence<std::tuple_size< ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:426:5: error: 'MakeIndexSequence' was not declared in this scope /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:427:62: error: expected primary-expression before ')' token typename std::remove_reference::type>::value>())) { ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: In function 'decltype (testing::internal::ApplyImpl(forward(f), forward(args), (( < std::1::tuple_size<typename std::1::remove_reference<_T2>::type>::value) > ))) testing::internal::Apply(F&&, Tuple&&)': /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:429:20: error: 'MakeIndexSequence' was not declared in this scope MakeIndexSequence<std::tuple_size< ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:430:77: error: expected primary-expression before ')' token typename std::remove_reference::type>::value>()); ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h: At global scope: /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:454:15: error: 'ElemFromList' does not name a type using Arg = ElemFromList<I, Args...>; ^ /googletest/googlemock/include/gmock/internal/gmock-internal-utils.h:458:34: error: expected type-specifier before 'IgnoredValue' using MakeResultIgnoredValue = IgnoredValue(Args...); ^ In file included from /googletest/googlemock/include/gmock/gmock.h:56:0, from /googletest/googlemock/src/gmock-all.cc:39: /googletest/googlemock/include/gmock/gmock-actions.h:1303:32: error: 'IndexSequence' has not been declared std::vector Convert(IndexSequence<I...>) const { ^ /googletest/googlemock/include/gmock/gmock-actions.h:1303:45: error: expected ',' or '...' before '<' token std::vector Convert(IndexSequence<I...>) const { ^ /googletest/googlemock/include/gmock/gmock-actions.h: In member function 'testing::internal::DoAllAction::operator testing::Action<R(Args ...)>() const': /googletest/googlemock/include/gmock/gmock-actions.h:1324:19: error: 'MakeIndexSequence' was not declared in this scope MakeIndexSequence<sizeof...(Actions) - 1>()), ^ /googletest/googlemock/include/gmock/gmock-actions.h:1323:14: error: expected primary-expression before '{' token return Op{Convert<Action<void(NonFinalType...)>>( ^ /googletest/googlemock/include/gmock/gmock-actions.h:1323:14: error: expected ';' before '{' token /googletest/googlemock/include/gmock/gmock-actions.h:1324:61: error: expected primary-expression before ')' token MakeIndexSequence<sizeof...(Actions) - 1>()), ^ /googletest/googlemock/include/gmock/gmock-actions.h:1325:56: error: expected ';' before '}' token std::get<sizeof...(Actions) - 1>(actions)}; ^ /googletest/googlemock/include/gmock/gmock-actions.h: At global scope: /googletest/googlemock/include/gmock/gmock-actions.h:1461:19: error: 'IgnoredValue' in namespace 'testing::internal' does not name a type typedef internal::IgnoredValue Unused; ^ /googletest/googlemock/include/gmock/gmock-actions.h:1780:11: error: 'IndexSequence' has not been declared R Apply(IndexSequence, IndexSequence, ^ /googletest/googlemock/include/gmock/gmock-actions.h:1780:24: error: expected ',' or '...' before '<' token R Apply(IndexSequence, IndexSequence, ^ /googletest/googlemock/include/gmock/gmock-actions.h: In member function 'R testing::internal::ActionImpl<R(Args ...), Impl>::operator()(Args&& ...) const': /googletest/googlemock/include/gmock/gmock-actions.h:1774:18: error: 'MakeIndexSequence' was not declared in this scope return Apply(MakeIndexSequence{}, ^ /googletest/googlemock/include/gmock/gmock-actions.h:1774:45: error: expected primary-expression before '{' token return Apply(MakeIndexSequence{}, ^ /googletest/googlemock/include/gmock/gmock-actions.h:1775:50: error: expected primary-expression before '{' token MakeIndexSequence<10 - kMaxArgs>{}, ^ /googletest/googlemock/include/gmock/gmock-actions.h: In member function 'R testing::internal::ActionImpl<R(Args ...), Impl>::Apply(int) const': /googletest/googlemock/include/gmock/gmock-actions.h:1794:22: error: 'args' was not declared in this scope /args=/args, std::get(args)..., ^ In file included from /googletest/googlemock/include/gmock/gmock.h:57:0, from /googletest/googlemock/src/gmock-all.cc:39: /googletest/googlemock/include/gmock/gmock-cardinalities.h: At global scope: /googletest/googlemock/include/gmock/gmock-cardinalities.h:50:33: error: expected constructor, destructor, or type conversion before '(' token GTEST_DISABLE_MSC_WARNINGSPUSH(4251 \ ^ In file included from /Work/V3NA/v3na_qnx_env/v3naEnv/qnx700/target/qnx7/usr/include/math.h:24:0, from /Work/V3NA/v3na_qnx_env/v3naEnv/qnx700/target/qnx7/usr/include/c++/v1/cmath:301, from /googletest/googlemock/include/gmock/gmock-matchers.h:259, from /googletest/googlemock/include/gmock/gmock-spec-builders.h:76, from /googletest/googlemock/include/gmock/gmock-function-mocker.h:43, from /googletest/googlemock/include/gmock/gmock.h:58, from /googletest/googlemock/src/gmock-all.cc:39: /Work/V3NA/v3na_qnx_env/v3naEnv/qnx700/target/qnx7/usr/include/_pack64.h:28:24: error: expected declaration before end of line cc: /Work/V3NA/v3na_qnx_env/v3naEnv/qnx700/host/linux/x86_64/usr/lib/gcc/aarch64-unknown-nto-qnx7.0.0/5.4.0/cc1plus error 1 googlemock/CMakeFiles/gmock.dir/build.make:75: recipe for target 'googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o' failed make[2]: [googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o] Error 1 CMakeFiles/Makefile2:118: recipe for target 'googlemock/CMakeFiles/gmock.dir/all' failed make[1]: [googlemock/CMakeFiles/gmock.dir/all] Error 2 Makefile:145: recipe for target 'all' failed make: *** [all] Error 2


segewang commented 2 years ago

Hi I met the same problem. Is the problem resolved? THX!

james94 commented 2 years ago

I dont think there is community support for building GMock for QNX Target yet like there is for GTest for QNX Target. Do you know if anyone has forked the googletest repo and updated GMock code to be compatible with QNX? Else we probably could look at what has been done for GMock for Linux as a starting point to QNX.

salih-aydogan commented 1 week ago

Hello, has this problem been solved? Can we cross-compile GTest and run it on QNX OS? I want to do software integration tests this way.