conan-io / conan

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

Check for working C compiler: - broken #11674

Open himansu2906 opened 2 years ago

himansu2906 commented 2 years ago

Hello All,

I am new to conan and currently trying to create library package and I am using gcc compiler.

whenever I am trying to create package it is giving following error

but if I am building this library with cmake command, it is building perfectly fine.

I am not able to set cross compile setting for with Conan.

if anyone can guild how can cross compile with with Conan.

memsharded commented 2 years ago

Hi @himansu2906

Can you please try sharing your conanfile.py and your CMakeLists.txt? Another thing to try is to start with a "hello world" simple package, created with conan new hello/0.1 -m=cmake_lib, and see if you are able to build with that compiler. It is possible that such compiler has something specific (like gcc 3.4 is really old and the Conan toolchain is producing some incompatible flag, because it is designed and tested with more modern compilers.

Also, please, do not share the output as images, but copy and paste the whole output as text (Github has utilities to hide it, so it doesn't clutter the whole issue), not trimming it, but the whole command output. Thanks!

memsharded commented 2 years ago

Ok, I start to understand where the issues could be. Let me explain them:

memsharded commented 2 years ago

As a general recommendation, if you haven't yet I would recommended learning first a bit of the basics. Creating simple Conan packages, for different variants, but for mainstream, native compilers like Visual Studio or regular gcc. Reuse those packages. Use profile files to define configurations, etc. Then when you grasp the basics, you can then start more advanced stuff, as defining other non mainstream compilers, etc. If you like videos, then this free course might help a bit: https://academy.jfrog.com/path/conan

memsharded commented 2 years ago

Is it possible to get this tricore-gcc.exe compiler from somewhere to be able to test it?

A couple of further notes:

himansu2906 commented 2 years ago

@memsharded : do you have any update for me on the issue?

memsharded commented 2 years ago

I am trying to reproduce this, but due to not knowing about this specific compiler, it is being very complex.

I would need to reproduce, first the basic CMake example, without Conan:

Then, for Conan, I would need specification of the full profile, for example:

memsharded commented 2 years ago

Hi @himansu2906

I have managed to make it work, indeed the toolchain was the piece that I was missing. Find attached a working example: tricore-example.zip

Need to:

That should run the creation of a package (a library), and also the "consuming" and testing of that library by an executable application inside the test_package folder.

The changes I had to to are:

Just a note, the profile that is being passed with -pr=tricore should be the "host" profile (the one the binary will run). As it has the ELF extension, maybe it shouldnt be Windows, but Linux?

Please try it and let me know. Thanks!

himansu2906 commented 2 years ago

Hi @memsharded,

do you have any update on above question regarding no ".a files" being generated in package folder.

memsharded commented 1 year ago

yes, the build executed by the build() method happens in a "build" folder in the cache. The package() method has the responsibility of copying the desired package artifacts from the "build" folder to the "package" folder. This can be done in different ways:

maitrey commented 1 year ago

Hello @memsharded , Sorry for hijacking your issue. We use the same compiler , Do you see any potential issues if we define the profiles like this: `target_host=C:/hightec_ifx/bin/tricore standalone_toolchain=C:/hightec_ifx/ cc_compiler=tricore-gcc

[settings] os=RTAOS arch=tc39xx arch_build=x86_64 compiler=tricore-gcc build_type=Release

[env] PATH=[$standalone_toolchain/bin] CC=$target_host-gcc.exe LD=$target_host-gcc.exe AR=$target_host-ar.exe AS=$target_host-as RANLIB=$target_host-ranlib STRIP=$target_host-strip CFLAGS=-O2 -g -W -Wall -Wcast-align -Wcast-qual -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wfloat-equal -Wredundant-decls -Wstrict-prototypes -Wundef -Wunsuffixed-float-constants -mversion-info -Wmissing-declarations -Winline -Werror-implicit-function-declaration -Wno-bad-function-cast -Wsign-compare -finline -mcpu=tc39xx -maligned-data-sections -fmessage-length=0 -fno-builtin-memcpy -fno-builtin-memcmp -fno-builtin-memset -fno-builtin-strlen -fno-common LDFLAGS=-lgcc -mcpu=tc39xx -mfixed-sda -Wl,-r -nostdlib -Wl,--cref -Wl,-no-demangle,-demangle=none -Wl,--extmap=a -ferror-numbers

[conf] tools.cmake.cmaketoolchain:generator=MinGW Makefiles`

One more additional question would be : How are profiles handling absolute and relative linking ? Thanks in advance for answering my question. Its probably even a cmake question as LDFLAGS is an environment variable in cmake.

memsharded commented 1 year ago

I don't see any apparent issue, if it works for you, besides using the legacy [env] management instead of the new integrations, that you should use to be 2.0 ready:

Check https://docs.conan.io/en/latest/reference/conanfile/tools.html for more info

maitrey commented 1 year ago

It so far works for me . Actually sometime back in another issue, I requested to update the documentation for build env and runtime env which was mentioned as new feature in 2.0. See here: https://github.com/conan-io/conan/issues/11499#issuecomment-1165447155 . And I still cannot find it. Perhaps I am missing checking , could you please be kind to forward me the exact link ?

memsharded commented 1 year ago

Yes, we are going to add some more docs for exactly this in 1.52 release soon.

maitrey commented 1 year ago

Sorry to bother you again : One more additional question would be : How are profiles handling absolute and relative linking ? Thanks in advance for answering my question. Its probably even a cmake question as LDFLAGS is an environment variable in cmake. We have both absolute linking and relative linking as we have execute in place microcontroller.

memsharded commented 1 year ago

How are profiles handling absolute and relative linking ? Thanks in advance for answering my question. Its probably even a cmake question as LDFLAGS is an environment variable in cmake. We have both absolute linking and relative linking as we have execute in place microcontroller.

This is not something handled by profiles, it depends on compiler, build systems, etc. Note that CMake does not necessarily always listen to env-vars (maybe only with Makefiles generators?). You can define user conf if you need it, or maybe it is something that you want to create custom settings to model it, and then pass that setting to your build scripts. But Conan doesn't have anything built-in for it.