-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Android: add bootstrap build support and fix tests #2417
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 |
---|---|---|
|
@@ -270,6 +270,10 @@ class Target(object): | |
if args.llbuild_link_framework: | ||
other_args.extend(["-F", args.llbuild_build_dir]) | ||
|
||
# Don't use GNU strerror_r on Android. | ||
if 'ANDROID_DATA' in os.environ: | ||
other_args.extend(["-Xcc", "-U_GNU_SOURCE"]) | ||
|
||
print(" import-paths: %s" % json.dumps(import_paths), file=output) | ||
print(" other-args: %s" % json.dumps(other_args), | ||
file=output) | ||
|
@@ -681,7 +685,7 @@ def process_runtime_libraries(build, args, lib_path): | |
cmd = [args.swiftc_path, "-emit-library", "-o", runtime_lib_path, | ||
"-Xlinker", "--whole-archive", | ||
"-Xlinker", input_lib_path, | ||
"-Xlinker", "--no-whole-archive", "-lswiftGlibc", | ||
"-Xlinker", "--no-whole-archive", "-lswiftGlibc", "-lFoundation", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only part of this pull that affects non-Android platforms. I had issues for a long time with getting the bootstrapped SPM to interpret its own manifest and dump it to JSON (as mentioned in #2396) and it turned out this was why. The problem is that libPackageDescription.so depends on some functions from Foundation, but doesn't list it as a required dependency:
These results were from the official 5.1.2 release for linux x86_64, I get the same results with the latest snapshots from master. The Android dynamic linker enforces that even if a executable or library links against libPackageDescription.so and lists libFoundation.so as a dependency there, it isn't transitively applied to libPackageDescription.so, unlike the GNU dynamic linker historically, though that may be changing. It appears that's why this hasn't hit on linux, as the Swift compiler seems to automatically add the needed Foundation dependency to a linux executable I tested linking against libPackageDescription.so, but that doesn't help on Android since it enforces that each library list its requirements itself. |
||
"-Xlinker", "-rpath=$ORIGIN/../../linux"] | ||
|
||
# We need to pass one swift file here to bypass the "no input files" | ||
|
@@ -1024,7 +1028,14 @@ def main(): | |
if platform.system() == 'Darwin': | ||
build_target = "x86_64-apple-macosx" | ||
elif platform.system() == 'Linux': | ||
if platform.machine() == 'x86_64': | ||
if 'ANDROID_DATA' in os.environ: | ||
if platform.machine().startswith("armv7"): | ||
build_target = 'armv7-unknown-linux-androideabi' | ||
elif platform.machine() == 'aarch64': | ||
build_target = 'aarch64-unknown-linux-android' | ||
else: | ||
raise SystemExit("ERROR: unsupported Android platform:",platform.machine()) | ||
elif platform.machine() == 'x86_64': | ||
build_target = "x86_64-unknown-linux-gnu" | ||
elif platform.machine() == "i686": | ||
build_target = "i686-unknown-linux" | ||
|
@@ -1175,6 +1186,10 @@ def main(): | |
# Append the versioning build flags. | ||
build_flags.extend(create_versoning_args(args)) | ||
|
||
# Don't use GNU strerror_r on Android. | ||
if 'ANDROID_DATA' in os.environ: | ||
build_flags.extend(["-Xswiftc", "-Xcc", "-Xswiftc", "-U_GNU_SOURCE"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine for now but this should go to BuildPlan.swift so swiftpm can correct compile itself and other Swift targets for Android. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, |
||
|
||
# Add llbuild import flags. | ||
for import_path in llbuild_import_paths(args): | ||
build_flags.extend(["-Xswiftc", "-I%s" % import_path]) | ||
|
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.
I am trying to move SwiftPM away from this bootstrap script and rely the CMake 3.15.1 which has builtin Swift support. I don't know when that'll happen but I expect to it to happen within next couple of months (ofc not a guarantee). So this might mean you have to do some of these changes again. If you want to try the new WIP CMake bootstrapping, run
Utilities/new-bootstrap
.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.
Sounds good, I'm going to try cross-compiling SPM itself from linux to Android next, so I was going to try the CMake support for that.