This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Improve GetHostTriple for Windows/ARM configurations
ClosedPublic

Authored by mstorsjo on Aug 6 2021, 1:43 AM.

Details

Summary

In MSVC mode, CMake provides CMAKE_C_COMPILER_ARCHITECTURE_ID,
which should be accurate for what the compiler produces. Keep
the old CMAKE_C_SIZEOF_VOID_P based fallback in case this
doesn't provide matches.

In GCC/MinGW mode, CMake doesn't provide that. As we're trying to
guess the default host architecture, use CMAKE_HOST_SYSTEM_PROCESSOR
in combination with the existing CMAKE_C_SIZEOF_VOID_P check to
estimate whether it's x86/x86_64/arm/aarch64.

I made a MR to upstream CMake to make it provide
CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID for GCC and non-MSVC Clang
configurations too, in
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6432,
but I wouldn't want to start relying on that right away.

Diff Detail

Event Timeline

mstorsjo created this revision.Aug 6 2021, 1:43 AM
mstorsjo requested review of this revision.Aug 6 2021, 1:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2021, 1:43 AM
phosek accepted this revision.Aug 6 2021, 1:51 AM

LGTM

This revision is now accepted and ready to land.Aug 6 2021, 1:51 AM