conan-io / conan

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

Conan doesn't know how to translate it to the GNU triplet #5914

Open AliAskari opened 4 years ago

AliAskari commented 4 years ago

To help us debug your issue please explain:

I am trying to cross compile for aarch64le and I am getting this warning:

libffi/3.2.1: WARN: Unknown 'aarch64le' machine, Conan doesn't know how to translate it to the GNU triplet, please report at https://github.com/conan-io/conan/issues

My conan profile is below:

[settings]
arch=aarch64le
arch_build=x86_64
build_type=Debug
compiler=qcc
compiler.version=5.4
compiler.libcxx=cxx
os=Neutrino
os.version=7.0
os_build=Linux

[env]
CONAN_CMAKE_TOOLCHAIN_FILE="$PROFILE_DIR/qnx-toolchain.cmake"
memsharded commented 4 years ago

Hi @AliAskari

I guess that aarch64le is a custom architecture that you added yourself to the settings.yml file, isn't it? If so, that is the reason why the AutoToolsBuildEnvironment is not able to map it correctly, because it is not defined.

I am not sure if this would be a totally new architecture, or it is actually another name for arm64 (armv8?):

I can see in the Conan code that:

  "armv8": "aarch64",
  "armv8_32": "aarch64",  # https://wiki.linaro.org/Platform/arm64-ilp32
  "armv8.3": "aarch64",

Is using one of those armv8 a possibility?

and detection of aarch64 is mapped to armv8

Hopobcn commented 3 years ago

Sorry for hijacking this issue but I stumbled with it and opening another seems too much.

I added riscv64 architecture to my settings.yml and later when trying to cross compile I got this:

gmp/6.1.2: WARN: Unknown 'riscv64' machine, Conan doesn't know how to translate it to the GNU triplet, please report at https://github.com/conan-io/conan/issues

Is there any hope that riscv64 arch could be added? Otherwise, I think it would restrict me from using AutoToolsBuildEnvironment right?

memsharded commented 3 years ago

Hi Pau @Hopobcn

Is the riscv64 a common documented architecture that could be useful for other Conan users? Or just your internal user convention?

In any case, we probably need a way to map custom user architectures in the new toolchains, we have already started to work in them.

Hopobcn commented 3 years ago

Hi, RISC-V is an open-source ISA that is gaining a lot of traction. It's being adopted for new developments. They have documentation in their webpage https://riscv.org/ and github groups https://github.com/riscv

There are 4 base ISA RV32I, RV64I, RV32E, RV128I. Then there are a handful of extensions that add functionality to the base ISA. To ease adoption the standard defines a base ISA + selected extensions (IMAFD, Zicsr, Zifencei) as a "general-purpose" ISA using the abbreviation RV32G or RV64G.

When I said riscv64 in my previous comment I was referring to RV64G.

In my case, I was preparing a conan POC for the company I work for. Problem is, being able to support riscv64 is essential req. Via upstream support or settings.yml modifications. If we were able to define/map our own custom architectures and still keep the compatibility with CCI, it would be awesome. Looking forward to it.

andreya108 commented 1 year ago

@memsharded We've added riscv64 manually to out settings.yml and both of build systems are ok, but not all:

ERROR: libcap/2.66@mobile/master: Error in generate() method, line 54
[15:48:17 ]    tc = AutotoolsToolchain(self)
[15:48:17 ]    ConanException: Unknown 'riscv64' machine, Conan doesn't know how to translate it to the GNU triplet, please report at  https://github.com/conan-io/conan/issues

Conan is badly missing archs riscv64 and riscv32 which are common names and known for compilers along with x86_64 and aarch64:

CXXFLAGS=-target riscv64-linux-gnu -pthread -fPIC -stdlib=libc++ -isystem /usr/lib/llvm-15/include/c++/v1 -isystem /usr/riscv64-linux-gnu/include
jcar87 commented 1 year ago

Hi @andreya108 - thanks for reporting this.

A couple of questions: are you cross-building from a different system, or building natively on the target machine? For different combinations of os and arch, what should the correct triples be?

Thanks!

andreya108 commented 1 year ago

@jcar87 We're always crossbuilding with clang from x86_64 to riscv64. riscv64 headers & libs & tools are installed with apt (ubuntu 22.04), here is docker recipe part:

RUN dpkg --add-architecture riscv64 && \
        apt-get update -y && \
        apt-get install -y \
        libc6-dev:riscv64 \
        crossbuild-essential-riscv64 \
        qemu-user qemu-user-static gcc-riscv64-linux-gnu binutils-riscv64-linux-gnu binutils-riscv64-linux-gnu-dbg \
        && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
        && apt-get autoremove -y \
        && apt-get clean

ENV QEMU_CMD "qemu-riscv64 -L /usr/riscv64-linux-gnu/"
ENV CROSSCOMPILE_SYSROOT "/usr/riscv64-linux-gnu"

For now we have only linux targets, but looks like Google is working under Android for RISC-V.

Here is commit to clang adding riscv support which can be used for guessing triples:

https://github.com/lowRISC/riscv-llvm/blob/master/0002-RISCV-Recognise-riscv32-and-riscv64-in-triple-parsin.patch

jcar87 commented 1 year ago

Hi @andreya108 thanks for your prompt reply.

In your case, since you are cross-building from a well known environment, you could use the following configuration setting that we have recently added. This could go in the conf section of your host profile: [conf] tools.gnu:host_triplet="riscv64-linux-gnu"



This will cause Conan to pass this triple when using the newer AutotoolsToolchain/Autotools integration. We'll look into adding the proper triples, but in the meantime, could you check if this works successfully in your case?

Thanks!
jcar87 commented 1 year ago

Hi @andreya108 thanks for your prompt reply.

In your case, since you are cross-building from a well known environment, you could use the following configuration setting that we have recently added. This could go in the conf section of your host profile:

[conf]
tools.gnu:host_triplet="riscv64-linux-gnu"

This will cause Conan to pass this triple when using the newer AutotoolsToolchain/Autotools integration. We'll look into adding the proper triples, but in the meantime, could you check if this works successfully in your case?

Thanks!

andreya108 commented 1 year ago

@jcar87 Thank you! I didn't know that trick!

andreya108 commented 1 year ago

@jcar87 Is there similar option for meson tools?

Error in build() method, line 31
self._meson_get_configured_module().build()
  while calling '_meson_get_configured_module', line 47
    return self.meson_get_configured_module(additional_opts)
  while calling 'meson_get_configured_module', line 235
    return ItcsMesonModule(self, self._meson_data.source_folder, additional_args)
  while calling '__init__', line 117
    meson_tools.write_cross_file('cross_file.txt', conanfile)
    ValueError: Unknown arch: riscv64