-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[android] A few tweaks for native compilation and to get more tests working #27167
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -262,6 +262,8 @@ macro(configure_sdk_unix name architectures) | |
| set(_swift_android_prebuilt_build linux-x86_64) | ||
| elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) | ||
| set(_swift_android_prebuilt_build Windows-x86_64) | ||
| elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL Android) | ||
| # When building natively on an Android host, there's no NDK or prebuilt suffix. | ||
|
||
| else() | ||
| message(SEND_ERROR "cannot cross-compile to android from ${CMAKE_HOST_SYSTEM_NAME}") | ||
| endif() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,8 @@ std::string | |
| toolchains::GenericUnix::sanitizerRuntimeLibName(StringRef Sanitizer, | ||
| bool shared) const { | ||
| return (Twine("libclang_rt.") + Sanitizer + "-" + | ||
| this->getTriple().getArchName() + ".a") | ||
| this->getTriple().getArchName() + | ||
| (this->getTriple().isAndroid() ? "-android" : "") + ".a") | ||
|
||
| .str(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,6 +282,10 @@ module SwiftGlibc [system] { | |
| module sys { | ||
| export * | ||
|
|
||
| module cdefs { | ||
| header "${GLIBC_ARCH_INCLUDE_PATH}/sys/cdefs.h" | ||
| export * | ||
| } | ||
|
||
| module file { | ||
| header "${GLIBC_ARCH_INCLUDE_PATH}/sys/file.h" | ||
| export * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,8 @@ | |
| // RUN: %target-swiftc_driver -driver-print-jobs -module-name=ThisModule -wmo -num-threads 4 %S/Inputs/main.swift %s -c | %FileCheck -check-prefix=OBJECT %s | ||
| // RUN: cd %t && %target-swiftc_driver -parseable-output -module-name=ThisModule -wmo -num-threads 4 %S/Inputs/main.swift %s -c 2> %t/parseable-output | ||
| // RUN: cat %t/parseable-output | %FileCheck -check-prefix=PARSEABLE %s | ||
| // RUN: cd %t && env TMPDIR=/tmp %swiftc_driver -driver-print-jobs -module-name=ThisModule -wmo -num-threads 4 %S/Inputs/main.swift %s -o a.out | %FileCheck -check-prefix=EXEC %s | ||
| // RUN: %empty-directory(%t/tmp) | ||
| // RUN: cd %t && env TMPDIR=%t/tmp/ %swiftc_driver -driver-print-jobs -module-name=ThisModule -wmo -num-threads 4 %S/Inputs/main.swift %s -o a.out | %FileCheck -check-prefix=EXEC %s | ||
|
||
| // RUN: echo "{\"%/s\": {\"llvm-bc\": \"%/t/multi-threaded.bc\", \"object\": \"%/t/multi-threaded.o\"}, \"%/S/Inputs/main.swift\": {\"llvm-bc\": \"%/t/main.bc\", \"object\": \"%/t/main.o\"}}" > %t/ofmo.json | ||
| // RUN: %target-swiftc_driver -module-name=ThisModule -wmo -num-threads 4 %S/Inputs/main.swift %s -emit-dependencies -output-file-map %t/ofmo.json -c | ||
| // RUN: cat %t/*.d | %FileCheck -check-prefix=DEPENDENCIES %s | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1021,6 +1021,9 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'w | |
| config.target_shared_library_prefix = 'lib' | ||
| config.target_shared_library_suffix = ".so" | ||
| config.target_sdk_name = "android" | ||
| # Needed by several ParseableInterface/swift_build_sdk_interfaces tests on | ||
| # Android | ||
| config.environment['ANDROID_DATA'] = os.environ['ANDROID_DATA'] | ||
| else: | ||
| lit_config.note("Testing Linux " + config.variant_triple) | ||
| config.target_object_format = "elf" | ||
|
|
@@ -1239,7 +1242,7 @@ ENV_VAR_PREFIXES = { | |
| 'appletvsimulator': SIMULATOR_ENV_PREFIX, | ||
| 'android': 'ANDROID_CHILD_' | ||
| } | ||
| TARGET_ENV_PREFIX = ENV_VAR_PREFIXES.get(config.target_sdk_name, "") | ||
| TARGET_ENV_PREFIX = ENV_VAR_PREFIXES.get(config.target_sdk_name, "") if not kIsAndroid else "" | ||
|
||
|
|
||
| if 'remote_run_host' in lit_config.params: | ||
| if 'remote_run_tmpdir' not in lit_config.params: | ||
|
|
@@ -1351,7 +1354,7 @@ def source_compiler_rt_libs(path): | |
| and config.compiler_rt_platform in lib]) | ||
|
|
||
| compiler_rt_dir = make_path(test_resource_dir, 'clang', 'lib', | ||
| platform.system().lower()) | ||
| platform.system().lower() if not kIsAndroid else 'android') | ||
|
||
| source_compiler_rt_libs(compiler_rt_dir) | ||
|
|
||
| def check_runtime_libs(features_to_check): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this caused the Syntax/Parser issues because swift-syntax-parser-test no longer linked properly, as lld would try to place a dependency on lib/lib_InternalSwiftSyntaxParser.so if that host library's soname wasn't set. This fixes that by only removing the soname for target libraries on Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgorloff, you added this, look good?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not 100% sure. I see that difference in junction
if(SWIFTLIB_SINGLE_TARGET_LIBRARY) .... The fix I made in past also was addressed link issues when building single targets, like libswiftCore.so, libswiftSwiftOnoneSupport.so, etc. Seems should be OK.