-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[APR] Support for cross-building using cache file #17609
Conversation
Hi @swebb2066, thank you for your contribution. For completion, could you attach a log to the PR description that shows the error that you get when trying to cross-build this recipe (without these changes)? My understanding is that when Thanks! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very nice solution to a tricky problem. Thank you!
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This pull request has been automatically closed because it has not had recent activity. Thank you for your contributions. |
@prince-chrismc Could you please reopen this - it just needs a second reviewer. |
I am no longer involved in the Conan project So i unfortunately can't help. However I do see questions from the team #17609 (comment) that have not been answered so you might what to explain these changes in more detail if you'd like to get this moving |
This comment has been minimized.
This comment has been minimized.
I answered this by adding the log in an edit to the PR. In summary, using the command:
So this understanding is not correct, |
Conan v1 pipeline ✔️All green in build 2 (
Conan v2 pipeline ✔️
All green in build 2 ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just checked it for Conan 2 and it's working too:
$ conan create . --version 1.7.4 -pr:h cross
...
======== Input profiles ========
Profile host:
[settings]
arch=armv7
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux
[options]
boost/*:bzip2=False
boost/*:shared=False
boost/*:zlib=False
log4cxx/*:shared=True
yaml-cpp/*:shared=False
[conf]
tools.gnu:host_triplet=arm-linux-gnueabihf
[buildenv]
AR=arm-linux-gnueabihf-ar
AS=arm-linux-gnueabihf-as
CC=arm-linux-gnueabihf-gcc
CXX=arm-linux-gnueabihf-g++
CXXCC=arm-linux-gnueabihf-cpp
LD=arm-linux-gnueabihf-ld
RANLIB=arm-linux-gnueabihf-ranlib
STRIP=arm-linux-gnueabihf-strip
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=11
os=Linux
....
apr/1.7.4: package(): Packaged 41 '.h' files
apr/1.7.4: package(): Packaged 3 files: LICENSE, apr-1-config, libtool
apr/1.7.4: package(): Packaged 1 '.a' file: libapr-1.a
apr/1.7.4: package(): Packaged 1 '.exp' file: apr.exp
apr/1.7.4: package(): Packaged 1 '.mk' file: apr_rules.mk
apr/1.7.4: package(): Packaged 1 '.sh' file: mkdir.sh
apr/1.7.4: package(): Packaged 2 '.awk' files: make_var_export.awk, make_exports.awk
apr/1.7.4: Created package revision 2fa96a8ace312b66d276862dbb33e02f
apr/1.7.4: Package 'a9facdc916a89b51805165331047fa4dca273ad3' created
apr/1.7.4: Full package reference: apr/1.7.4#d1ced664417e992ee2cfe16d40e9d195:a9facdc916a89b51805165331047fa4dca273ad3#2fa96a8ace312b66d276862dbb33e02f
apr/1.7.4: Package folder /root/.conan2/p/b/apr8171acf48b1ae/p
WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X:
WARN: deprecated: 'env_info' used in: apr/1.7.4
I'm getting an error running the test_package but I'm sure I'm missing some CFLAGS injected via profile:
gmake[2]: Warning: File 'CMakeFiles/test_package.dir/flags.make' has modification time 1.2 s in the future
[ 50%] Building C object CMakeFiles/test_package.dir/test_package.c.o
In file included from /root/.conan2/p/b/apr8171acf48b1ae/p/include/apr_version.h:130,
from /home/develop/conan-center-index/recipes/apr/all/test_package/test_package.c:1:
/root/.conan2/p/b/apr8171acf48b1ae/p/include/apr.h:381:10: error: unknown type name ‘off64_t’
381 | typedef off64_t apr_off_t;
| ^~~~~~~
gmake[2]: *** [CMakeFiles/test_package.dir/build.make:76: CMakeFiles/test_package.dir/test_package.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/test_package.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
ERROR: apr/1.7.4 (test package): Error in build() method, line 21
cmake.build()
ConanException: Error 2 while executing
Without this fix, we got a fast error:
checking for mprotect... yes
checking for MAP_ANON in sys/mman.h... yes
checking for /dev/zero... configure: error: cannot check for file existence when cross compiling
apr/1.7.4: ERROR:
Package 'a9facdc916a89b51805165331047fa4dca273ad3' build failed
apr/1.7.4: WARN: Build folder /root/.conan2/p/b/apr939632588d82c/b/build-release
ERROR: apr/1.7.4: Error in build() method, line 114
autotools.configure()
ConanException: Error 1 while executing
cc @jcar87
The vast majority of projects that use autotools and make use of the In that regard, apr cannot be cross-compiled by traditional means, and the only fallback is to use a cache file - so this makes apr a bit unique in this sense (have not encountered a case similar to this in conan center so far for a library that is built with autotools). Indeed the only way to cross-compile that is documented by upstream is by pre-empting the configuration checks with a cache file that needs to be generated on the target system. I can see there are some commits/issues upstream dealing with some of the quirks: The problem with conan center bundling pre-generated cache files, is that they are too "wide" a net to cast - some things are very specific to the build environment (I can see some absolute paths on the machine they were generated on) - and some things may not necessarily be "universally" true - for example, some are checks on headers that may or may not be available. With @franramirez688 we have identified about 5 variables coming from checks for a cross-build - I think that narrows it down quite a lot, and if we can assume they are true in the general case, we can happily pass those to configure, rather than an entire pre-generated cache file. On the other hand, preserving the ability to do is useful, but it would be up to the user to generate them and provide one that suits their needs. |
closed in favour of #24329 but please comment if there are any further issues |
The APR configure.in script makes extensive (30 instances) use of AC_TRY_RUN (to determine system capabilities) and checks for /dev/zero. These runtime checks only work when run on the host so the configure script will fail when cross compiling unless the relevant configuration variables are provided in a cache file or on the command line or in an environment variable.
The configuration variable values are most easily determined by running the configure script on a host system using:
./configure --cache-file={gnu_host_triplet}.cache
and then removing the 'precious' autoconf variables:
ac_cv_env_*
The generated cache file can be repeatedly used to cross-compile to the targeted host system by including it with the recipe data.
The default targeted host system name can be overriden in the profile using (for example).
This PR assumes the generated cache file is stored in the 'cross_build' directory.
Using the command:
conan create . apr/1.7.4@ -pr:h arm-linux-gnueabihf -pr:b default
on the master branch conanfile.py with the validate() removed results in:
omitting a long list of checks ....