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

Conversation

sfackler
Copy link
Contributor

@sfackler sfackler commented Feb 24, 2023

Changelog: Fix: Fix flags passed by AutotoolsToolchain when cross compiling from macOS to a non-Apple OS.
Docs: Omit

Fixes #13219

  • 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.

@CLAassistant
Copy link

CLAassistant commented Feb 24, 2023

CLA assistant check
All committers have signed the CLA.

@sfackler sfackler changed the title Fix macOS -> Linux cross cflag resolution Fix macOS <-> Linux cross cflags resolution Feb 24, 2023
@sfackler sfackler changed the base branch from develop2 to release/2.0 March 1, 2023 16:48
@sfackler
Copy link
Contributor Author

sfackler commented Mar 3, 2023

ping

@jcar87
Copy link
Contributor

jcar87 commented Mar 13, 2023

Hi @sfackler, thanks so much for your detailed report and for opening this PR.

Indeed I believe the logic was not robust enough to account for the fact that you can target Linux from macOS.

I have made a small fix to your PR - I believe the conditional should cover the case where os_build is MacOS, and the target OS is one of the Apple operating systems.

  • The call to apple_sdk_path() has a call to xcrun, which is a utility only available on macOS - thus, the conditional should cover that case.
  • The flags -isysroot (specifically pointing to an Apple-provided SDK) and -arch carry two implications: that the sysroot is an Apple provided SDK (and thus, the os_host is an Apple one), and that the compiler accepts the -arch flag (clang or AppleClang, although we are not specifically checking for this condition).

Note for @czoido: there's a chance this doesn't fully cover the case of targetting iOS from Linux (see https://github.com/tpoechtrager/cctools-port) - but this PR at least doesn't prevent that :D

@jcar87 jcar87 requested a review from czoido March 13, 2023 16:03
@jcar87 jcar87 added this to the 2.0.2 milestone Mar 13, 2023
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.

It would be great to add a test for this.

@jcar87 jcar87 merged commit f8e5abf into conan-io:release/2.0 Mar 14, 2023
franramirez688 added a commit to franramirez688/conan that referenced this pull request Mar 26, 2024
memsharded pushed a commit that referenced this pull request Mar 27, 2024
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] AutotoolsToolchain uses the build compiler rather than host compiler
6 participants