This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Update compiler-rt for cross-compilation with multiple architectures
AbandonedPublic

Authored by fjricci on Jul 14 2016, 3:39 PM.

Details

Summary

This allows for building compiler-rt to target multiple android
architectures, by using a set of -DTARGET_<arch>_CFLAGS cmake arguments.

Diff Detail

Event Timeline

fjricci updated this revision to Diff 64059.Jul 14 2016, 3:39 PM
fjricci retitled this revision from to [compiler-rt] Update compiler-rt for cross-compilation with multiple architectures.
fjricci updated this object.
fjricci added a subscriber: llvm-commits.
compnerd edited edge metadata.Jul 15 2016, 10:16 AM

The various architecture spellings are available in config-ix.cmake, and it seems nicer to re-use those. Note that the alternate that I proposed I just wrote up, didnt actually run, so it probably requires tweaking :-)

cmake/Modules/CompilerRTUtils.cmake
147

I think that this is better written as:

set(SAVED_CMAKE_REQUIRED_FLAS "${CMAKE_REQUIRED_FLAGS}")
foreach(arch ARM64;ARM32;X86;X86_64;MIPS32;MIPS64;S390X;WASM32;WASM64)
  set(CMAKE_REQUIRED_FLAGS "${SAVED_CMAKE_REQUIRED_FLAGS} ${${TARGET_${arch}_CFLAGS}}")
  foreach(spelling ${${arch}})
    check_symbol_exists(__${spelling}__ "" __${arch}_${spelling})
    if(__${arch}_${spelling})
      add_default_target_arch("${arch}")
      break()
    endif()
  endforeach()
endforeach()
fjricci abandoned this revision.Jul 15 2016, 10:36 AM

Multiple simultaneous architectures are not well-supported by cmake (for example, checks for existing headers only occur once).

beanz edited edge metadata.Jul 15 2016, 10:52 AM

In general we need to be moving compiler-rt into the direction of building one and only one architecture per CMake invocation except on platforms that support fat binaries, where we should support one target platform per invocation.

There is a lot of work to be done to get to that point, but it is the way to go so that we stop fighting with CMake trying to make it do things it isn't designed to do.

-Chris