This is an archive of the discontinued LLVM Phabricator instance.

Add manually overriding of the darwin SDK version
ClosedPublic

Authored by vchuravy on Mar 29 2020, 6:43 PM.

Details

Summary

When doing cross-compilation from Linux to MacOS we don't have
access to have access to xcodebuild and therefore need a way
to set the SDK version from the outside.

Fixes https://reviews.llvm.org/D68292#1853594 for me.

Diff Detail

Event Timeline

vchuravy created this revision.Mar 29 2020, 6:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2020, 6:43 PM
Herald added subscribers: Restricted Project, mgorny. · View Herald Transcript
vchuravy added a subscriber: Restricted Project.Mar 29 2020, 6:44 PM
delcypher requested changes to this revision.Mar 29 2020, 6:56 PM
delcypher added inline comments.
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
47

I do not want to support a cached SDK version. A variable that if set provides an override is fine but CMake's caching causes far too many problems already that I don't want a new one introduced.

So something like this...

if (DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION)
  message(WARNING "Overriding ${sdk_name} SDK version to ${DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION}")
  set(${var} "${DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION}")
  return()
endif()

I'd consider a reasonable compromise.

Then in your CMake invocations you can provide something like -DDARWIN_macosx_OVERRIDE_SDK_VERSION=10.12.

82

You deleted a comment where I explicitly stated we do not want to use the cache. This goes completely against that. Caching the SDK version will create too many problems.

This revision now requires changes to proceed.Mar 29 2020, 6:56 PM
delcypher added inline comments.Mar 29 2020, 6:58 PM
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
47

Sorry that should be

if (DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION)
  message(WARNING "Overriding ${sdk_name} SDK version to ${DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION}")
  set(${var} "${DARWIN_${sdk_name}_OVERRIDE_SDK_VERSION}" PARENT_SCOPE)
  return()
endif()
vchuravy updated this revision to Diff 253481.Mar 29 2020, 8:42 PM

Allow for manually specifying the darwin SDK version

vchuravy marked 4 inline comments as done.Mar 29 2020, 8:44 PM
vchuravy added inline comments.
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
47

Thanks! Manually overriding is fine for my use-case.

vchuravy retitled this revision from Add caching to darwin SDK version lookup to Add manually overriding of the darwin SDK version.Mar 29 2020, 8:44 PM
delcypher accepted this revision.Mar 30 2020, 11:46 AM

@vchuravy LGTM. Just to note an alternative to this patch would be to implement a "barebones" version of xcrun that implements enough functionality to report the SDK to CMake. I think the compromise we came to is fine for now. If this patch becomes a maintenance burden in the future then we may need to revisit this.

This revision is now accepted and ready to land.Mar 30 2020, 11:46 AM
This revision was automatically updated to reflect the committed changes.
vchuravy marked an inline comment as done.