Skip to content
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

[SR-1360] Android: Possible to lower minimum API level? #43969

Closed
swift-ci opened this issue Apr 29, 2016 · 4 comments
Closed

[SR-1360] Android: Possible to lower minimum API level? #43969

swift-ci opened this issue Apr 29, 2016 · 4 comments
Labels
Android Platform: Android task

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1360
Radar None
Original Reporter ewmailing (JIRA User)
Type Task
Additional Detail from JIRA
Votes 1
Component/s
Labels Task, Android
Assignee None
Priority Medium

md5: 9bbb4091c91b7b52c7f18d792ccac188

Issue Description:

The current requirement is API 21. I was wondering if we can make this lower. The problem with Android is nobody updates.

http://developer.android.com/about/dashboards/index.html

By the current stats, for example, if we could go from 5.0 (API 21) to just 4.4 (API 19), we get of potential devices 33.4% back.

I suggest using this bug/thread to document what the compatibility issues are:

I’ve been made aware of two problems so far: log2f and getline.

I don’t currently have any info on getline, but log2f is available in API 19 (Not sure if it was introduced in API 19 or slightly before. It was not in API 14.)

I am also aware of a cheat for log2f that developers have exploited. It is defined as an inline function in API 19. So you can actually build against API 19 in this case and still to deploy to older versions.

@swift-ci
Copy link
Collaborator Author

Comment by Sam Khawase (JIRA)

Paging @modocache and udiWertheimer (JIRA User)

I've lowered the Android API level version to API level 16 and tried to build Swift.

vagrant@ubuntu1510:/vagrant$ ./swift/utils/build-script -R \
--android \
--android-ndk /vagrant/android-sdk-linux/ndk-bundle \
--android-api-level 16 \
--android-icu-uc /vagrant/libiconv-libicu-android/armeabi-v7a \
--android-icu-uc-include /vagrant/libiconv-libicu-android/armeabi-v7a/icu/source/common \
--android-icu-i18n /vagrant/libiconv-libicu-android/armeabi-v7a \
--android-icu-i18n-include /vagrant/libiconv-libicu-android/armeabi-v7a/icu/source/i18n \
--android-ndk-gcc-version 4.8

Building the standard library for: swift-test-stdlib-linux-x86_64 swift-test-stdlib-android-armv7

