Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] Force cross compilation #9808

Open
upsilona opened this issue Oct 11, 2021 · 4 comments
Open

[question] Force cross compilation #9808

upsilona opened this issue Oct 11, 2021 · 4 comments

Comments

@upsilona
Copy link

Hello everyone,
I have a question regarding the cross compilation detection in conan. Reading the code I saw we assume cross compilation is enabled if os and / or arch is different between host and build. I managed to embed a Linux SDK for several targets archs into a conan package of my own. However I face compilation issues for x86 / x86_64 because of missing compilation flags, due to conan not detecting my cross compilation scenario. I was wondering if we shouldn't add an environment variable to force cross compilation, for instance CONAN_CROSS_COMPILATION.
NB : The code I build using my SDK is not intended to run on the build machine. I updated my conan settings to ensure all the dependencies get build using my SDK, avoiding contamination.
Regards

@ericLemanissier
Copy link
Contributor

isn't this covered by the skip_x64_x86=True argument of tools.cross_building() ?

@SSE4
Copy link
Contributor

SSE4 commented Oct 13, 2021

I think it doesn't scale on recipe basis. perhaps, global override via conf or env var is required?
my guess is you may have an ARM Linux laptop and cross-compile for ARM board such as raspberry pi.
in this case conan won't detect cross-building (as both os and arch are the same), but actually it is.
same for x86 Linux desktop compiling for x86 board such as hackboard.
I think it's worth opening an issue for the conan client itself: https://github.com/conan-io/conan/issues/new/choose
(please try to desribe as much details as possible)

@jgsogo
Copy link
Contributor

jgsogo commented Oct 15, 2021

I'm moving this issue to Conan client repository. Right now cross-compilation is detected, but it might be worth being able to force it with some input.

@jgsogo jgsogo transferred this issue from conan-io/conan-center-index Oct 15, 2021
@steinerthomas
Copy link

steinerthomas commented Sep 8, 2023

Hi,
what's the status? Will there be a flag for forcing cross building in the future?

I'm facing an issue "cross-building" from x86_64 Debian10 (build server, default profile) to x86_64 Debian12 (target) when building the benchmark library:

$conan create recipes/benchmark/all benchmark/1.8.2@ -u -tf None -pr debian6412 -pr:b default -s:b build_type=RelWithDebInfo -s build_type=RelWithDebInfo

ERROR:

-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Error at CMakeLists.txt:299 (message):
  Failed to determine the source files for the regular expression backend
Full log
Exporting package recipe
benchmark/1.8.2 exports: File 'conandata.yml' found. Exporting it...
benchmark/1.8.2 exports: Copied 1 '.yml' file: conandata.yml
benchmark/1.8.2: The stored package has not changed
benchmark/1.8.2: Using the exported files summary hash as the recipe revision: 33859562c342e2d8e0a17918c1190fa2
benchmark/1.8.2: Exported revision: 33859562c342e2d8e0a17918c1190fa2
Configuration (profile_host):
[settings]
arch=x86_64
build_type=RelWithDebInfo
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[options]
[build_requires]
[env]
AR=x86_64-debian6412-linux-gnu-ar
AS=x86_64-debian6412-linux-gnu-as
CC=x86_64-debian6412-linux-gnu-gcc
CHOST=x86_64-debian6412-linux-gnu
CONAN_CMAKE_FIND_ROOT_PATH=/opt/x-tools/x86_64-debian6412-linux-gnu/x86_64-debian6412-linux-gnu/sysroot
CONAN_CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
CONAN_CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
CONAN_CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
CONAN_CMAKE_TOOLCHAIN_FILE=/opt/x-tools/x86_64-debian6412-linux-gnu/toolchain.cmake
CXX=x86_64-debian6412-linux-gnu-g++
LD=x86_64-debian6412-linux-gnu-ld
PATH=[/opt/x-tools/x86_64-debian6412-linux-gnu/bin]
RANLIB=x86_64-debian6412-linux-gnu-ranlib
STRIP=x86_64-debian6412-linux-gnu-strip
Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=RelWithDebInfo
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

benchmark/1.8.2: Forced build from source
Version ranges solved
    cmake/* versions found in 'cc-conan-local' remote
    Version range '>=3.16.3 <4' required by 'benchmark/1.8.2' resolved to 'cmake/3.27.1' in remote 'cc-conan-local'

Installing package: benchmark/1.8.2
Requirements
    benchmark/1.8.2 from 'cc-conan-local' - Cache
Packages
    benchmark/1.8.2:e7f09c57b624b2100ef636844c070bdce803af28 - Build
Build requirements
    cmake/3.27.1 from 'cc-conan-local' - Cache
Build requirements packages
    cmake/3.27.1:4db1be536558d833e52e862fd84d64d75c2b3656 - Cache

Installing (downloading, building) binaries...
cmake/3.27.1: Already installed!
cmake/3.27.1: Appending PATH environment variable: /home/thomas/.conan/data/cmake/3.27.1/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/bin
benchmark/1.8.2: Applying build-requirement: cmake/3.27.1
benchmark/1.8.2: WARN: Build folder is dirty, removing it: /home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28
benchmark/1.8.2: Copying sources to build folder
benchmark/1.8.2: Building your package in /home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28
benchmark/1.8.2: Generator txt created conanbuildinfo.txt
benchmark/1.8.2: Calling generate()
benchmark/1.8.2: Preset 'relwithdebinfo' added to CMakePresets.json. Invoke it manually using 'cmake --preset relwithdebinfo'
benchmark/1.8.2: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/build/RelWithDebInfo/generators/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=RelWithDebInfo'
benchmark/1.8.2: Aggregating env generators
benchmark/1.8.2: Calling build()
benchmark/1.8.2: CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/build/RelWithDebInfo/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/thomas/.conan/data/benchmark/1.8.2/_/_/package/e7f09c57b624b2100ef636844c070bdce803af28" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="RelWithDebInfo" "/home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/src"
-- Using Conan toolchain: /home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/build/RelWithDebInfo/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: C++ Standard 20 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is GNU 12.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/x-tools/x86_64-debian6412-linux-gnu/bin/x86_64-debian6412-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Failed to find LLVM FileCheck
-- Found Git: /usr/bin/git (found version "2.20.1")
-- git version: v0.0.0 normalized to 0.0.0
-- Google Benchmark version: 1.8.2
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST - Success
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Compiling and running to test HAVE_STD_REGEX
-- Performing Test HAVE_STD_REGEX -- compiled but failed to run
-- Compiling and running to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Error at CMakeLists.txt:299 (message):
  Failed to determine the source files for the regular expression backend


-- Configuring incomplete, errors occurred!
benchmark/1.8.2:
benchmark/1.8.2: ERROR: Package 'e7f09c57b624b2100ef636844c070bdce803af28' build failed
benchmark/1.8.2: WARN: Build folder /home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/build/RelWithDebInfo
ERROR: benchmark/1.8.2: Error in build() method, line 89
        cmake.configure()
        ConanException: Error 1 while executing cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/build/RelWithDebInfo/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/thomas/.conan/data/benchmark/1.8.2/_/_/package/e7f09c57b624b2100ef636844c070bdce803af28" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="RelWithDebInfo" "/home/thomas/.conan/data/benchmark/1.8.2/_/_/build/e7f09c57b624b2100ef636844c070bdce803af28/src"

My current workaround is to remove the cross_building check in the recipe.
conan-io/conan-center-index@246b029
Is there a better way?
I think it would also work to update my build server to Debian12.
UPDATE: I now use a Debian12 build-container, it compiles as expected.

This issue is being transferred. Timeline may not be complete until it finishes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants