Skip to content

Conversation

@finagolfin
Copy link
Member

@gottesmm and @etcwilde, I believe you two are most familiar with this build-script feature, let me know what you think. I reused the linux toolchain file generation for Android, as they have a lot in common, but can separate the two if wanted. This pull was tested by cross-compiling on my Android CI, and natively on Android in the Termux app.

I will look at cross-compiling Foundation dependencies like libcurl with this new Android toolchain file in a subsequent pull.

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is currently used to generate Swift cross-compilation flags for build-script-impl products alone, but I was able to reuse it for Testing by passing in a separate resource_path. That resource_path calculation can only be done externally, where the particular build product is known.

@finagolfin
Copy link
Member Author

@swift-ci test

@xavgru12
Copy link

This looks great and is useful for cross compilation in general!

@finagolfin
Copy link
Member Author

@swift-ci smoke test

@finagolfin
Copy link
Member Author

Updated to refactor a bit and disable a recently failing but unrelated test on 32-bit Android.

@finagolfin
Copy link
Member Author

@swift-ci smoke test macos

@finagolfin
Copy link
Member Author

Ping @etcwilde, any feedback on this small Android-only pull? I'd like to get it into 6.2 next, works well on my CI.

@finagolfin
Copy link
Member Author

Updated to enable a test that now passes and rebased.

@swift-ci smoke test

@finagolfin
Copy link
Member Author

@MaxDesiatov, you've also modified this code, perhaps you can review?

Also, disable a recently failing test for Android armv7 and enable another one
that now passes.
@finagolfin
Copy link
Member Author

Added a validation test, made sure it worked on linux, and rebased.

@swift-ci smoke test

@finagolfin
Copy link
Member Author

Going ahead and merging because this only affects Android, passed the CI, and I want to get it into 6.2 next. If anyone finally reviews it and wants anything changed, I can always do that later.

@finagolfin finagolfin merged commit 09a751f into swiftlang:main Aug 2, 2025
3 checks passed
@finagolfin finagolfin deleted the droid branch August 2, 2025 09:59
@shahmishal
Copy link
Member

We noticed a FreeBSD test failure with this change.

