Skip to content

Fix build for android #332

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

Closed
wants to merge 9 commits into from
Closed

Conversation

ephemer
Copy link
Contributor

@ephemer ephemer commented Jan 18, 2018

As mentioned in #312, this fixes the build for Android and works on both Mac and Linux with the following CMake invocation:

cmake -G Ninja \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_SYSTEM_NAME=Android \
    -DCMAKE_SYSROOT=$ANDROID_STANDALONE_TOOLCHAIN/sysroot \
    -DENABLE_SWIFT=YES \
    -DBUILD_SHARED_LIBS=YES \
    -DCMAKE_SWIFT_COMPILER=$SWIFT_INSTALLATION_PATH/usr/Darwin/swiftc \
    -DENABLE_TESTING=OFF \
    -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \
    -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
    $SWIFT_SOURCE_PATH/swift-corelibs-libdispatch

@@ -30,6 +30,8 @@
#include <os/linux_base.h>
#endif

#include <string.h>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be wrapped with an #if ANDROID

@@ -38,6 +38,10 @@ function(add_swift_library library)
endforeach()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Android)
list(APPEND flags -sdk;${CMAKE_SYSROOT})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably makes sense to always add the sysroot?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that we should always add the sysroot here.

@@ -13,7 +13,7 @@ function(add_swift_library library)
list(APPEND flags -emit-library)

if(ASL_TARGET)
list(APPEND FLAGS -target;${ASL_TARGET})
list(APPEND flags -target;${ASL_TARGET})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently CMake variable names are case sensitive. This is a typo introduced in an earlier PR

@MadCoder MadCoder requested a review from compnerd February 27, 2018 07:16
@MadCoder
Copy link
Contributor

@compnerd you did most of the cmake porting, can you review the change please?

@@ -30,6 +30,10 @@
#include <os/linux_base.h>
#endif

#ifdef __ANDROID__
#include <string.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this can be done unconditionally.

@@ -38,6 +38,10 @@ function(add_swift_library library)
endforeach()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Android)
list(APPEND flags -sdk;${CMAKE_SYSROOT})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that we should always add the sysroot here.

@compnerd
Copy link
Member

compnerd commented May 4, 2018

Can you please squash the changes into a single commit?

@@ -30,6 +30,8 @@
#include <os/linux_base.h>
#endif


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the empty line

@@ -93,7 +95,7 @@ function(get_swift_host_arch result_var_name)
set("${result_var_name}" "s390x" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6l")
set("${result_var_name}" "armv6" PARENT_SCOPE)
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^armv7")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want the same for armv6l above?

@@ -20,4 +20,8 @@
#define _Static_assert(...)
#endif

#ifndef TRASHIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly sure this has been moved to internal.h already in a previous PR, please remove.

@MadCoder
Copy link
Contributor

MadCoder commented May 4, 2018

Also please squash in a single commit.

dgrove-oss and others added 5 commits May 15, 2018 12:35
Seek to avoid spurious test timeouts in Swift CI by
raising limit for individual test execution from 30
seconds to 120 seconds.
This is the first commit of several to bring libdispatch support up to date on FreeBSD
@MadCoder
Copy link
Contributor

this branch seems completely broken :/

@Fischiii
Copy link

Fischiii commented Jul 3, 2018

@MadCoder can you elaborate? We are successfully working with this fork, since we need the android support. Would be nice to have this merged.

@compnerd
Copy link
Member

compnerd commented Dec 1, 2018

I'm going to close this PR for now. It no longer cleanly applies. I believe that libdispatch builds for android currently, but, if it does not, that is certainly that should be addressed.

@compnerd compnerd closed this Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants