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

Add Android community CI #55

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add Android community CI #55

wants to merge 6 commits into from

Conversation

marcprux
Copy link
Contributor

@marcprux marcprux commented Nov 4, 2024

The previous Android CI has been offline for nearly a year. We'd like to volunteer to take on the community CI builds for Android.

@marcprux marcprux requested a review from shahmishal as a code owner November 4, 2024 22:42
@shahmishal
Copy link
Member

@marcprux Email sent for additional information. Thanks

@finagolfin
Copy link
Member

The main issue with the current setup is that it was using the bootstrap build, so once that broke, it no longer built the compiler. If you simply use the same build preset but provide an OS environment with a prebuilt Swift toolchain and Android NDK 26d available, it should work.

@marcprux
Copy link
Contributor Author

If you simply use the same build preset but provide an OS environment with a prebuilt Swift toolchain and Android NDK 26d available, it should work.

Yes, I expect some tweaks will be needed to get it going again. Once the builds start getting submitted to the machine I'll start filing PRs to get the preset working.

I submitted the requested information a couple weeks ago, but haven't heard anything since.

@finagolfin
Copy link
Member

Btw, I updated trunk to work with NDK 27, so the latest NDK 27c should work now.

@marcprux
Copy link
Contributor Author

The NDK 27c installation is at ANDROID_NDK. It is also set to SWIFT_ANDROID_NDK_PATH, which build-script-impl script suggests should be automatically used, but it appears not:

$  ./swift/utils/build-script --preset buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build install_destdir=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install installable_package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz

[./swift/utils/build-script] ERROR: no value found for ndk_path in "%(ndk_path)s"

Tacking it onto the end of the command with ndk_path=${ANDROID_NDK} does successfully kick off the build, though.

Should I make a PR for build-presets.ini with this flag, or should be added by the Jenkins controller?

@marcprux
Copy link
Contributor Author

Manually running the Android build with:

./swift/utils/build-script --preset buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build install_destdir=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install installable_package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz ndk_path=${ANDROID_NDK} --reconfigure

eventually errors out with:

+ /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/cmake-linux-x86_64/bin/cmake --build /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/swift-linux-x86_64 -- -j4 all swift-stdlib-linux-x86_64 swift-stdlib-android-aarch64 swift-libexec-linux-x86_64 swift-libexec-android-aarch64
ninja: error: 'stdlib/public/core/SwiftMacros', needed by 'stdlib/public/core/LINUX/x86_64/Swift.o', missing and no known rule to make it

This is the same error cited by swiftlang/swift#77795, so I'm wondering if swiftlang/swift#77815 will fix it.

@finagolfin
Copy link
Member

Should I make a PR for build-presets.ini with this flag, or should be added by the Jenkins controller?

The latter, Swift build presets are customizable with such declared command-line flags, though I believe it ignores the --reconfigure you added, certainly other undeclared customizations. The Android build presets expect the NDK path to be passed in by this ndk_path flag and will not work without it.

This is the same error cited by swiftlang/swift#77795, so I'm wondering if swiftlang/swift#77815 will fix it.

That shouldn't be necessary: if you simply install a prebuilt Swift toolchain for the host and add it to the PATH, as I noted a couple weeks ago, the CMake build automatically picks it up and uses it to build the Swift portions of the trunk compiler.

There is no reason to bootstrap the trunk compiler on this CI when there are already prebuilt host toolchains available for linux.

@marcprux
Copy link
Contributor Author

if you simply install a prebuilt Swift toolchain for the host and add it to the PATH, as I noted a couple weeks ago, the CMake build automatically picks it up and uses it to build the Swift portions of the trunk compiler.

That seems to not be the case:

swiftci@skipbox:~$ which swift
/home/swiftci/swift/swift-current/usr/bin/swift

