conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.95k stars 952 forks source link

[question] What is the current state of QNX and Conan? #7012

Open derived-coder opened 4 years ago

derived-coder commented 4 years ago

I would like to know what is the current state of support for QNX platform.

At the moment I can compile something, but I don't see any mapping of the conan arch to the QNX target arch when making a verbose build (-V gcc_ntoaarch64le option which points to the target is missing) http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html

This is my profile

QNX_BASE=/lhome/user/tools/qnx/qnx700
QNX_CONFIGURATION=/lhome/user/.qnx

[settings]
os=Neutrino
os.version=7.0
arch=armv8
compiler=qcc
compiler.version=5.4
compiler.libcxx=cxx
[options]
[build_requires]
[env]
PATH=[$QNX_BASE/host/linux/x86_64/usr/bin,$QNX_CONFIGURATION/bin,$QNX_BASE/jre/bin]
LD_LIBRARY_PATH=[$QNX_BASE/host/linux/x86_64/usr/lib]
CC=$QNX_BASE/host/linux/x86_64/usr/bin/qcc
CXX=$QNX_BASE/host/linux/x86_64/usr/bin/q++
CMAKE_C_COMPILER=$QNX_BASE/host/linux/x86_64/usr/bin/qcc
CMAKE_CXX_COMPILER=$QNX_BASE/host/linux/x86_64/usr/bin/q++
QNX_HOST=$QNX_BASE/host/linux/x86_64
QNX_TARGET=$QNX_BASE/target/qnx7
MAKEFLAGS=-I$QNX_BASE/target/qnx7/usr/include

I do not source anything else. I am just compiling with this profile above. I found following issue: https://github.com/bincrafters/community/issues/1041 with a big profile. but it didn't work either.

So my current problem is, that the binaries generated are not the for the target platform.

danimtb commented 4 years ago

In theory, you should be able to create packages using QNX as any other compiler as documented here: https://docs.conan.io/en/latest/integrations/cross_platform/qnx_neutrino.html

I see in the Conan codebase that CMAKE_SYSTEM_NAME is being populated with QNX, and tools.get_gnu_triplet() is prepared to handle cross-compilation flags.

I have no experience with QNX so I will ping @SSE4 for some help in this regard 😄

Johnnyxy commented 4 years ago

@derived-coder Hi, your provided profile won't work and from my experience it will not be sufficient to only use a profile to do all the configuration work for QNX.

The common workflow to use the QNX compiler is to setup the system to support calling the qcc and q++ out of the box from any path. For that there are two script files (.sh/.bat) in the QNX 7.0 installation folder which setup all paths to use the compiler. All tools I have seen (e.g. Boost B2) just call qcc and q++ directly so they have to be present in the PATH. To execute the compiler by using an absolute path could lead to confusing errors with CMake and the qcc/q++ itself.

You could use the hardcoded paths in your profile but I do not recommend it.

After providing a correctly setup environment (by executing qnxdev-env.sh/.bat from QNX install folder) you have to correct the following lines in the profile:

[settings]
os=Neutrino
os.version=7.0
arch=armv8
compiler=qcc
compiler.version=5.4
compiler.libcxx=cxx
[options]
[build_requires]
[env]
CC=qcc
CXX=q++
AR=ntoaarch64-ar
RANLIB=ntoaarch64-ranlib

I my tests I could not provide any additional parameters to CC or CXX thus I had to fall back to CMake toolchain files.

A complete example is provided in this ZIP file (source): https://github.com/bincrafters/community/files/4021060/conan_boost_qnx-7.0.zip

The splited profile files can be merged together if you want only an all-in-one profile file.

The CMAKE_C_COMPILER and CMAKE_CXX_COMPILER entries won't work at all. As those are CMake variables which you cannot set through environment variables (CMake doc). To set them you have to provide them in a CMake toolchain file (docs) by adding the following line to the profile in the env section:

CONAN_CMAKE_TOOLCHAIN_FILE=<FULLPATH_TO_YOUR_TOOLCHAIN_FILE>

Until now (at least CMake 3.15) I had to provide a full path or CMake could not find the toolchain file. I seems a relative path to a toolchain file is not supported by CMake.

Additionally you have to set certain variables which provide the correct parameters (e.g. -V) to the compiler in the CMake toolchain file. Have a look in toolchain file the previously mentioned ZIP file (see above).

derived-coder commented 4 years ago

Hi @ Johnnyxy I am using parts of your profile, thanks. I got it also working to compiled stuff. Not for all configs, but at least for one.

My question for the team in charge, is it possible to add QNX setup in CI for conan-center? That is the only way to make sue the recipes are working.

Johnnyxy commented 4 years ago

That every recipe / codeis just working cannot be ensured. As the QNX compiler has some problems of its own. Thus I think Conan could provide general settings. But not all recipes will just work out of the box only by providing these in the code base. Maybe I have some time next week. Then I will have a look at the current Conan code base. As it has changed since I did my last examination of possible changes to support QNX.

derived-coder commented 4 years ago

@Johnnyxy I removed the

CMAKE_C_COMPILER=$QNX_BASE/host/linux/x86_64/usr/bin/qcc
CMAKE_CXX_COMPILER=$QNX_BASE/host/linux/x86_64/usr/bin/q++

from my profile, as you correctly pointed out they are set via cmake toolchain file.

btw. That is how I set it:

CONAN_CMAKE_TOOLCHAIN_FILE=$PROFILE_DIR/toolchains/toolchain-aarch64le.cmake

There is $PROFILE_DIR which allows you now to use relative path to the toolchain, which gets to an absolute