cmark: using standard linker
++ cmake_config_opt cmark
++ product=cmark
++ [[ Ninja == \X\c\o\d\e ]]
+ /usr/bin/cmake --build /vagrant/build/Ninja-ReleaseAssert/cmark-linux-x86_64 -- -j4 all
ninja: no work to do.
llvm: using standard linker
++ cmake_config_opt llvm
++ product=llvm
++ [[ Ninja == \X\c\o\d\e ]]
+ /usr/bin/cmake --build /vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64 -- -j4 all
ninja: no work to do.
++ uname -s
+ [[ Linux == \D\a\r\w\i\n ]]
+ HOST_CXX_HEADERS_DIR=/usr/include/c++
+ BUILT_CXX_INCLUDE_DIR=/vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include
+ echo 'symlinking the system headers (/usr/include/c++) into the local clang build directory (/vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include).'
symlinking the system headers (/usr/include/c++) into the local clang build directory (/vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include).
+ ln -s -f /usr/include/c++ /vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include
swift: using standard linker
++ cmake_config_opt swift
++ product=swift
++ [[ Ninja == \X\c\o\d\e ]]
+ /usr/bin/cmake --build /vagrant/build/Ninja-ReleaseAssert/swift-linux-x86_64 -- -j4 all swift-test-stdlib-linux-x86_64 swift-test-stdlib-android-armv7
[8/187] Building CXX object stdlib/public/runtime/CMakeFiles/swiftRuntime-android-armv7.dir/ProtocolConformance.cpp.o
FAILED: /usr/bin/clang++   -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-stack-protector -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Werror=date-time -std=c++11 -fcolor-diagnostics -ffunction-sections -fdata-sections -Wdocumentation -Wimplicit-fallthrough -Wunreachable-code -Woverloaded-virtual -O3  -Istdlib/public/runtime -I/vagrant/swift/stdlib/public/runtime -I/vagrant/swift/include -Iinclude -I/vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include -I/vagrant/llvm/include -I/vagrant/build/Ninja-ReleaseAssert/llvm-linux-x86_64/tools/clang/include -I/vagrant/llvm/tools/clang/include -I/vagrant/cmark/src -I/vagrant/build/Ninja-ReleaseAssert/cmark-linux-x86_64/src    -UNDEBUG  -fno-exceptions -fno-rtti -Wglobal-constructors -Wexit-time-destructors -fvisibility=hidden -DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=1 -target armv7-none-linux-androideabi -isysroot /vagrant/android-sdk-linux/ndk-bundle/platforms/android-16/arch-arm --sysroot=/vagrant/android-sdk-linux/ndk-bundle/platforms/android-16/arch-arm -B /vagrant/android-sdk-linux/ndk-bundle/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ -O2 -g0 -UNDEBUG -I/vagrant/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++/libcxx/include -I/vagrant/android-sdk-linux/ndk-bundle/sources/cxx-stl/llvm-libc++abi/libcxxabi/include -I/vagrant/android-sdk-linux/ndk-bundle/sources/android/support/include -MMD -MT stdlib/public/runtime/CMakeFiles/swiftRuntime-android-armv7.dir/ProtocolConformance.cpp.o -MF stdlib/public/runtime/CMakeFiles/swiftRuntime-android-armv7.dir/ProtocolConformance.cpp.o.d -o stdlib/public/runtime/CMakeFiles/swiftRuntime-android-armv7.dir/ProtocolConformance.cpp.o -c /vagrant/swift/stdlib/public/runtime/ProtocolConformance.cpp
/vagrant/swift/stdlib/public/runtime/ProtocolConformance.cpp:287:31: warning: declaration requires a global constructor [-Wglobal-constructors]
static Lazy<ConformanceState> Conformances;
                              ^~~~~~~~~~~~
/vagrant/swift/stdlib/public/runtime/ProtocolConformance.cpp:362:50: error: use of undeclared identifier 'RTLD_NOLOAD'
    handle = dlopen(info->dlpi_name, RTLD_LAZY | RTLD_NOLOAD);
                                                 ^
/vagrant/swift/stdlib/public/runtime/ProtocolConformance.cpp:397:3: error: use of undeclared identifier 'dl_iterate_phdr'
  dl_iterate_phdr(_addImageProtocolConformances, &inspectArgs);
  ^
1 warning and 2 errors generated.
[8/187] Building CXX object stdlib/public/runtime/CMakeFiles/swiftRuntime-linux-x86_64.dir/HeapObject.cpp.o
/vagrant/swift/stdlib/public/runtime/HeapObject.cpp:228:43: warning: declaration requires a global constructor [-Wglobal-constructors]
static Lazy<MetadataCache<BoxCacheEntry>> Boxes;
                                          ^~~~~
1 warning generated.
ninja: build stopped: subcommand failed.
./swift/utils/build-script: command terminated with a non-zero exit status 1, aborting  

So the main issue here is the RTLD_NOLOAD flag and dl_iterate_phdr that was added to NDK in r10c/ JellyBean API.

IMO we need to find an alternative to do the dlopen for pre API 21. Do you guys have any pointers?

@swift-ci
Copy link
Collaborator Author

Comment by Eric Wing (JIRA)

I'm curious what Swift does with this feature (why it is needed). I'm a little concerned that this kind of feature is bad to assume for cross-platform support as not every platform allows dynamic libraries. (cough cough iOS until recently). And even if they do, the functionality is always platform specific. Like is there an equivalent for dl_iterate_phdr for Windows?

@Dante-Broggi
Copy link
Contributor

Is this resolved, or no longer being considered? If either, this should be closed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@finagolfin
Copy link
Contributor

This has been open for so long and no work that I know of has been done on it. Further, the current Android NDK 24 only supports back to API 19, so pretty soon API 21 will be the minimum supported API, and that's what it has been in Swift for years and what the community CI tests.

@compnerd, I think you can close this after six years as something that won't be done.

@keith keith closed this as completed May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Platform: Android task
Projects
None yet
Development

No branches or pull requests

4 participants