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 macOS <-> Linux cross cflags resolution #13230

Merged
merged 4 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions conan/tools/gnu/autotoolstoolchain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conan.internal import check_duplicated_generator
from conan.tools.apple.apple import apple_min_version_flag, to_apple_arch, apple_sdk_path
from conan.tools.apple.apple import apple_min_version_flag, is_apple_os, to_apple_arch, apple_sdk_path
from conan.tools.apple.apple import get_apple_sdk_fullname
from conan.tools.build import cmd_args_to_string, save_toolchain_args
from conan.tools.build.cross_building import cross_building
Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self, conanfile, namespace=None, prefix="/"):
# Build triplet
self._build = _get_gnu_triplet(os_build, arch_build, compiler=compiler)
# Apple Stuff
if os_build == "Macos":
if os_build == "Macos" and is_apple_os(conanfile):
# SDK path is mandatory for cross-building
sdk_path = apple_sdk_path(self._conanfile)
if not sdk_path:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,19 @@ def test_apple_min_os_flag():
assert expected in env["LDFLAGS"]


def test_crossbuild_from_macos_to_non_apple_os():
"""Check we are not adding Apple-specific flags
when the os_build is Macos, but we are targetting
a non-Apple OS (e.g. Linux, Android, QNX)"""
conanfile = ConanFileMock()
conanfile.settings = MockSettings({"os": "Android", "arch": "armv8"})
conanfile.settings_build = MockSettings({"os": "Macos", "arch": "armv8"})
be = AutotoolsToolchain(conanfile)
assert be.apple_min_version_flag == ''
assert be.apple_arch_flag is None
assert be.apple_isysroot_flag is None


def test_apple_isysrootflag():
"""Even when no cross building it is adjusted because it could target a Mac version"""
conanfile = ConanFileMock()
Expand Down