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

fix: sysroot property #16011

Open
wants to merge 4 commits into
base: develop2
Choose a base branch
from

Conversation

ErniGH
Copy link
Contributor

@ErniGH ErniGH commented Apr 3, 2024

Changelog: Fix: Handle tools.build:sysroot on Meson toolchain
Docs: https://github.com/conan-io/docs/pull/XXXX

Close: #14987

I added the sys_root to the Meson properties and the --sysroot=sys_root flag on c_args, cpp_args, c_link_args and cpp_link_args.

Comment on lines +402 to +406
self.properties["sys_root"] = sys_root
self.c_args.append("--sysroot=" + sys_root)
self.cpp_args.append("--sysroot=" + sys_root)
self.c_link_args.append("--sysroot=" + sys_root)
self.cpp_link_args.append("--sysroot=" + sys_root)
Copy link
Member

Choose a reason for hiding this comment

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

If sys_root is a property, does it still need to be added as a flag? Wouldn't Meson take care of that automatically?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it looks weird. I'm going to figure out how Meson manages this attribute because I think that it should automatically inject that one.

Copy link
Member

Choose a reason for hiding this comment

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

It's needed: https://mesonbuild.com/Cross-compilation.html#properties

Since 0.52.0 The sys_root property may point to the root of the host system path (the system that will run the compiled binaries). This is used internally by Meson to set the PKG_CONFIG_SYSROOT_DIR environment variable for pkg-config. If this is unset the host system is assumed to share a root with the build system.

The sys_root property only configures the PKG_CONFIG_SYSROOT_DIR, nothing more.

But how Meson users manage --sysroot then?

They pass to c_flags and cxx_flags:


On the other hand, Conan users could have it defined in tools.build:cflags and so on.

Comment on lines 403 to 406
# self.c_args.append("--sysroot=" + sys_root)
# self.cpp_args.append("--sysroot=" + sys_root)
# self.c_link_args.append("--sysroot=" + sys_root)
# self.cpp_link_args.append("--sysroot=" + sys_root)
Copy link
Member

Choose a reason for hiding this comment

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

These are then unnecessary, and Meson will manage with the property? (recall to remove this code, you can put a comment like # property sys_root is enough, not necessary to define cxx flags

Comment on lines 365 to 368
assert re.search(r"c_args =.+--sysroot=/my/new/sysroot/path.+", conan_meson)
assert re.search(r"c_link_args =.+--sysroot=/my/new/sysroot/path.+", conan_meson)
assert re.search(r"cpp_args =.+--sysroot=/my/new/sysroot/path.+", conan_meson)
assert re.search(r"cpp_link_args =.+--sysroot=/my/new/sysroot/path.+", conan_meson)
Copy link
Member

Choose a reason for hiding this comment

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

Who is adding this to the file then?

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@memsharded memsharded added this to the 2.4.0 milestone May 8, 2024
@memsharded
Copy link
Member

Assigning this PR to @franramirez688 for Conan 2.4, otherwise it will slip

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

Successfully merging this pull request may close these issues.

[bug] MesonToolchain does not handle tools.build:sysroot
4 participants