2:46:55  ******************** TEST 'Swift-validation(freebsd-x86_64) :: BuildSystem/cmark_crosscompile_using_toolchain_always.test' FAILED ********************
22:46:55  Exit Code: 1
22:46:55  
22:46:55  Command Output (stderr):
22:46:55  --
22:46:55  RUN: at line 3: rm -rf "/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp" && mkdir -p "/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp"
22:46:55  + rm -rf /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp
22:46:55  + mkdir -p /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp
22:46:55  RUN: at line 4: mkdir -p /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp
22:46:55  + mkdir -p /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp
22:46:55  RUN: at line 5: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/utils/build-script --dry-run --install-all --cmake /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/cmake-freebsd-x86_64/bin/cmake --skip-build-llvm --skip-build-swift 2>&1 | /usr/local/bin/python3.11 /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/utils/PathSanitizingFileCheck --allow-unused-prefixes --sanitize BUILD_DIR=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64 --sanitize SOURCE_DIR=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift --ignore-runtime-warnings --use-filecheck /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/llvm-freebsd-x86_64/bin/FileCheck   /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
22:46:55  + SKIP_XCODE_VERSION_CHECK=1
22:46:55  + SWIFT_BUILD_ROOT=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp
22:46:55  + /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/utils/build-script --dry-run --install-all --cmake /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/cmake-freebsd-x86_64/bin/cmake --skip-build-llvm --skip-build-swift
22:46:55  + /usr/local/bin/python3.11 /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/utils/PathSanitizingFileCheck --allow-unused-prefixes --sanitize BUILD_DIR=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/swift-freebsd-x86_64 --sanitize SOURCE_DIR=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift --ignore-runtime-warnings --use-filecheck /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/llvm-freebsd-x86_64/bin/FileCheck /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
22:46:55  /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test:8:10: error: CHECK: expected string not found in input
22:46:55  # CHECK: DRY_RUN! Writing Toolchain file to path:{{.*}}BuildScriptToolchain.cmake
22:46:55           ^
22:46:55  <stdin>:1:1: note: scanning from here
22:46:55  [SOURCE_DIR/utils/build-script] NOTE: Using toolchain default
22:46:55  ^
22:46:55  
22:46:55  Input file: <stdin>
22:46:55  Check file: /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/swift/validation-test/BuildSystem/cmark_crosscompile_using_toolchain_always.test
22:46:55  
22:46:55  -dump-input=help explains the following input dump.
22:46:55  
22:46:55  Input was:
22:46:55  <<<<<<
22:46:55           1: [SOURCE_DIR/utils/build-script] NOTE: Using toolchain default 
22:46:55  check:8     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
22:46:55           2: + /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/cmake-freebsd-x86_64/bin/cmake --version 
22:46:55  check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22:46:55           3: --- Local Ninja Build --- 
22:46:55  check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~
22:46:55           4: + /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/cmake-freebsd-x86_64/bin/cmake -S /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/ninja -B BUILD_DIR/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp/Ninja-DebugAssert/ninja-build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCMAKE_C_COMPILER=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/llvm-freebsd-x86_64/./bin/clang -DCMAKE_CXX_COMPILER=/home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/buildbot_freebsd/llvm-freebsd-x86_64/./bin/clang++ 
22:46:55  check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22:46:55           5: + /home/ec2-user/jenkins/workspace/swift-bootstrap-freebsd-14-x86_64/build/cmake-freebsd-x86_64/bin/cmake --build BUILD_DIR/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp/Ninja-DebugAssert/ninja-build 
22:46:55  check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22:46:55           6: + mkdir -p BUILD_DIR/validation-test-freebsd-x86_64/BuildSystem/Output/cmark_crosscompile_using_toolchain_always.test.tmp/Ninja-DebugAssert 
22:46:55  check:8     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22:46:55           .
22:46:55           .
22:46:55           .
22:46:55  >>>>>>
22:46:55  
22:46:55  --
22:46:55  
22:46:55  ********************

@finagolfin
Copy link
Member Author

@shahmishal, ah, was a bit confused initially, as this pull has nothing to do with FreeBSD, but I then noticed that I just enabled this test on non-macOS platforms, since I figured that all the build-script platforms that have CI- macOS, linux, and soon Android- are now using these CMake toolchain files to compile cmark. I was unaware of the new FreeBSD CI, so we will have to adjust the test for that, if it is not using toolchain files yet.

@etcwilde, would you like me to disable this test again for FreeBSD alone, or do you have any plans to have it use toolchain files also? Let me know what you'd like to do about this failing test on the new FreeBSD CI, great news that it is up btw! 😄

@etcwilde
Copy link
Member

etcwilde commented Aug 6, 2025

I'll XFAIL it for now. If we do add the generated toolchain files, the test should fail and then we can revert the XFAIL.

finagolfin added a commit that referenced this pull request Aug 22, 2025
…83260)

Also, disable a recently failing test for Android armv7.
finagolfin added a commit that referenced this pull request Aug 22, 2025
This new flag makes it easy to build Swift cross-compilation toolchains, by
disabling cross-compilation of all host tools, like the Swift compiler and
various macros, building on prior pulls #38441 and #82163.

Also, add two class methods to the Testing macros product so it works with #83260.
shahmishal pushed a commit that referenced this pull request Sep 18, 2025
…83260)

Also, disable a recently failing test for Android armv7.
shahmishal pushed a commit that referenced this pull request Sep 18, 2025
This new flag makes it easy to build Swift cross-compilation toolchains, by
disabling cross-compilation of all host tools, like the Swift compiler and
various macros, building on prior pulls #38441 and #82163.

Also, add two class methods to the Testing macros product so it works with #83260.
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