Repository navigation
Fix cross compiling on Apple - #2882
Conversation
mkmkme
left a comment
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
Both changes look right for a macOS → Linux cross build and don't affect Linux hosts. Two suggestions inline: backport the upstream fix for cpu_features.cmake so the x86 check is covered too, and correct the root cause in the tblgen comment.
| if (OS_LINUX AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)" AND NOT NO_ARMV81_OR_HIGHER) | ||
| # `OS_LINUX` follows the target system, so a Darwin host cross-compiling for Linux matches it too. `/proc/cpuinfo` exists only on a | ||
| # Linux host, and host tools in that cross build are compiled for the Mac rather than with the target `-march`. | ||
| if (OS_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)" AND NOT NO_ARMV81_OR_HIGHER) |
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
Upstream fixed the same thing in ClickHouse#131330 (merge 88d8610fdb13). It also adds CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" to the x86 check in the ARCH_AMD64 branch, which still greps /proc/cpuinfo here, so an Intel Mac building an amd64 Linux target would still fail at configure. How about backporting it with git cherry-pick --no-commit -m1 88d8610fdb13 instead? That covers both checks and keeps us in sync with upstream.
There was a problem hiding this comment.
Yeah, it's definitely better.
| endif() | ||
|
|
||
| if (APPLE) | ||
| # Homebrew libc++ does not include <sys/resource.h>, which declares |
There was a problem hiding this comment.
🤖 [Posted by an LLM agent on behalf of @mkmkme]
The cause isn't Homebrew libc++. llvm/llvm-project#142733 removed an include that brought in PRIO_DARWIN_THREAD/PRIO_DARWIN_BG indirectly, and llvm/llvm-project#208065 fixed it by including <sys/resource.h> in CrashRecoveryContext.cpp. Our LLVM submodule predates that fix; upstream's LLVM 23 bump has it. Could the comment reference llvm#208065 so the workaround can be dropped on the next LLVM bump? Optionally, the -include could also be limited to CrashRecoveryContext.cpp via set_source_files_properties rather than applied to every C++ file.
|
Add partial backport of ClickHouse#131330, add include in |
|
Do not need to port in later versions. Partially backport, partially fixed in newer LLVM version. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix cross compiling on Apple
Documentation entry for user-facing changes
Allow to compile Linux binary on Apple hosts.
CI/CD Options
Exclude tests:
Regression jobs to run: