Commit Graph

941 Commits

Author SHA1 Message Date
Max Desiatov
03dd520646 Add swift_build/swift-build to swift_build_support/toolchain.py
This exposes `swift-build` from toolchains, which allows products to use this tool directly when building
2025-07-07 15:16:52 +01:00
Max Desiatov
461f7d026b Fix typo in reset func in productpipeline_list_builder.py (#82777)
`pipelinst_list` -> `pipeline_list`

There are no other uses of `pipelinst_list`, so it's clearly a typo when trying to refer to `pipeline_list`
2025-07-04 23:02:16 +01:00
Max Desiatov
0c4e56174b Merge pull request #82399 from swiftlang/maxd/embedded-wasm-tests
These tests still require a manual `lit.py` invocation for Wasm, which will be added as a separate CMake target in a future PR.
2025-07-04 15:36:15 +01:00
Yuta Saito
05204bdf63 Merge pull request #82285 from kateinoigakukun/yt/build-foundation 2025-07-04 22:02:14 +09:00
Max Desiatov
572c52955b NFC: Fix doc comment typo in productpipeline_list_builder.py (#82771)
`Product a final schedule` -> `Produce a final schedule`
2025-07-04 05:49:38 -07:00
Mishal Shah
65d9f5f71c Merge pull request #82729 from etcwilde/ewilde/build-script-divide-by-zero
Build-Script: Don't divide by zero
2025-07-03 15:46:49 -07:00
Yuta Saito
838e9543e8 [wasm] Build and install Foundation for Wasm SDK 2025-07-03 03:25:17 +00:00
Yuta Saito
245dd83e47 Revert "Revert "[wasm] Build and install libxml2 for Wasm SDK""
This reverts commit d5abfa431b.
2025-07-03 03:25:17 +00:00
Evan Wilde
f64b5a0488 Build-Script: Don't divide by zero
If things crash very early on, build-script tries to divide by zero when
computing the percent time spent in each project because the build time
is zero. While this is a failure state, all it does is add more output
to the crashing stack trace.
2025-07-02 10:59:55 -07:00
finagolfin
b2f52524c5 [android] Disable a couple Reflection tests and fix an install path (#82620)
The tests broke on the community Android CI since #82325, and I just
noticed the install issue when cross-compiling Testing with a
freshly-built compiler, which I'd never done before. Also, fix the NDK
path shown in the CMake output.
2025-07-02 09:41:59 +05:30
Max Desiatov
27e5d5c551 Fix/xfail/disable remaining tests for embedded Wasm 2025-07-01 11:43:43 +01:00
3405691582
1cf426c905 Plumb native-clang-tools-path to build support. (#81587)
The build support Python libraries assume by default that if we do not
supply a Swift toolchain path, we can find clang in the installed
toolchain path: i.e., the clang that we just built. However, possibly
during bootstrap, we may not have a preexisting Swift compiler but still
want to use the clang on the platform that is already installed.

build-script already gives us native-clang-tools-path. Here, we plumb
this through to the relevant Python modules. If the
native-clang-tools-path is not specified, we use the
install_toolchain_path, just like native_toolchain_path, and the
existing behavior is effectively unchanged. If we do specify a
native-clang-tools-path, then we return it to ensure that we properly
refer to the clang that lives there instead of always defaulting to the
just-built clang.
2025-06-30 10:07:59 -07:00
Max Desiatov
92dd843a18 Fix building Wasm stdlib with macOS presets (#80850)
Added optional `ignore_extra_cmake_options` to `cmake_product.py`, existing behavior is preserved with the default argument value set to `False`.

Passed `ignore_extra_cmake_options=True` in `wasisysroot.py`. This allows libc++ for WASI to be built correctly with `-fno-exceptions` in presence of `extra-cmake-options` in macOS presets (which are absent in Linux presets).
2025-06-24 11:15:25 -07:00
Yuta Saito
9488df15e0 Merge pull request #82393 from wti/wasmkit-universal-fix-82390
Update wasmkit toolchain build to emit universal binary on macOS to fix #82390
2025-06-23 13:58:09 +09:00
Max Desiatov
9b9db58b21 Discover embedded tests when testing wasmstdlib.py (#82376)
Embedded tests are only included in test discovery for `wasmstdlib` product, a separate change is needed to mark relevant tests as supported.

Without this change:

```
[2025-06-21T00:53:52.507Z] --- Running tests for wasmstdlib ---
[...]
[2025-06-21T00:59:22.874Z] Total Discovered Tests: 1405
[2025-06-21T00:59:22.874Z]   Excluded         :   2 (0.14%)
[2025-06-21T00:59:22.874Z]   Unsupported      : 725 (51.60%)
[2025-06-21T00:59:22.874Z]   Passed           : 674 (47.97%)
[2025-06-21T00:59:22.874Z]   Expectedly Failed:   4 (0.28%)
[...]
[2025-06-20T17:42:41.045Z] Build Percentage 	 Build Duration (sec) 	 Build Phase
[2025-06-20T17:42:41.045Z] ================ 	 ==================== 	 ===========
[...]
[2025-06-21T02:02:24.048Z] 3.0%              	 324.31                	 Running tests for wasmstdlib
```

With this change:

```
[2025-06-20T16:33:58.389Z] --- Running tests for wasmstdlib ---
[...]
[2025-06-20T16:39:29.285Z] Total Discovered Tests: 1626
[2025-06-20T16:39:29.285Z]   Excluded         :   2 (0.12%)
[2025-06-20T16:39:29.285Z]   Unsupported      : 946 (58.18%)
[2025-06-20T16:39:29.285Z]   Passed           : 674 (41.45%)
[2025-06-20T16:39:29.285Z]   Expectedly Failed:   4 (0.25%)
[...]
[2025-06-20T17:42:41.045Z] Build Percentage 	 Build Duration (sec) 	 Build Phase
[2025-06-20T17:42:41.045Z] ================ 	 ==================== 	 ===========
[...]
[2025-06-20T17:42:41.045Z] 3.0%              	 322.87                	 Running tests for wasmstdlib
```
2025-06-21 13:47:55 -07:00
wti
65302367d0 Update wasmkit toolchain build to emit universal on macOS to fix #82390
[platform_args] has platform variants of SwiftPM wasmkit build command:
- unchanged: non-macOS + set_installation_rpath -> rpath config
- added: macOS -> universal binaries using --arch

side effect ok?: binary path changes are captured by '--show-bin-path'
2025-06-21 11:20:40 -07:00
Eric Miotto
218799aedb [build-script] build LLVMTestingSupport only if target is generated
Otherwise the build will fail if we pass `--no-llvm-include-tests` or we
set directly `LLVM_INCLUDE_TESTS` directly to `FALSE`/`OFF`

Addresses rdar://153562845
2025-06-16 15:01:32 -07:00
Eric Miotto
d3f8bbffcb Merge pull request #82124 from edymtt/edymtt/remove-old-way-of-building-compiler-rt
build-script: Remove support for legacy way of building compiler-rt
2025-06-16 12:35:21 -07:00
Max Desiatov
d733338626 build-script: fix --skip-build-llvm not having full effect (#82233)
While LLVM cannot be completely disabled when Swift or LLDB are built, we should still allow skipping LLVM configuration and build steps when Swift and LLDB are not built. This can happen, for example, when `build-script` user wants an ad-hoc incremental build with `--skip-build-swift` and `--skip-build-lldb` for products that don't depend on LLVM and Swift, or if LLVM and Swift were already configured and built in previous `build-script` invocations.
2025-06-16 12:05:31 -07:00
Yuta Saito
df9bed6a29 [wasm] Enable building swift-testing for wasm32-unknown-wasip1-threads 2025-06-12 07:57:40 +09:00
Eric Miotto
b7f8eb7480 build-script: Remove support for legacy way of building compiler-rt
Addresses rdar://149293315
2025-06-11 14:39:05 -07:00
Yuta Saito
2549627293 Merge pull request #82123 from kateinoigakukun/yt/fix-swt-crash-wmo 2025-06-11 06:25:57 +09:00
Yuta Saito
e46480e98c [wasm] Emit libTesting.a objects with single-threaded LLVM codegen unit
Since 5f2b0022d1, swift-testing is being
compiled with WMO, which removes some of inter-object references in
object files by DCE. The inter-object reference removal revealed a
long-standing issue that the runtime metadata sections of objects in an
archive are not always included in the final binary if symbols from
those objects are not referenced anywhere. To force including all
metadata sections in the final binary, we have to emit everything in a
single object file when building the archive.
This issue happens only for Wasm SDK, which ships swift-testing as a
static archive.
2025-06-09 21:48:59 +00:00
Ben Barham
3982ebbbb3 [Build] Pass the toolchain version through to Swift's compilation
Passes the value of the environment variable `TOOLCHAIN_VERSION` through
to Swift's `SWIFT_TOOLCHAIN_VERSION` for use in eg.
`-print-target-info` (and some day, `--version`).
2025-06-06 15:09:21 -07:00
Alastair Houghton
df35df17ce [Build] Fix the minimal-stdlib build by setting a deployment version.
We need to set a deployment version, not just blank, because otherwise
we don't know the correct deployment target to use for the standard
library.
2025-06-05 13:09:43 +01:00
Alastair Houghton
d5ed335339 Merge pull request #81440 from al45tair/currentos-availability
[Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
2025-06-03 15:01:22 +01:00
Yuta Saito
94b40d1bde Merge pull request #81799 from kateinoigakukun/yt/unify-wasmllvmruntime-build-dir
[wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
2025-05-28 23:31:37 +09:00
Yuta Saito
1592c9e2b3 [wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
Having separate build product does not make sense and just adds
complexity to manage build directory names.
2025-05-28 04:14:23 +00:00
Evan Wilde
a313a63bba Merge pull request #81662 from etcwilde/ewilde/aarch64-freebsd
Fix the ARM architecture on FreeBSD
2025-05-22 20:21:17 -07:00
Evan Wilde
fd2ba8b95d Fix the ARM architecture on FreeBSD
The 64-bit ARM architecture spelling on FreeBSD is aarch64, not arm64.
This results in a build failure about a missing
`freebsd/arm64/swiftrt.o` while building the runtimes.
2025-05-20 21:38:41 -07:00
Evan Wilde
5f2b0022d1 Build Swift-Testing with WMO
This tells build-script to build Swift-testing with WMO.
This results in a faster build products, but is also necessary for
configurations using the legacy swift driver, which would emit an
invalid swift interface in non-WMO builds.

Fixes: rdar://151357567
2025-05-19 13:24:23 -07:00
Eric Miotto
a5261ae492 Merge pull request #81386 from edymtt/edymtt/do-not-crosscompile-llvm-under-linux
Reenable build of compiler-rt with LLVM_ENABLE_RUNTIMES in Linux bots...
2025-05-14 06:47:30 -07:00
Eric Miotto
fcc03898c7 Reenable build of compiler-rt with LLVM_ENABLE_RUNTIMES in Linux bots...
...we disabled in #81354

This requires a couple of supporting changes

* under Linux, do not cross compile LLVM when building for the host
 architecture -- that will ensure that the compiler-rt build will use
the just built compiler and not the system one (which may not be
new enough for this purpose);
* provide sanitizer flags depending on the linker the just built compiler
 will use -- this detection is brittle, so print a message advising the
user how to override this.

Addresses rdar://150849329
2025-05-13 08:34:11 -07:00
Alastair Houghton
28f96e64ab [Concurrency][Stdlib] Add SwiftStdlibCurrentOS availability, use it.
If you use SwiftStdlibCurrentOS availability, you will be able to
use new types and functions from within the implementation. This
works by, when appropriate, building with the CurrentOS availability
set to the current deployment target.

rdar://150944675
2025-05-12 12:07:24 +01:00
Max Desiatov
eac419b8ca Merge pull request #81178 from swiftlang/maxd/install-wasmkit
This enables `swift run` and `swift test` to use WasmKit when cross-compiling to Wasm with Swift SDKs that have toolsets pointing to WasmKit.

rdar://150382758
2025-05-12 02:27:49 +01:00
Max Desiatov
06bee27b9e Set rpath correctly for installed wasmkit binary 2025-05-11 17:36:28 +01:00
Evan Wilde
6ad5c40caa Merge pull request #81364 from etcwilde/ewilde/extend-swift-cmake-options
[Build-Script]: Extend Swift cmake options
2025-05-09 09:07:48 -07:00
finagolfin
e76b97e2b7 [build-script] Add an option to build the Foundation tests in another mode (#78390)
Use it in the linux CI presets to set them to Debug mode and speed up
the linux CI, plus add a new preset which keeps building them in Release
mode.

I was looking at a passing linux CI run and saw the log timings at the
end: it takes [longer to build and test the swift-foundation repos than
to compile all 7k+ mostly C++ files in
LLVM](https://ci.swift.org/job/swift-PR-Linux/18996/console)!
```
--- Build Script Analyzer ---
Build Script Log: /home/build-user/build/.build_script_log
Build Percentage 	 Build Duration (sec) 	 Build Phase
================ 	 ==================== 	 ===========
9.2%              	 1132.94               	 Running tests for foundationtests
9.1%              	 1120.57               	 linux-x86_64-swift-build
9.0%              	 1104.2                	 Building llvm
7.2%              	 878.84                	 Running tests for swiftfoundationtests
6.5%              	 796.81                	 Running tests for swiftpm
5.6%              	 684.7                 	 Building swiftpm
5.5%              	 667.92                	 linux-x86_64-swift-test
4.9%              	 597.64
```
Looking at the log, building swift-foundation in release mode takes a
long time, so let's see if changing it to debug mode helps. Some
background - the Foundation repos are built twice on the linux CI: once
by CMake, which is the version installed in the toolchain, then a second
time by SwiftPM purely for testing.

This pull only affects that second SwiftPM build for testing, which is
not shipped in the final toolchain but thrown away.
2025-05-09 21:07:01 +05:30
Max Desiatov
7db6c5ddaa Build CMake on macOS if one is not preinstalled (#81161)
We build CMake on all platforms (except Darwin for an unknown reason) if CMake is not preinstalled. Since CMake 4.0 regresses certain build configurations, there's currently no way to build on Darwin without installing an older CMake version 3.x manually. This can be simplified if we build a pinned version of CMake consistently on all platforms.
2025-05-09 15:59:05 +01:00
Yuta Saito
3dc24b83bd Merge pull request #81387 from kateinoigakukun/yt/remove-wasilibc-workaround 2025-05-09 19:03:57 +08:00
Yuta Saito
e32566154b [wasm] Remove workaround for wasi-libc's check-symbols target
Our LLVM has been already updated to 19, so we no longer need to
workaround the `__FPCLASS_XXX` macro issue in wasi-libc's
check-symbols target.
2025-05-08 23:31:35 +00:00
Max Desiatov
cb038fa0da Build WasmKit with the freshly-built SwiftPM 2025-05-08 16:11:55 +01:00
Max Desiatov
07d611ec5a Merge branch 'main' of https://github.com/swiftlang/swift into maxd/install-wasmkit 2025-05-08 13:03:41 +01:00
Evan Wilde
004a738c70 [Build-Script]: Extend Swift cmake options
The existing swift-cmake-options flag overwrites all flags computed by
build-script. Sometimes it is useful to be able to append additional
CMake flags without overwriting the existing flags.
This patch adds `--extra-swift-cmake-options` that adds the specified
flags to the Swift CMake configuration instead of overwriting them.

This also adds a similar `--extra-llvm-cmake-options`, which adds the
new flags to the end, allowing one to replace and overwrite CMake flags
that build-script computed.
Due to the parameter passing mechanisms in build-script-impl, while this
behavior would be useful for Swift, it is not immediately apparent how
one would best implement this at this time.
2025-05-07 14:49:45 -07:00
Eric Miotto
ad3616f5fa LLVM build product: build LLVMTestingSupport by default
This supports scenarios when tests are run separately from
`build-script` using e.g. `run-test`

Addresses rdar://150774282
2025-05-06 10:11:19 -07:00
Eric Miotto
1bf6ac8118 compiler-rt: use the current host architecture for the runtime targets
This will ensure all the test executables generated by `check-*` targets
can run on the current machine.

Addresses rdar://150469492
2025-05-01 15:48:12 -07:00
Max Desiatov
9ba86e7b28 Rename wasmkit-cli to wasmkit when installing 2025-05-01 10:10:55 +01:00
Max Desiatov
7bb6282c60 Copy WasmKit to install_destdir
This enables `swift run` and `swift test` to use WasmKit when cross-compiling to Wasm with Swift SDKs that have toolsets pointing to WasmKit.
2025-04-29 22:07:02 +01:00
Kuba Mracek
c5aa98a449 [embedded] Make the CMake setup for Embedded Concurrency distnguish ARCH and SUBDIR for builds products 2025-04-26 07:03:19 -07:00
Eric Miotto
7b001765bd Merge pull request #80174 from edymtt/edymtt/use-runtimes-build-quater
build-script: Permit to build compiler-rt with `LLVM_ENABLE_RUNTIMES`
2025-04-22 06:48:17 -07:00