This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Fix runtimes build for host Windows (default target)
ClosedPublic

Authored by krisb on Jun 15 2020, 1:51 PM.

Details

Summary

When building runtimes, the compiler name (e.g. clang, clang-cl) is set based on
CMAKE_SYSTEM_NAME passed to llvm_ExternalProject_Add() through CMAKE_ARGS argument.
This mechanism doesn't work well if the target is Windows host.
runtime_default_target()/builtin_default_target() doesn't provide a way
to specify CMAKE_SYSTEM_NAME and doesn't set it either.

This patch appends variables specified in RUNTIMES_CMAKE_ARGS/BUILTINS_CMAKE_ARGS
to CMAKE_ARGS argument of llvm_ExternalProject_Add() in the case of called
from runtime_default_target()/builtin_default_target() thus in particular
it allows passing CMAKE_SYSTEM_NAME whenever it is required.

As far as I can see from D73811 default target doesn't necessarily assume host.
So, this solution might be safer than D73811.

There is an alternative approach for this problem at D80866 (which looks
more vague and unclear).

Diff Detail

Event Timeline

krisb created this revision.Jun 15 2020, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2020, 1:51 PM

I definitely like this approach better. I would like to get @plotfi to sign off on this, but LGTM.

plotfi accepted this revision.Jun 16 2020, 3:19 PM

LGTM

This revision is now accepted and ready to land.Jun 16 2020, 3:19 PM
phosek accepted this revision.Jun 16 2020, 3:41 PM

LGTM, I like this, thanks! I think we should use this approach for other flags as well, e.g. RUNTIMES_LLVM_ENABLE_RUNTIMES.

compnerd accepted this revision.Jun 16 2020, 4:38 PM
krisb added a comment.Jun 20 2020, 1:44 AM

@plotfi @compnerd @phosek Thank you all for reviewing this!

This revision was automatically updated to reflect the committed changes.