Skip to content

Fix macOS <-> Linux cross cflags resolution - #13230

Merged
jcar87 merged 4 commits into
conan-io:release/2.0from
sfackler:fix-macos-cross
Mar 14, 2023
Merged

jcar87 merged 4 commits into
conan-io:release/2.0from
sfackler:fix-macos-cross

Conversation

@sfackler

@sfackler sfackler commented Feb 24, 2023

Copy link
Copy Markdown
Contributor

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

CLAassistant commented Feb 24, 2023

Copy link
Copy Markdown

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

sfackler commented Mar 3, 2023

Copy link
Copy Markdown
Contributor Author

ping

@jcar87

jcar87 commented Mar 13, 2023

Copy link
Copy Markdown
Contributor

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

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

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