swiftci@skipbox:~$ swift --version
Swift version 6.0.2 (swift-6.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu


swiftci@skipbox:~$  ~/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script --preset buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build install_destdir=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install installable_package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz ndk_path=${ANDROID_NDK}

[/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script] NOTE: using preset "buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build", which expands to 

/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script --assertions --swift-enable-ast-verifier=0 --no-swift-stdlib-assertions '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;libexec;stdlib;swift-remote-mirror;sdk-overlay;static-mirror-lib;toolchain-tools;license;sourcekit-inproc' '--llvm-install-components=llvm-ar;llvm-ranlib;llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file' --build-subdir=buildbot_linux --release --test --validation-test --long-test --stress-test --test-optimized '--lit-args=-v --time-tests' --build-ninja --android --android-ndk=/home/swiftci/android/ndk/android-ndk --android-api-level=21 --build-swift-static-stdlib --build-swift-static-sdk-overlay --build-swift-stdlib-unittest-extra --install-destdir=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install --installable-package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz --host-test --install-prefix=/usr --install-llvm --install-static-linux-config --install-swift --install-swiftsyntax --skip-test-linux --skip-build-benchmarks --skip-early-swiftsyntax --reconfigure

[/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script] NOTE: Using toolchain default

…

-- Build files have been written to: /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/swift-linux-x86_64
+ popd
~
+ /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/cmake-linux-x86_64/bin/cmake --build /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/swift-linux-x86_64 -- -j4 all swift-stdlib-linux-x86_64 swift-stdlib-android-aarch64 swift-libexec-linux-x86_64 swift-libexec-android-aarch64
ninja: error: 'stdlib/public/core/SwiftMacros', needed by 'stdlib/public/core/LINUX/x86_64/Swift.o', missing and no known rule to make it
ERROR: command `['/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script-impl', '--workspace', '/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build', '--build-dir', '/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux', '--install-prefix', '/usr', '--host-target', 'linux-x86_64', '--stdlib-deployment-targets=linux-x86_64 android-aarch64', '--host-cc', '/usr/bin/clang', '--host-cxx', '/usr/bin/clang++', '--darwin-xcrun-toolchain', 'default', '--darwin-deployment-version-osx=13.0', '--darwin-deployment-version-ios=16.0', '--darwin-deployment-version-tvos=16.0', '--darwin-deployment-version-watchos=6.0', '--darwin-deployment-version-xros=1.0', '--cmake', '/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/cmake-linux-x86_64/bin/cmake', '--llvm-build-type', 'Release', '--swift-build-type', 'Release', '--swift-stdlib-build-type', 'Release', '--lldb-build-type', 'Release', '--foundation-build-type', 'Release', '--libdispatch-build-type', 'Release', '--xctest-build-type', 'Release', '--llbuild-build-type', 'Release', '--swift-enable-assertions', 'true', '--swift-stdlib-enable-assertions', 'false', '--swift-analyze-code-coverage', 'false', '--llbuild-enable-assertions', 'true', '--lldb-assertions', 'true', '--cmake-generator', 'Ninja', '--cross-compile-append-host-target-to-destdir', 'true', '--build-jobs', '4', '--lit-jobs', '4', '--common-cmake-options=-G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++ -DCMAKE_Swift_COMPILER:PATH=/home/swiftci/swift/swift-current/usr/bin/swiftc -DCMAKE_LIBTOOL:PATH= -DCMAKE_AR:PATH=/usr/bin/ar -DCMAKE_RANLIB:PATH=/usr/bin/ranlib -DLLVM_VERSION_MAJOR:STRING=17 -DLLVM_VERSION_MINOR:STRING=0 -DLLVM_VERSION_PATCH:STRING=0 -DCLANG_VERSION_MAJOR:STRING=17 -DCLANG_VERSION_MINOR:STRING=0 -DCLANG_VERSION_PATCH:STRING=0 -DCMAKE_MAKE_PROGRAM=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/ninja-build/ninja', '--build-args=-j4', '--dsymutil-jobs', '1', '--build-swift-libexec', 'true', '--swift-enable-backtracing', 'true', '--build-swift-clang-overlays', 'true', '--build-swift-remote-mirror', 'true', '--swift-cmake-options=-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE -DSWIFT_FORCE_OPTIMIZED_TYPECHECKER:BOOL=FALSE -DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE -DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=TRUE -DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=TRUE -DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=TRUE -DSWIFT_ENABLE_CXX_INTEROP_SWIFT_BRIDGING_HEADER:BOOL=TRUE -DSWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS:BOOL=FALSE -DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=TRUE -DSWIFT_ENABLE_BACKTRACING:BOOL=TRUE -DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=TRUE -DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=TRUE -DSWIFT_ENABLE_VOLATILE:BOOL=TRUE -DSWIFT_STDLIB_STATIC_PRINT=FALSE -DSWIFT_FREESTANDING_IS_DARWIN:BOOL=FALSE -DSWIFT_STDLIB_BUILD_PRIVATE:BOOL=TRUE -DSWIFT_STDLIB_ENABLE_UNICODE_DATA=TRUE -DSWIFT_SHOULD_BUILD_EMBEDDED_STDLIB=TRUE -DSWIFT_SHOULD_BUILD_EMBEDDED_STDLIB_CROSS_COMPILING=FALSE -DSWIFT_STDLIB_BUILD_SYMBOL_GRAPHS:BOOL=FALSE -DSWIFT_TOOLS_LD64_LTO_CODEGEN_ONLY_FOR_SUPPORTING_TARGETS:BOOL=FALSE -DSWIFT_ENABLE_EXPERIMENTAL_PARSER_VALIDATION:BOOL=TRUE -USWIFT_DEBUGINFO_NON_LTO_ARGS', '--build-stdlib-deployment-targets', 'all', '--ninja-bin=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/ninja-build/ninja', '--install-destdir', '/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install', '--skip-build-benchmarks', '--skip-build-foundation', '--skip-build-xctest', '--skip-build-lldb', '--skip-build-llbuild', '--skip-build-libcxx', '--skip-build-libdispatch', '--skip-build-libxml2', '--skip-build-zlib', '--skip-build-curl', '--build-swift-dynamic-stdlib', '--build-swift-static-stdlib', '--build-swift-stdlib-unittest-extra', '--build-swift-dynamic-sdk-overlay', '--build-swift-static-sdk-overlay', '--validation-test', '--long-test', '--stress-test', '--skip-test-benchmarks', '--android-arch', 'aarch64', '--android-ndk', '/home/swiftci/android/ndk/android-ndk', '--android-api-level', '21', '--android-deploy-device-path', '/data/local/tmp', '--extra-cmake-options=-USWIFT_DARWIN_SUPPORTED_ARCHS -DSWIFT_EARLY_SWIFT_DRIVER_BUILD=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/earlyswiftdriver-linux-x86_64/release/bin', '--swift-enable-ast-verifier=0', '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;libexec;stdlib;swift-remote-mirror;sdk-overlay;static-mirror-lib;toolchain-tools;license;sourcekit-inproc', '--installable-package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz', '--install-swift', '--reconfigure', '--llvm-lit-args=-v --time-tests --param color_output', '--llvm-install-components=llvm-ar;llvm-ranlib;llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file', '--musl-path=/usr/local/musl', '--linux-static-archs=x86_64;aarch64', '--only-execute', 'linux-x86_64-swift-build']` terminated with a non-zero exit status 1, aborting

ERROR: command `['/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift/utils/build-script', '--assertions', '--swift-enable-ast-verifier=0', '--no-swift-stdlib-assertions', '--swift-install-components=autolink-driver;compiler;clang-resource-dir-symlink;libexec;stdlib;swift-remote-mirror;sdk-overlay;static-mirror-lib;toolchain-tools;license;sourcekit-inproc', '--llvm-install-components=llvm-ar;llvm-ranlib;llvm-cov;llvm-profdata;IndexStore;clang;clang-resource-headers;compiler-rt;clangd;lld;LTO;clang-features-file', '--build-subdir=buildbot_linux', '--release', '--test', '--validation-test', '--long-test', '--stress-test', '--test-optimized', '--lit-args=-v --time-tests', '--build-ninja', '--android', '--android-ndk=/home/swiftci/android/ndk/android-ndk', '--android-api-level=21', '--build-swift-static-stdlib', '--build-swift-static-sdk-overlay', '--build-swift-stdlib-unittest-extra', '--install-destdir=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/swift-nightly-install', '--installable-package=/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/2-android.tar.gz', '--host-test', '--install-prefix=/usr', '--install-llvm', '--install-static-linux-config', '--install-swift', '--install-swiftsyntax', '--skip-test-linux', '--skip-build-benchmarks', '--skip-early-swiftsyntax', '--reconfigure']` terminated with a non-zero exit status 1, aborting

@finagolfin
Copy link
Member

You snipped out the relevant portion where the CMake config for the trunk Swift compiler is supposed to find it:

-- Found assembler: /opt/swift/5.8.1/usr/bin/clang
CMake Warning (dev) at CMakeLists.txt:108 (enable_language):
  project() should be called prior to this enable_language() call.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The Swift compiler identification is Apple 5.8.1
-- Check for working Swift compiler: /opt/swift/5.8.1/usr/bin/swiftc
-- Check for working Swift compiler: /opt/swift/5.8.1/usr/bin/swiftc - works
-- CMake (/home/build-user/build/cmake-linux-x86_64/bin/cmake) Version: 3.30.2
-- CMake Make Program (/home/build-user/build/buildbot_linux/ninja-build/ninja) Version: 1.11.1                                                                    -- C Compiler (/opt/swift/5.8.1/usr/bin/clang) Version: 13.0.0
-- C++ Compiler (/opt/swift/5.8.1/usr/bin/clang++) Version: 13.0.0                                                                                                 -- Assembler (/opt/swift/5.8.1/usr/bin/clang) Version:                                                                                                             -- Swift Compiler (/opt/swift/5.8.1/usr/bin/swiftc) Version: 5.8.1
--   Implicit 'string-processing' import: TRUE
--   Implicit 'backtracing' import: FALSE
--   Package CMO: NO
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

That log snippet shows how the linux CI has CMake find the prebuilt Swift 5.8.1 toolchain used from its PATH.

Is it possible your PATH is different in the CI environment where build-script is actually run somehow? Take a look at that log output to see what CMake is finding.

@marcprux
Copy link
Contributor Author

The Jenkins-submitted build is still failing immediately due to the missing ndk_path (https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-24.04-android-build/lastBuild/consoleFull). But when I manually add it to the PATH and run the build manually, it does seem to pick up the compiler:

-- The Swift compiler identification is Apple 6.0.2
-- Check for working Swift compiler: /home/swiftci/swift/swift-current/usr/bin/swiftc
-- Check for working Swift compiler: /home/swiftci/swift/swift-current/usr/bin/swiftc - works
CMake Warning at CMakeLists.txt:820 (message):
  Force setting SWIFT_BUILD_REGEX_PARSER_IN_COMPILER=OFF because Swift parser
  integration is disabled


-- CMake (/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/cmake-linux-x86_64/bin/cmake) Version: 3.30.2
-- CMake Make Program (/home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-build/build/buildbot_linux/ninja-build/ninja) Version: 1.11.1
-- C Compiler (/usr/bin/clang) Version: 18.1.3
-- C++ Compiler (/usr/bin/clang++) Version: 18.1.3

@shahmishal, can you configure Jenkins for the Android CI to:

  1. Set ndk_path to /home/swiftci/android/ndk/android-ndk
  2. Set the PATH environment to include /home/swiftci/swift/swift-current/usr/bin to pick up the Swift compiler (I had added it to ~/.profile, but it doesn't looks like the Jenkins agent pick up the environment from there)

@marcprux
Copy link
Contributor Author

marcprux commented Dec 2, 2024

@shahmishal, can you configure Jenkins for the Android CI to:

@shahmishal, should I be requesting this through some other forum?

@shahmishal
Copy link
Member

@marcprux Sorry, I was out last week. Let me look into this later today.

@shahmishal
Copy link
Member

@finagolfin
Copy link
Member

OK, it finds the prebuilt Swift compiler now, so you can start updating the presets. You'll want to start building the swift-syntax parser again, add android-arch=armv7 to the base preset (I switched the Android default arch to AArch64 earlier this year), and while you're at it, fix the CMake log output to remove the incorrect ENV portion.

@drodriguez, is it okay if we modify the README to remove the links to your old community CI, which it looks like stopped running a couple months ago?

@shahmishal
Copy link
Member

@drodriguez, is it okay if we modify the README to remove the links to your old community CI, which it looks like stopped running a couple months ago?

Yes, we should update the README.

@finagolfin
Copy link
Member

add android-arch=armv7 to the base preset

Oh wait, you are proposing CI for aarch64 and x86_64 instead. In that case, maybe just leave the base preset alone for that variable, so it defaults to aarch64, then add a new x86_64 preset and update this pull to explicitly list that new x86_64 preset instead.

@marcprux
Copy link
Contributor Author

marcprux commented Dec 5, 2024

That shouldn't be necessary: if you simply install a prebuilt Swift toolchain for the host and add it to the PATH, as I noted a couple weeks ago, the CMake build automatically picks it up and uses it to build the Swift portions of the trunk compiler.

Even though the build is now finding the host toolchain:

-- Check for working Swift compiler: /home/swiftci/swift/swift-current/usr/bin/swiftc
-- Check for working Swift compiler: /home/swiftci/swift/swift-current/usr/bin/swiftc - works

It is still ultimately failing with the same error:

+ /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-arm64/cmake-linux-x86_64/bin/cmake --build /home/swiftci/jenkins/workspace/oss-swift-RA-linux-ubuntu-24.04-android-arm64/buildbot_linux/swift-linux-x86_64 -- -j4 all swift-stdlib-linux-x86_64 swift-stdlib-android-aarch64 swift-libexec-linux-x86_64 swift-libexec-android-aarch64
ninja: error: 'stdlib/public/core/SwiftMacros', needed by 'stdlib/public/core/LINUX/x86_64/Swift.o', missing and no known rule to make it

Should we be adding build-llvm=0 to build-presets.ini?

I almost wonder if we should add a new Android preset that exactly mirrors your working build script:

./swift/utils/build-script -RA --skip-build-cmark --build-llvm=0 --android --android-ndk $ANDROID_NDK_LATEST_HOME --android-arch ${{ matrix.arch }} --android-api-level $ANDROID_API_LEVEL --build-swift-tools=0 --native-swift-tools-path=${TOOLCHAIN}/bin --native-clang-tools-path=${TOOLCHAIN}/bin --cross-compile-hosts=android-${{ matrix.arch }} --cross-compile-deps-path=$SDK --skip-local-build --build-swift-static-stdlib --xctest --skip-early-swift-driver --install-swift --install-libdispatch --install-foundation --install-xctest --install-destdir=$SDK --swift-install-components='compiler;clang-resource-dir-symlink;license;stdlib;sdk-overlay' --cross-compile-append-host-target-to-destdir=False -b -p --install-llbuild --sourcekit-lsp --skip-early-swiftsyntax

@finagolfin
Copy link
Member

It is still ultimately failing with the same error:

That is most likely related to the now incorrect skip-early-swiftsyntax flag in the preset that I linked to above. Try it out locally and see.

Should we be adding build-llvm=0 to build-presets.ini?

The point of this community CI is to regularly build the trunk compiler and test it for Android, so that wouldn't make sense. I do think the official CI rebuilds way too much code, and told Mishal years ago that it should employ some build caching, so that a recently built compiler build directory for a certain compiler commit can be reused between, let's say, swift-foundation builds.

Some of that has been done, eg SwiftPM "self-hosted" smoke tests now use the prebuilt nightly snapshot compiler instead of building the latest trunk compiler commit from source each time, but not nearly enough build caching on the CI has been added.

The problem is that you'd have to clearly state the build dependency tree first to know what repo depends on what, eg the compiler build also builds libdispatch so that's a circular dependency of sorts, and that work likely hasn't been done.

I hope Mishal gets some help with his official CI work- I thought I saw on Mastodon that Apple was hiring build engineers for Swift- and they can get that implemented some day.

I almost wonder if we should add a new Android preset that exactly mirrors your working build script

That's the plan for the official CI at some point, which is moving up to the top of my task queue, though it would have to build the trunk compiler also, unlike my Android CI which just uses the prebuilt compiler snapshots.

If you find setting this up too much of a hassle, we could just wait for that official Android CI instead. This preset will only really help keep the compiler validation suite up to date for Android, which has little to no effect on my Android CI and its SDK bundles. You mentioned some failed trunk runs on my Android CI in asking for this community CI, but that's mostly related to my upstreaming Android patches for other repos like SwiftPM, which aren't even built by this preset.

And considering I expect to get the official Android CI submitted in the next couple months, this community CI would only be useful for those few prior months.

Your call: there is some value in fixing the last tests in the compiler validation suite for Android, and getting this preset working isn't much effort. But this community CI will have basically no effect on my own Android CI and the trunk SDK bundles it generates.

@marcprux
Copy link
Contributor Author

marcprux commented Dec 5, 2024

And considering I expect to get the official Android CI submitted in the next couple months, this community CI would only be useful for those few prior months.

What form will this take? Will it be just another preset that is built using the same Jenkins process, or a whole separate CI mechanism? If the latter, how do you envision it integrating with PRs and the like?

I certainly don't want to duplicate work. My goal was to first get the current preset working, and then start proposing additions to it like building SwiftPM, Foundation, and other essential packages that frequently need to be patched due to breakage.

@drodriguez
Copy link
Contributor

drodriguez commented Dec 5, 2024

@marcprux the existing Android presets were the presets used by the community CI which was disconnected at the end of September. Feel free to repourpose those presets for the new community CI. No need to create new ones (well, if you want to modernize to skip armv7 and do something more meaningful that should be fine). If a Swift toolchain is present in the new CI machines, the changes from swiftlang/swift#68895 should not be necessary anymore.

@finagolfin
Copy link
Member

What form will this take? Will it be just another preset that is built using the same Jenkins process, or a whole separate CI mechanism?

It would be part of the official CI, which are Docker images that run a build preset through Jenkins, similar to this community CI.

how do you envision it integrating with PRs and the like?

Initially, it would be another post-commit CI, like the couple dozen that run now. Maybe it would graduate to a pre-commit CI at some point, as Alex discussed on the forum earlier this year.

I certainly don't want to duplicate work.

You wouldn't, I haven't done anything about the official Android CI yet. If you want to spearhead this, whether with the community or official CI, go for it, and I will assist when I can.

My goal was to first get the current preset working, and then start proposing additions to it like building SwiftPM, Foundation, and other essential packages that frequently need to be patched due to breakage.

I agree about the corelibs, as I wrote up in my plan for the official CI when discussing it with Alex on the forum.

As for building SwiftPM and other outside packages for Android, I don't know if the official CI does that type of extra validation, particularly for platforms for which it does not distribute an official native toolchain, only a cross-compilation SDK. Building the compiler and corelibs and running their tests is mostly what I see it doing for other platforms now.

Also, in my experience, everything has been pretty stable and I see almost no breakage with most of the Swift repos. If you're referring to the sometimes failing builds on my Android CI, that's usually because I'm still upstreaming patches for the new Android overlay and Foundation rewrite from earlier this year and I don't know when those will be included in a new snapshot tag. So when one of my patches makes it into a snapshot tag, my CI will try to apply the same patch and fail.

That's not a big deal and is quickly fixed, plus it's just a temporary situation after all the Android overlay/rewrite changes earlier this year.

@finagolfin
Copy link
Member

Alright, changing the base preset and adding one for x86_64 shows that this CI works, as it now builds the Swift compiler and fails when cross-compiling the stdlib for Android, because the passed-in path to the Android NDK on this CI doesn't have the NDK version.

That's fine: I'll update the stdlib CMake config to check the NDK's source.properties instead, which is a more reliable way to check the NDK version that I need on my Android CI also.

So keep this NDK path the way it is, but update this pull to use the right aarch64 and new x86_64 presets now.

@shahmishal, I don't know if you need to change any other internal config to use the new x86_64 preset also, but once those last changes are in, we can get this merged and Marc and I can then iterate on the presets and fixing tests for Android.

@shahmishal
Copy link
Member

If we need to change the preset, please update the nodes/aarch64_ubuntu_22_04_android.json and nodes/x86_64_ubuntu_22_04_android.json in this PR.

@marcprux
Copy link
Contributor Author

So keep this NDK path the way it is, but update this pull to use the right aarch64 and new x86_64 presets now.

I've updated the x86_64 preset to match the new entry in build-presets.ini.

That should be all that is needed, yes? The aarch64 preset is unchanged.

@finagolfin
Copy link
Member

@shahmishal, we got the compiler validation suite running on this new CI finally, so once you adjust the CI jobs to these two presets, this is ready for merging.

@finagolfin
Copy link
Member

Oh, one discrepancy I noticed is that this pull says 22.04, but the CI jobs are named and seem to run 24.04.

@marcprux
Copy link
Contributor Author

Oh, one discrepancy I noticed is that this pull says 22.04, but the CI jobs are named and seem to run 24.04.

Fixed in edcc8e3 and c7c1865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants