Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions conan/tools/gnu/autotoolstoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)["triplet"]

sysroot = self._conanfile.conf.get("tools.build:sysroot")
sysroot = sysroot.replace("\\", "/") if sysroot is not None else None
self.sysroot_flag = "--sysroot {}".format(sysroot) if sysroot else None
if sysroot:
root = sysroot.replace("\\", "/")
compiler = self._conanfile.settings.get_safe("compiler")
self.sysroot_flag = f"--sysroot {root}" if compiler != "qcc" else f"-Wc,-isysroot {root}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the correct syntax is "-Wc,-isysroot,{root}". At least then the configuration went through and this is also how CMake passes the sysroot to qcc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, thanks for checking it, I overlooked that detail, I'll fix it.

else:
self.sysroot_flag = None

extra_configure_args = self._conanfile.conf.get("tools.gnu:extra_configure_args",
check_type=list,
default=[])
Expand Down
9 changes: 7 additions & 2 deletions conan/tools/gnu/gnutoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
self.triplets_info["build"] = _get_gnu_triplet(os_build, arch_build, compiler=compiler)

sysroot = self._conanfile.conf.get("tools.build:sysroot")
sysroot = sysroot.replace("\\", "/") if sysroot is not None else None
self.sysroot_flag = "--sysroot {}".format(sysroot) if sysroot else None
if sysroot:
root = sysroot.replace("\\", "/")
compiler = self._conanfile.settings.get_safe("compiler")
self.sysroot_flag = f"--sysroot {root}" if compiler != "qcc" else f"-Wc,-isysroot {root}"
else:
self.sysroot_flag = None

self.configure_args = {}
self.autoreconf_args = {"--force": None, "--install": None}
self.make_args = {}
Expand Down
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,21 @@ def test_sysrootflag():
assert expected in env["LDFLAGS"]


def test_sysrootflag_qnx():
"""Even when no cross building it is adjusted because it could target a Mac version"""
conanfile = ConanFileMock()
conanfile.conf.define("tools.build:sysroot", "/path/to/sysroot")
conanfile.settings = MockSettings(
{"compiler": "qcc",
"build_type": "Debug",
"os": "Linux",
"arch": "x86_64"})
conanfile.settings_build = conanfile.settings
be = AutotoolsToolchain(conanfile)
expected = "-Wc,-isysroot /path/to/sysroot"
assert be.sysroot_flag == expected


def test_custom_defines():
conanfile = ConanFileMock()
conanfile.conf.define("tools.apple:sdk_path", "/path/to/sdk")
Expand Down
15 changes: 15 additions & 0 deletions test/unittests/tools/gnu/test_gnutoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ def test_linker_scripts():
assert "-T'path_to_second_linker_script'" in env["LDFLAGS"]


def test_sysrootflag_qnx():
"""Even when no cross building it is adjusted because it could target a Mac version"""
conanfile = ConanFileMock()
conanfile.conf.define("tools.build:sysroot", "/path/to/sysroot")
conanfile.settings = MockSettings(
{"compiler": "qcc",
"build_type": "Debug",
"os": "Linux",
"arch": "x86_64"})
conanfile.settings_build = conanfile.settings
be = GnuToolchain(conanfile)
expected = "-Wc,-isysroot /path/to/sysroot"
assert be.sysroot_flag == expected


def test_update_or_prune_any_args(cross_building_conanfile):
# Issue: https://github.com/conan-io/conan/issues/12642
at = GnuToolchain(cross_building_conanfile)
Expand Down
Loading