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

meson: Add preliminary support for cross builds #6410

Closed

Conversation

kristofferkoch
Copy link

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

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the 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.

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.
@kristofferkoch
Copy link
Author

Jenkins seems to be failing because of a timeout.

endian = '{endian}'

[properties]
needs_exe_wrapper = true
Copy link
Contributor

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,
Copy link
Contributor

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}'
Copy link
Contributor

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}
Copy link
Contributor

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}]
Copy link
Contributor

@SSE4 SSE4 Mar 24, 2020

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'),
Copy link
Contributor

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)
Copy link
Contributor

@SSE4 SSE4 Mar 24, 2020

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")
Copy link
Contributor

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.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @kristofferkoch

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' \
Copy link
Member

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.

@KristianJerpetjon
Copy link

I couldnt push to this branch @kristofferkoch so i made a new PR #7075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Build Build helpers, build systems..
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants