Skip to content

Commit

Permalink
[android] Add support for building the toolchain for ARMv7
Browse files Browse the repository at this point in the history
  • Loading branch information
finagolfin committed Oct 3, 2020
1 parent 72b6a00 commit f7576a7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions cmake/modules/AddSwift.cmake
Expand Up @@ -291,6 +291,16 @@ function(_add_host_variant_c_compile_flags target)
target_compile_options(${target} PRIVATE -march=core2)
endif()
endif()

# The LLVM backend is built with these defines on most 32-bit platforms,
# llvm/llvm-project@66395c9, which can cause incompatibilities with the Swift
# frontend if not built the same way.
if("${SWIFT_HOST_VARIANT_ARCH}" MATCHES "armv6|armv7|i686" AND
NOT (SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID AND SWIFT_ANDROID_API_LEVEL LESS 24))
target_compile_definitions(${target} PRIVATE
_LARGEFILE_SOURCE
_FILE_OFFSET_BITS=64)
endif()
endfunction()

function(_add_host_variant_link_flags target)
Expand Down
2 changes: 1 addition & 1 deletion lib/ClangImporter/ImportType.cpp
Expand Up @@ -556,7 +556,7 @@ namespace {
if (size > 4096)
return Type();

SmallVector<TupleTypeElt, 8> elts{size, elementType};
SmallVector<TupleTypeElt, 8> elts{static_cast<size_t>(size), elementType};
return TupleType::get(elts, elementType->getASTContext());
}

Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/runtime/Float16Support.cpp
Expand Up @@ -29,7 +29,7 @@

// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
// provide shims in that case.
#if (defined(ANDROID) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
((defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))

#include "../SwiftShims/Visibility.h"
Expand Down
4 changes: 4 additions & 0 deletions utils/build-script-impl
Expand Up @@ -454,6 +454,10 @@ function set_build_options_for_host() {
SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
llvm_target_arch="AArch64"
;;
android-armv7)
SWIFT_HOST_TRIPLE="armv7-unknown-linux-androideabi"
llvm_target_arch="ARM"
;;
linux-armv6)
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
llvm_target_arch="ARM"
Expand Down

0 comments on commit f7576a7

Please sign in to comment.