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
meson: Add preliminary support for cross builds #6410
meson: Add preliminary support for cross builds #6410
Conversation
f0fd046
to
4c61ca2
Compare
This currently works for compiling glib for aarch64 on x86_64, but probably not for anything else yet. But it should be simpler to add more architectures when needed than the situation today.
4c61ca2
to
2229bd4
Compare
Jenkins seems to be failing because of a timeout. |
endian = '{endian}' | ||
|
||
[properties] | ||
needs_exe_wrapper = true |
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 don't think it should be always true. it's only for specific cases, e.g. for wine
or iOS/Android simulator/emulator.
environ_append.update({'CC': None, | ||
'CXX': None, | ||
'CFLAGS': None, | ||
'CXXFLAGS': None, |
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.
what about LDFLAGS?
c_args = [{cflags}] | ||
[binaries] | ||
c = '{cc}' | ||
cpp = '{cpp}' |
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.
we need to respect other tools if corresponding environment variables are set (e.g. AR, RANLIB, STRIP, etc.)
@@ -147,25 +185,37 @@ def configure(self, args=None, defs=None, source_dir=None, build_dir=None, | |||
"Release": "release"}.get(str(self.build_type), "") | |||
|
|||
build_type = "--buildtype=%s" % bt | |||
cross_option = None | |||
environ_append = {"PKG_CONFIG_PATH": pc_paths} |
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.
as I understand, it may go into cross file as well (** pkg_config_libdir**)
|
||
[properties] | ||
needs_exe_wrapper = true | ||
c_args = [{cflags}] |
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.
need to set c_link_args, cpp_args, cpp_link_args, sysroot as well
check the full list: https://mesonbuild.com/Builtin-options.html#page-description
@@ -118,6 +118,44 @@ def _get_dirs(self, source_folder, build_folder, source_dir, build_dir, cache_bu | |||
def flags(self): | |||
return defs_to_string(self.options) | |||
|
|||
def _configure_cross_compile(self, cross_filename, environ_append): | |||
cpu_translate = { | |||
'armv8': ('aarch64', 'aarch64', 'little'), |
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'd love to see more mapping of conan/meson supported architectures
https://mesonbuild.com/Reference-tables.html#cpu-families
env_build = AutoToolsBuildEnvironment(self._conanfile) | ||
with environment_append(env_build.vars): | ||
if use_auto_tools: | ||
env_build = AutoToolsBuildEnvironment(self._conanfile) |
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'd say AutoToolsBuildEnvironment are needed in both cases, otherwise, we're not setting all the flags correctly
@@ -71,60 +71,66 @@ def folders_test(self): | |||
'includedir': 'include', | |||
'cpp_std': 'none' | |||
} | |||
|
|||
build_dir = os.path.join(self.tempdir, "build") |
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'd expect most of the existing tests to stay unchanged, as they aren't using cross-building, and thus cross-file as well. and adding few tests specific for the cross-building to test newly added features.
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.
As this is changing a few things related cross-building, we will need to wait until the ongoing base changes in cross-building are merged and released: #5594
A ton of work has already been merged, and this will be released in Conan 1.24 next week. After that we will continue working in improving the build helpers, and this can be taken into account then.
Thanks very much for your contribution!
cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release' \ | ||
% (source_expected, build_expected, defs_to_string(defs)) | ||
build_expected = build_dir | ||
cmd_expected = 'meson "%s" "%s" --backend=ninja %s --buildtype=release --cross-file=%s' \ |
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.
As a general rule, new features in code shouldn't change existing tests, unless it is strictly considered a bug. Instead, please try to just add new tests for the new behavior.
I couldnt push to this branch @kristofferkoch so i made a new PR #7075 |
This currently works for compiling glib for aarch64 on x86_64,
but probably not for anything else yet. But it should be
simpler to add more architectures when needed than the situation
today. Improves #4529.
Changelog: (Fix): Make cross-compiling with meson work in some cases
develop
branch, documenting this one.Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.