Skip to content

[android] Add support for building the toolchain for ARMv7 #34160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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